summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-04-24 16:04:14 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-04-28 12:42:12 +0000
commitf15d6c3fa910d5200e245fe15ae9932f4b4eca78 (patch)
tree9f2d7352f2b2cb3779ffd2110aa0b9cf308adcb9 /tests
parent1576f62eaf962aaaaba83337284d23c732bfb52b (diff)
Preserve QImage metadata in image transforms
Some QImage methods were not preserving image metadata, or only preserving some of it. This adds the missing parts and adds a test for metadata. Change-Id: Ib5892a23e49dfde5ea26074d3deaa887fa930c6b Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 5691a654d7..51e4c6233e 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -184,6 +184,8 @@ private slots:
void devicePixelRatio();
+ void metadataPassthrough();
+
private:
const QString m_prefix;
};
@@ -2827,5 +2829,39 @@ void tst_QImage::devicePixelRatio()
QCOMPARE(b.devicePixelRatio(), qreal(1.0));
}
+void tst_QImage::metadataPassthrough()
+{
+ QImage a(64, 64, QImage::Format_ARGB32);
+ a.fill(Qt::white);
+ a.setText(QStringLiteral("Test"), QStringLiteral("Text"));
+ a.setDotsPerMeterX(100);
+ a.setDotsPerMeterY(80);
+ a.setDevicePixelRatio(2.0);
+
+ QImage scaled = a.scaled(QSize(32, 32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
+
+ scaled = a.scaled(QSize(128, 128), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage mirrored = a.mirrored();
+ QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage swapped = a.rgbSwapped();
+ QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio());
+}
+
QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc"