Ticket #2154: mythgalleryAR.diff

File mythgalleryAR.diff, 2.0 KB (added by drdaz7@…, 19 years ago)

Aspect Ratio patch for mythgallery

  • glsingleview.cpp

     
    3535
    3636#include "glsingleview.h"
    3737#include "galleryutil.h"
     38#include <X11/Xlib.h>
    3839
    3940GLSDialog::GLSDialog(const ThumbList& itemList, int pos, int slideShow,
    4041                     MythMainWindow *parent, const char *name)
     
    574575
    575576    QImage image(item->path);
    576577    if (!image.isNull()) {
     578        // get screen aspect
     579        Display  *display;
     580        display = XOpenDisplay(NULL);
    577581
     582        int scr = DefaultScreen(display);
     583        int s_height_mm = DisplayHeightMM(display,scr);
     584        int s_width_mm = DisplayWidthMM(display,scr);
     585        int s_height_px = DisplayHeight(display,scr);
     586        int s_width_px = DisplayWidth(display,scr);
     587
     588        double aspect_h = (double)s_height_px/(double)s_height_mm;
     589        double aspect_w = (double)s_width_px/(double)s_width_mm;
     590
     591        double scale_factor_w = 1;
     592
     593        scale_factor_w = aspect_w / aspect_h;
     594
    578595        int a  = m_tex1First ? 0 : 1;
    579596        TexItem& t = m_texItem[a];
    580597
     
    582599        t.angle    = 0;
    583600
    584601        t.angle = item->GetRotationAngle();
     602
     603       t.width  = (int)round(image.width() * scale_factor_w);
     604        t.height = (int)round(image.height());
    585605
    586         t.width  = image.width();
    587         t.height = image.height();
    588 
    589606        if (t.angle%180 != 0) {
     607           t.width = image.width();
    590608            int tmp  = t.width;
    591             t.width  = t.height;
     609            t.width  = t.height * scale_factor_w;
    592610            t.height = tmp;
    593611        }
    594612
  • glsingleview.h

     
    8585    int           screenwidth, screenheight;
    8686    float         wmult, hmult;
    8787    int           m_w, m_h;
     88    double        scale_factor_w;
    8889
    8990    TexItem       m_texItem[2];
    9091    int           m_curr;