diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-03-16 11:52:28 (GMT) |
---|---|---|
committer | Timo Turunen <timo.p.turunen@nokia.com> | 2011-03-17 08:52:34 (GMT) |
commit | a92f15eaae6981bf420477e4736f169b4224a6c4 (patch) | |
tree | c8e36ca2ca57dac05a2fa87f898b2cd7158e9249 | |
parent | 3fa85afd04ba67c762ca7489c63b4bfc4a6deac0 (diff) | |
download | Qt-a92f15eaae6981bf420477e4736f169b4224a6c4.zip Qt-a92f15eaae6981bf420477e4736f169b4224a6c4.tar.gz Qt-a92f15eaae6981bf420477e4736f169b4224a6c4.tar.bz2 |
Fix for wrong dpi metrics for raster pixmaps on Symbian.
The original implementation relied on SizeInTwips() for the underlying
bitmap which unfortunately returns 0, leading to incorrect results
from QPixmap::logicalDpiX/Y(). This caused issues in text rendering
onto pixmaps (QTBUG-17628). This fix changes QS60PixmapData to use a
slightly different metrics() implementation (the one VG and GL
PixmapData are using).
Task-number: QTBUG-18154
Reviewed-by: Jani Hautakangas
(cherry picked from commit 48629ab39aa4e20b21a359dc251569a98606983d)
-rw-r--r-- | src/gui/image/qpixmap_s60.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 2bde2e5..0de99f8 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -599,6 +599,9 @@ bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect) return res; } +Q_GUI_EXPORT int qt_defaultDpiX(); +Q_GUI_EXPORT int qt_defaultDpiY(); + int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!cfbsBitmap) @@ -609,28 +612,18 @@ int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const return cfbsBitmap->SizeInPixels().iWidth; case QPaintDevice::PdmHeight: return cfbsBitmap->SizeInPixels().iHeight; - case QPaintDevice::PdmWidthMM: { - TInt twips = cfbsBitmap->SizeInTwips().iWidth; - return (int)(twips * (25.4/KTwipsPerInch)); - } - case QPaintDevice::PdmHeightMM: { - TInt twips = cfbsBitmap->SizeInTwips().iHeight; - return (int)(twips * (25.4/KTwipsPerInch)); - } + case QPaintDevice::PdmWidthMM: + return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); + case QPaintDevice::PdmHeightMM: + return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); case QPaintDevice::PdmNumColors: return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); case QPaintDevice::PdmDpiX: - case QPaintDevice::PdmPhysicalDpiX: { - TReal inches = cfbsBitmap->SizeInTwips().iWidth / (TReal)KTwipsPerInch; - TInt pixels = cfbsBitmap->SizeInPixels().iWidth; - return pixels / inches; - } + case QPaintDevice::PdmPhysicalDpiX: + return qt_defaultDpiX(); case QPaintDevice::PdmDpiY: - case QPaintDevice::PdmPhysicalDpiY: { - TReal inches = cfbsBitmap->SizeInTwips().iHeight / (TReal)KTwipsPerInch; - TInt pixels = cfbsBitmap->SizeInPixels().iHeight; - return pixels / inches; - } + case QPaintDevice::PdmPhysicalDpiY: + return qt_defaultDpiY(); case QPaintDevice::PdmDepth: return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); default: |