summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-12-04 11:30:43 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-04 16:28:20 +0000
commit5e548d35928f1efdeae54b6f93144d26eeebaee2 (patch)
treecf7efa73a76c0e500d1b383f58f6985f98781293
parent751892a21c796130cdceaa8cee4aeeea18618c5e (diff)
Fix QImage::setPixelColor on RGBA64_Premultiplied5.12
QColors were not premultiplied before being set. Change-Id: Id3765b6932a72374ddfd788fae4bb628a4edf0b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 0c19e3f703a7c3fd59e6db8a9d4ac7091674b552) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/image/qimage.cpp5
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp8
2 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index ef0481bdb2..7b3ca0f7ee 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2627,12 +2627,9 @@ void QImage::setPixelColor(int x, int y, const QColor &color)
((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(c);
return;
case Format_RGBX64:
- ((QRgba64 *)s)[x] = color.rgba64();
- ((QRgba64 *)s)[x].setAlpha(65535);
- return;
case Format_RGBA64:
case Format_RGBA64_Premultiplied:
- ((QRgba64 *)s)[x] = color.rgba64();
+ ((QRgba64 *)s)[x] = c;
return;
default:
setPixel(x, y, c.toArgb32());
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index bb81b9f61f..b2873d6f8a 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -3324,6 +3324,14 @@ void tst_QImage::pixelColor()
// Try setting an invalid color.
QTest::ignoreMessage(QtWarningMsg, "QImage::setPixelColor: color is invalid");
argb32.setPixelColor(0, 0, QColor());
+
+ // Test correct premultiplied handling of RGBA64 as well
+ QImage rgba64(1, 1, QImage::Format_RGBA64);
+ QImage rgba64pm(1, 1, QImage::Format_RGBA64_Premultiplied);
+ rgba64.setPixelColor(QPoint(0, 0), c);
+ rgba64pm.setPixelColor(QPoint(0, 0), c);
+ QCOMPARE(rgba64.pixelColor(QPoint(0, 0)), c);
+ QCOMPARE(rgba64pm.pixelColor(QPoint(0, 0)), c);
}
void tst_QImage::pixel()