From 0ff1dc7110d373c85ce41e90073291b5e2eb16ad Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 11 Feb 2021 11:23:05 +0100 Subject: Fix alpha handling of QImage::setPixel It was treated differently depending on format, made it consistently behave the same for all formats (following the behavior of the primary formats). Change-Id: Ie24e19957d076fdf3ebd333074e26ede187489eb Reviewed-by: Eirik Aavitsland (cherry picked from commit c32cd44d34910cfd42e32537578e4a573138a282) --- src/gui/image/qimage.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/gui/image/qimage.cpp') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2c356dba16..9a9ab873ff 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2470,7 +2470,7 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) ((uint *)s)[x] = index_or_rgb; return; case Format_RGB16: - ((quint16 *)s)[x] = qConvertRgb32To16(qUnpremultiply(index_or_rgb)); + ((quint16 *)s)[x] = qConvertRgb32To16(index_or_rgb); return; case Format_RGBX8888: ((uint *)s)[x] = ARGB2RGBA(0xff000000 | index_or_rgb); @@ -2491,6 +2491,10 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) case Format_A2RGB30_Premultiplied: ((uint *)s)[x] = qConvertArgb32ToA2rgb30(index_or_rgb); return; + case Format_RGBA64: + case Format_RGBA64_Premultiplied: + ((QRgba64 *)s)[x] = QRgba64::fromArgb32(index_or_rgb); + return; case Format_Invalid: case NImageFormats: Q_ASSERT(false); @@ -2500,7 +2504,10 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) } const QPixelLayout *layout = &qPixelLayouts[d->format]; - layout->storeFromARGB32PM(s, &index_or_rgb, x, 1, nullptr, nullptr); + if (!hasAlphaChannel()) + layout->storeFromRGB32(s, &index_or_rgb, x, 1, nullptr, nullptr); + else + layout->storeFromARGB32PM(s, &index_or_rgb, x, 1, nullptr, nullptr); } /*! -- cgit v1.2.3