diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-01-22 13:47:08 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-01-24 13:17:33 +0100 |
commit | 502d3d6744913899da87acfda5ebdab42c40329e (patch) | |
tree | 16658a328503bfd5a62b4fd5d69ffb66e9854b18 /tests/auto/gui/image/qimage | |
parent | d1be8b9ceb2c7b20bbe53a07154c79699540ea3d (diff) | |
parent | 06bb315beb6c2c398223cfe52cbc7f66e14a8557 (diff) |
Merge remote-tracking branch 'origin/dev' into merge-dev
Change-Id: I31b761cfd5ea01373c60d02a5da8c33398d34739
Diffstat (limited to 'tests/auto/gui/image/qimage')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2a9b92ed35..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(); @@ -924,6 +926,9 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff0000ff << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("semigray argb32 -> a2rgb30 pm") << int(QImage::Format_ARGB32) << 0x4c646565u + << int(QImage::Format_A2RGB30_Premultiplied) << 0x55212222u; + QTest::newRow("white gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xfffffeffu << int(QImage::Format_ARGB32_Premultiplied) << 0xfffefefeu; QTest::newRow("gray gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff565557u @@ -3083,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"); |