From 01c15a94387f8791e2bd600519de98bd0e03f266 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Jul 2015 15:32:40 +0200 Subject: Always return grayscale indexed8 from QImage::alphaChannel() We shouldn't short-cut alpha8 formats in alphaChannel, the method is used under the assumption that the returned alpha map has encoded the alphas as an indexed grayscale image. The method is also documented as not returning alpha8. Task-number: QTBUG-47138 Change-Id: I1cf16957d12e65d44f2b586d9f127fcb33c549b6 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/gui/image/qimage.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 08eb759ec2..176cdfe09f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4134,9 +4134,6 @@ QImage QImage::alphaChannel() const if (!d) return QImage(); - if (d->format == QImage::Format_Alpha8) - return *this; - int w = d->width; int h = d->height; @@ -4166,6 +4163,10 @@ QImage QImage::alphaChannel() const src_data += d->bytes_per_line; dest_data += image.d->bytes_per_line; } + } else if (d->format == Format_Alpha8) { + const uchar *src_data = d->data; + uchar *dest_data = image.d->data; + memcpy(dest_data, src_data, d->bytes_per_line * h); } else { QImage alpha32 = *this; bool canSkipConversion = (d->format == Format_ARGB32 || d->format == Format_ARGB32_Premultiplied); -- cgit v1.2.3