summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimage
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2021-02-21 20:46:22 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-03-08 08:27:41 +0000
commit1471f2ae0924e5d124178d1953a14db889348da0 (patch)
treedef325a49c4caced38619631008b2ccc62c02967 /tests/auto/gui/image/qimage
parent4f37cf2ce544dad5b207161536566627b6b0b1ef (diff)
Add deviceIndependentSize() to QPixmap and QImage
This function returns the size in device independent pixels, and should be used when calculating user interface sizes. Change-Id: I528123f962595a3da42438ca560289a29aca4917 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/gui/image/qimage')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 1554ac3602..12345b2a97 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -212,6 +212,7 @@ private slots:
void cleanupFunctions();
void devicePixelRatio();
+ void deviceIndependentSize();
void rgb30Unpremul();
void rgb30Repremul_data();
void rgb30Repremul();
@@ -3473,6 +3474,15 @@ void tst_QImage::devicePixelRatio()
QCOMPARE(b.devicePixelRatio(), qreal(1.0));
}
+void tst_QImage::deviceIndependentSize() {
+ QImage a(64, 64, QImage::Format_ARGB32);
+ a.fill(Qt::white);
+ a.setDevicePixelRatio(1.0);
+ QCOMPARE(a.deviceIndependentSize(), QSizeF(64, 64));
+ a.setDevicePixelRatio(2.0);
+ QCOMPARE(a.deviceIndependentSize(), QSizeF(32, 32));
+}
+
void tst_QImage::rgb30Unpremul()
{
QImage a(3, 1, QImage::Format_A2RGB30_Premultiplied);