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 <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
Allan Sandfeld Jensen 2015-07-14 15:32:40 +02:00
parent e92c2e119b
commit 01c15a9438

View File

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