diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-12-03 15:15:19 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-12-04 09:54:39 +0000 |
commit | c04e7dead8bee51e11698fe1c625c76915a60753 (patch) | |
tree | e42259c20a7b33ca2558bbabc0998f758608e692 /tests/auto/gui/image/qimage/tst_qimage.cpp | |
parent | 2366ecfb2dbf96eda8fa77d1f8cb484d80b52642 (diff) |
QImage pixelColor and setPixelColor must use unpremultiplied QColor
QColor always uses unpremultiplied alpha, but the new QImage methods
were based on the QRgb versions which might be either. This patches fixes
the two new methods so they treat QColor alpha correctly.
Change-Id: I78a5b875ad4e78ad7fde3b811c6187482b4f6d15
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 5574a92ad9..23ddfbdd58 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -196,6 +196,8 @@ private slots: void metadataPassthrough(); + void pixelColor(); + private: const QString m_prefix; }; @@ -3020,5 +3022,21 @@ void tst_QImage::metadataPassthrough() QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio()); } +void tst_QImage::pixelColor() +{ + QImage argb32(1, 1, QImage::Format_ARGB32); + QImage argb32pm(1, 1, QImage::Format_ARGB32_Premultiplied); + + QColor c(Qt::red); + c.setAlpha(128); + argb32.setPixelColor(QPoint(0, 0), c); + argb32pm.setPixelColor(QPoint(0, 0), c); + QCOMPARE(argb32.pixelColor(QPoint(0, 0)), c); + QCOMPARE(argb32pm.pixelColor(QPoint(0, 0)), c); + + QImage t = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QCOMPARE(t.pixel(0,0), argb32pm.pixel(0,0)); +} + QTEST_GUILESS_MAIN(tst_QImage) #include "tst_qimage.moc" |