summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-07-14 15:32:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-09 09:13:30 +0000
commit01c15a94387f8791e2bd600519de98bd0e03f266 (patch)
tree09ec07133ec03e6cbe36f768f281a658029798be /src/gui/image
parente92c2e119beb06e3ef47ae6fd871b34ec0ef0939 (diff)
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>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp7
1 files 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);