summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimage/tst_qimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index b84aa52465..71aaa23da4 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -32,7 +32,7 @@
#include <qimage.h>
#include <qimagereader.h>
#include <qlist.h>
-#include <qmatrix.h>
+#include <qtransform.h>
#include <qrandom.h>
#include <stdio.h>
@@ -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
@@ -1199,7 +1204,7 @@ void tst_QImage::rotate()
// original.save("rotated90_original.png", "png");
// Initialize the matrix manually (do not use rotate) to avoid rounding errors
- QMatrix matRotate90;
+ QTransform matRotate90;
matRotate90.rotate(degrees);
QImage dest = original;
// And rotate it 4 times, then the image should be identical to the original
@@ -1213,7 +1218,7 @@ void tst_QImage::rotate()
// dest.save("rotated90_result.png","png");
QCOMPARE(original, dest);
- // Test with QMatrix::rotate 90 also, since we trust that now
+ // Test with QTransform::rotate 90 also, since we trust that now
matRotate90.rotate(degrees);
dest = original;
// And rotate it 4 times, then the image should be identical to the original
@@ -2132,6 +2137,12 @@ void tst_QImage::paintEngine()
QCOMPARE(engine, img.paintEngine());
QCOMPARE(img, expected);
+
+ {
+ QImage img1(16, 16, QImage::Format_ARGB32);
+ QImage img2 = img1;
+ QVERIFY(img2.paintEngine());
+ }
}
void tst_QImage::setAlphaChannelWhilePainting()
@@ -3077,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");