From a9458a175598a0da0fdfbfed7f9470878af25b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 24 Jan 2013 09:09:28 +0100 Subject: Clean up logical dpi for QImage. Revert to the pre highdpi-patch behaviour. Before, both physical and logical DPI would be based on the dpmx/dpmy variables, which could be changed with setDotsPerMeter(). The highdpi patch introduced separate ldpmx/ldpmy variables, which were not changed by setDotsPerMeter(). This broke when loading images: setDotsPerMeter would be called but the logical dpi would not change. Remove ldpmx/ldpmy. Keep scaling the physical dpi by the devicePixelRatio, which will be set to 1 by default. Task-number: QTBUG-29187 Change-Id: I0d6f5f3b8efae5fb1adc0a50b22a5da78324a282 Reviewed-by: Gunnar Sletta --- tests/auto/gui/image/qimage/tst_qimage.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto/gui/image/qimage') diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 6f372b0160..b668f57909 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -86,6 +86,7 @@ private slots: #endif void dotsPerMeterZero(); + void dotsPerMeterAndDpi(); void convertToFormatPreserveDotsPrMeter(); void convertToFormatPreserveText(); @@ -899,6 +900,27 @@ void tst_QImage::dotsPerMeterZero() QCOMPARE(img.dotsPerMeterX(), defaultDpmX); QCOMPARE(img.dotsPerMeterY(), defaultDpmY); + +} + +// verify that setting dotsPerMeter has an effect on the dpi. +void tst_QImage::dotsPerMeterAndDpi() +{ + QImage img(100, 100, QImage::Format_RGB32); + QVERIFY(!img.isNull()); + + QPoint defaultLogicalDpi(img.logicalDpiX(), img.logicalDpiY()); + QPoint defaultPhysicalDpi(img.physicalDpiX(), img.physicalDpiY()); + + img.setDotsPerMeterX(100); // set x + QCOMPARE(img.logicalDpiY(), defaultLogicalDpi.y()); // no effect on y + QCOMPARE(img.physicalDpiY(), defaultPhysicalDpi.y()); + QVERIFY(img.logicalDpiX() != defaultLogicalDpi.x()); // x changed + QVERIFY(img.physicalDpiX() != defaultPhysicalDpi.x()); + + img.setDotsPerMeterY(200); // set y + QVERIFY(img.logicalDpiY() != defaultLogicalDpi.y()); // y changed + QVERIFY(img.physicalDpiY() != defaultPhysicalDpi.y()); } void tst_QImage::rotate_data() -- cgit v1.2.3