summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-06-17 13:31:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-06-20 16:08:28 +0200
commit70dd5630463cb8aabd927a3a4944aedbd90b70af (patch)
tree54dad54feff32e13a2539f303d6b31bec480b0e1 /tests/auto/gui/image
parente98c461d43ea07c73898c93debe9285029ba0416 (diff)
Correct QImage::fill(uint) on RGBA8888 formats
QImage::fill(uint) was incorrectly performing ARGB->RGBA conversion when called on RGBA8888 formated images. This patch moves the color conversion to QImage::fill(QColor) where it belongs so that fill(uint) can behave consistent with documentation and how it treats other formats. The fill(uint) method had no automated tests, and this patch adds one. [ChangeLog][QtGui][QImage] QImage::fill(uint) now fills the given pixel value unconverted when used on RGBA8888 image, making it consistent with the documentation and treatment of all other image formats. Change-Id: I00a9d810c61d350dbdd7c4b9ad09e5ce11896b6d Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/gui/image')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 95a9b142ec..65ecd54526 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -146,6 +146,9 @@ private slots:
void fillRGB888();
+ void fillPixel_data();
+ void fillPixel();
+
void rgbSwapped_data();
void rgbSwapped();
@@ -2054,6 +2057,42 @@ void tst_QImage::fillRGB888()
}
}
+void tst_QImage::fillPixel_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<uint>("color");
+ QTest::addColumn<uint>("pixelValue");
+
+ QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << 0x0u << 0xff000000u;
+ QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << 0x0u << 0xff000000u;
+ QTest::newRow("RGBx8888, transparent") << QImage::Format_RGBX8888 << 0x0u << 0xff000000u;
+ QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
+ QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
+ QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
+
+ QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
+ QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u;
+ QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
+ QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
+
+ QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
+ QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
+ QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
+ QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
+}
+
+void tst_QImage::fillPixel()
+{
+ QFETCH(QImage::Format, format);
+ QFETCH(uint, color);
+ QFETCH(uint, pixelValue);
+
+ QImage image(1, 1, format);
+
+ image.fill(color);
+ QCOMPARE(image.pixel(0, 0), pixelValue);
+}
+
void tst_QImage::rgbSwapped_data()
{
QTest::addColumn<QImage::Format>("format");