Fix artifacts when reading certain 32 bit ico files
Images in an ico file contains transparency information stored as a 1 bit mask. However, when the depth is 32 bit, it means there is an alpha channel present, and the mask should be ignored. The Qt ico handler failed to do that. This has gone unnoticed, since the mask in such images is typically set to all 0s, and so makes no difference to the result. But ico files exist that contain junk mask data, so fix the reader to ignore it properly. Fixes: QTBUG-75214 Change-Id: I1b4456d71689ec783076a582f2fb215e7dc56e62 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>bb10
parent
d6c3fa6e0c
commit
1d128ed1df
|
|
@ -523,17 +523,21 @@ QImage ICOReader::iconAt(int index)
|
|||
if (!image.isNull()) {
|
||||
readBMP(image);
|
||||
if (!image.isNull()) {
|
||||
QImage mask(image.width(), image.height(), QImage::Format_Mono);
|
||||
if (!mask.isNull()) {
|
||||
mask.setColorCount(2);
|
||||
mask.setColor(0, qRgba(255,255,255,0xff));
|
||||
mask.setColor(1, qRgba(0 ,0 ,0 ,0xff));
|
||||
read1BitBMP(mask);
|
||||
if (icoAttrib.depth == 32) {
|
||||
img = std::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
} else {
|
||||
QImage mask(image.width(), image.height(), QImage::Format_Mono);
|
||||
if (!mask.isNull()) {
|
||||
img = image;
|
||||
img.setAlphaChannel(mask);
|
||||
// (Luckily, it seems that setAlphaChannel() does not ruin the alpha values
|
||||
// of partially transparent pixels in those icons that have that)
|
||||
mask.setColorCount(2);
|
||||
mask.setColor(0, qRgba(255,255,255,0xff));
|
||||
mask.setColor(1, qRgba(0 ,0 ,0 ,0xff));
|
||||
read1BitBMP(mask);
|
||||
if (!mask.isNull()) {
|
||||
img = image;
|
||||
img.setAlphaChannel(mask);
|
||||
// (Luckily, it seems that setAlphaChannel() does not ruin the alpha values
|
||||
// of partially transparent pixels in those icons that have that)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue