Fix QImage::setPixelColor on RGBA64_Premultiplied

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>
This commit is contained in:
Allan Sandfeld Jensen 2020-12-04 11:30:43 +01:00 committed by Qt Cherry-pick Bot
parent 751892a21c
commit 5e548d3592
2 changed files with 9 additions and 4 deletions

View File

@ -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());

View File

@ -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()