summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-12-19 15:00:15 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-12-19 16:16:50 +0100
commit6227a0d2e2e924cf717fa2a3d7c3e1223c4aed5f (patch)
tree09871d6e201ef05622f455f1b4a236958b16de00 /tests/auto
parent09f19e48ac2a34ea2df9d19267599e05d64d45c6 (diff)
Add test for invertPixels on indexed formats
It wasn't tested and behaves in a very particular way. Change-Id: I60a31681e5b221cf9a86df77e410a76ee4c10864 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index e9aa9aad30..bc964e0d5c 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -191,6 +191,8 @@ private slots:
void invertPixelsRGB_data();
void invertPixelsRGB();
+ void invertPixelsIndexed();
+
void exifOrientation_data();
void exifOrientation();
@@ -3086,6 +3088,36 @@ void tst_QImage::invertPixelsRGB()
QCOMPARE(qBlue(pixel) >> 4, (255 - 96) >> 4);
}
+void tst_QImage::invertPixelsIndexed()
+{
+ {
+ QImage image(1, 1, QImage::Format_Mono);
+ image.fill(Qt::color1);
+ image.invertPixels();
+ QCOMPARE(image.pixelIndex(0, 0), 0);
+ }
+ {
+ QImage image(1, 1, QImage::Format_MonoLSB);
+ image.fill(Qt::color0);
+ image.invertPixels();
+ QCOMPARE(image.pixelIndex(0, 0), 1);
+ }
+ {
+ QImage image(1, 1, QImage::Format_Indexed8);
+ image.setColorTable({0xff000000, 0xffffffff});
+ image.fill(Qt::black);
+ image.invertPixels();
+ QCOMPARE(image.pixelIndex(0, 0), 255);
+ }
+ {
+ QImage image(1, 1, QImage::Format_Indexed8);
+ image.setColorTable({0xff000000, 0xffffffff, 0x80000000, 0x80ffffff, 0x00000000});
+ image.fill(Qt::white);
+ image.invertPixels();
+ QCOMPARE(image.pixelIndex(0, 0), 254);
+ }
+}
+
void tst_QImage::exifOrientation_data()
{
QTest::addColumn<QString>("fileName");