Ticket #4162: mythgallery16x9.diff
File mythgallery16x9.diff, 4.5 KB (added by , 16 years ago) |
---|
-
mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.cpp
diff -Naur old/mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.cpp new/mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.cpp
old new 28 28 #include "galleryutil.h" 29 29 #include "thumbgenerator.h" 30 30 31 #ifdef Q_WS_X11 32 #define USING_XV 33 #include "util-x11.h" 34 #endif // Q_WS_X11 35 31 36 #ifdef EXIF_SUPPORT 32 37 #include <libexif/exif-data.h> 33 38 #include <libexif/exif-entry.h> … … 348 353 return false; 349 354 } 350 355 356 QSize GalleryUtil::ScaleToDest(QSize sz, QSize dest) 357 { 358 359 // calculate screen pixel aspect ratio 360 double pixelAspect = 1.0; 361 #ifdef Q_WS_X11 362 Display *display = MythXOpenDisplay(); 363 int scr = DefaultScreen(display); 364 int displayWidthPixel = DisplayWidth(display,scr); 365 int displayHeightPixel = DisplayHeight(display,scr); 366 int displayWidthMM = DisplayWidthMM(display,scr); 367 int displayHeightMM = DisplayHeightMM(display,scr); 368 // avoid divide by 0 369 if ((displayWidthPixel != 0) && (displayHeightPixel != 0) && 370 (displayWidthMM != 0) && (displayHeightMM != 0)) 371 { 372 pixelAspect = 373 ((double)displayWidthMM / (double)displayWidthPixel) / 374 ((double)displayHeightMM / (double)displayHeightPixel); 375 } 376 #endif // Q_WS_X11 377 378 // calculate image aspect ratio 379 double imageAspect = 1.0; 380 // avoid divide by 0 381 if ((sz.width() != 0) && (sz.height() != 0)) 382 { 383 imageAspect = 384 (double)sz.width() / (double)sz.height(); 385 } 386 387 // scale to dest height for most images 388 int scalewidth = (int)((float)dest.height() * imageAspect / pixelAspect); 389 int scaleheight = dest.height(); 390 if (scalewidth > dest.width()) 391 { 392 // scale to dest width for extra wide images 393 scalewidth = dest.width(); 394 scaleheight = (int)((float)dest.width() * pixelAspect / imageAspect); 395 } 396 397 sz.scale(scalewidth, scaleheight, QSize::ScaleFree); 398 return sz; 399 } 400 351 401 bool GalleryUtil::CopyDirectory(const QFileInfo src, QFileInfo &dst) 352 402 { 353 403 QDir srcDir(src.absFilePath()); -
mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.h
diff -Naur old/mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.h new/mythplugins-0.20.2/mythgallery/mythgallery/galleryutil.h
old new 43 43 static bool Copy(const QFileInfo &src, QFileInfo &dst); 44 44 static bool Move(const QFileInfo &src, QFileInfo &dst); 45 45 static bool Delete(const QFileInfo &file); 46 static QSize ScaleToDest(QSize sz, QSize dest); 46 47 47 48 private: 48 49 static bool CopyDirectory(const QFileInfo src, QFileInfo &dst); -
mythplugins-0.20.2/mythgallery/mythgallery/gltexture.cpp
diff -Naur old/mythplugins-0.20.2/mythgallery/mythgallery/gltexture.cpp new/mythplugins-0.20.2/mythgallery/mythgallery/gltexture.cpp
old new 26 26 // MythGallery headers 27 27 #include "thumbview.h" 28 28 #include "gltexture.h" 29 #include "galleryutil.h" 29 30 30 31 /** \fn GLTexture::Init(const QImage&) 31 32 * \brief Create the texture initialized with QImage … … 85 86 86 87 void GLTexture::ScaleTo(const QSize &dest) 87 88 { 88 QSize sz = GetSize(); 89 sz.scale(dest.width(), dest.height(), QSize::ScaleMin); 89 QSize sz = GalleryUtil::ScaleToDest(GetSize(), dest); 90 90 SetScale((float)sz.width() / (float)dest.width(), 91 91 (float)sz.height() / (float)dest.height()); 92 92 } -
mythplugins-0.20.2/mythgallery/mythgallery/singleview.cpp
diff -Naur old/mythplugins-0.20.2/mythgallery/mythgallery/singleview.cpp new/mythplugins-0.20.2/mythgallery/mythgallery/singleview.cpp
old new 594 594 if (m_image.isNull()) 595 595 return; 596 596 597 QImage img = m_image.smoothScale((int) (screenwidth * m_zoom), 598 (int) (screenheight * m_zoom), 599 QImage::ScaleMin); 597 QSize dest = QSize( 598 (int)(screenwidth * m_zoom), 599 (int)(screenheight * m_zoom)); 600 QSize sz = GalleryUtil::ScaleToDest(m_image.size(), dest); 601 QImage img = m_image.smoothScale(sz); 600 602 601 603 SetPixmap(new QPixmap(img)); 602 604 }