[mythtv] mythgallery aspect ratio patch

Kielogl kielogl at yahoo.com
Sat Nov 3 23:08:46 UTC 2007


Hi,

I been enjoying mythtv for some time now, with a minor annoyance. I have a 16:9 screen with 1024x768 (non-square) pixels which means my photos are horizontally stretched in mythgallery.

I recently found an old patch for this problem posted by Julian, at http://mythtv.org/pipermail/mythtv-dev/2004-June/023309.html.

Using a similar approach, the patch below fixes my problem on version 0.20.2. (It also seems ok on version 0.21.)

Is this fix something that could be included in a release a some point?

Thanks,

Mark

=============================================

--- mythplugins-0.20.2/mythgallery/mythgallery/singleview.cpp       2006-07-25 06:59:38.000000000 +1000
+++ mythplugins-0.20.2/mythgallery/mythgallery/singleview.cpp       2007-10-14 13:08:11.000000000 +1000
@@ -40,6 +40,8 @@
 #include "constants.h"
 #include  "galleryutil.h"

+#include <X11/Xlib.h>
+
 #define LOC QString("QtView: ")
 #define LOC_ERR QString("QtView, Error: ")

@@ -594,9 +596,21 @@
     if (m_image.isNull())
         return;

-    QImage img = m_image.smoothScale((int) (screenwidth  * m_zoom),
-                                     (int) (screenheight * m_zoom),
-                                     QImage::ScaleMin);
+    // calculate display pixel aspect ratio
+    Display  *display =  XOpenDisplay(NULL);
+    int scr = DefaultScreen(display);
+    double pixelaspect =
+       ((double)DisplayWidthMM(display,scr) / (double)screenwidth) /
+       ((double)DisplayHeightMM(display,scr) / (double)screenheight);
+
+    // calculate image aspect ratio
+    double imageaspect =
+       (double)m_image.width() / (double)m_image.height();
+
+    QImage img = m_image.smoothScale(
+        (int) (screenheight * imageaspect / pixelaspect * m_zoom),
+        (int) (screenheight * m_zoom),
+        QImage::ScaleFree);

     SetPixmap(new QPixmap(img));
 }
 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20071103/05bfcf4c/attachment.htm 


More information about the mythtv-dev mailing list