[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/kdetv/libkdetv
From: Dirk Ziegelmeier <dziegel () gmx ! de>
Date: 2005-05-23 19:52:02
Message-ID: 1116877922.814925.30170.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 417497 by dziegel:
Correctly fix aspect ratio on screens with non-rectangular pixels
M +22 -7 kdetvview.cpp
--- kdetvview.cpp #417496:417497
@@ -26,6 +26,10 @@
#include "kdetvview.h"
+#include <qapplication.h>
+#include <qpaintdevice.h>
+#include <qpaintdevicemetrics.h>
+
KdetvView::KdetvView(QWidget *parent, const char *name)
: QWidget(parent,name ? name : "kdetv_view")
{
@@ -72,9 +76,20 @@
void KdetvView::resizeWithFixedAR() {
int tmp;
int am = aspectMode;
+ QPaintDeviceMetrics \
m(QApplication::desktop()->screen((QApplication::desktop()->screenNumber(this))));
+ /*
+ kdDebug() << "Screen dpix x dpiy: "
+ << m.logicalDpiY() << "x" << m.logicalDpiX()
+ << " -> aspect correction factor: "
+ << (float)m.logicalDpiX()/(float)m.logicalDpiY()
+ << endl;
+ */
+
+ float ar = aspectRatio * ((float)m.logicalDpiX()/(float)m.logicalDpiY());
+
if (am == AR_BEST_FIT) {
- if( (int)(height() * aspectRatio) <= width() ) {
+ if( (int)(height() * ar) <= width() ) {
am = AR_WIDTH_TO_HEIGHT;
} else {
am = AR_HEIGHT_TO_WIDTH;
@@ -84,19 +99,19 @@
switch( am ) {
case AR_HEIGHT_TO_WIDTH:
// -1 for float->int rounding problems
- tmp = ((height() - (int)(width() / aspectRatio)) / 2) - 1;
+ tmp = ((height() - (int)(width() / ar)) / 2) - 1;
if (tmp > 0) move(0, tmp);
- resize( width(), (int)(width() / aspectRatio) );
+ resize( width(), (int)(width() / ar) );
break;
case AR_WIDTH_TO_HEIGHT:
// -1 for float->int rounding problems
- tmp = ((width() - (int)(height() * aspectRatio)) / 2) - 1;
+ tmp = ((width() - (int)(height() * ar)) / 2) - 1;
if (tmp > 0) move(tmp, 0);
- resize( (int)(height() * aspectRatio), height() );
+ resize( (int)(height() * ar), height() );
break;
default:
- kdDebug() << "KdetvView::resizeWithFixedAR(). AR mode unknown."
- << "We should never reach this point!" << endl;
+ kdWarning() << "KdetvView::resizeWithFixedAR(). AR mode unknown."
+ << "We should never reach this point!" << endl;
break;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic