diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-12-18 13:16:20 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-12-19 11:45:41 +0100 |
commit | 09f19e48ac2a34ea2df9d19267599e05d64d45c6 (patch) | |
tree | 443f50e6e3fddf24461fbfd030f6e3bd3b97b090 /src/plugins/imageformats | |
parent | 322e5b7f5e35db73f7d7730a6fff558e153ad356 (diff) |
Fix unneeded use of QImage invertPixels and createAlphaMask
The result of createAlphaMask was mostly overwritten and then inverted,
we can write the right values directly instead.
Change-Id: I3cdddcc74218a4058bddd20178733688607c8a01
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/plugins/imageformats')
-rw-r--r-- | src/plugins/imageformats/ico/qicohandler.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index c8e31dceac..6515748bf5 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -615,13 +615,7 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) } QImage maskImage(image.width(), image.height(), QImage::Format_Mono); image = image.convertToFormat(QImage::Format_ARGB32); - - if (image.hasAlphaChannel()) { - maskImage = image.createAlphaMask(); - } else { - maskImage.fill(0xff); - } - maskImage = maskImage.convertToFormat(QImage::Format_Mono); + maskImage.fill(Qt::color1); int nbits = 32; int bpl_bmp = ((image.width()*nbits+31)/32)*4; @@ -671,7 +665,7 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) *b++ = qRed(*p); *b++ = qAlpha(*p); if (qAlpha(*p) > 0) // Even mostly transparent pixels must not be masked away - maskImage.setPixel(x, y, Qt::color1); // (i.e. createAlphaMask() takes away too much) + maskImage.setPixel(x, y, 0); p++; x++; } @@ -679,7 +673,6 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) } delete[] buf; - maskImage.invertPixels(); // seems as though it needs this // NOTE! !! The mask is only flipped vertically - not horizontally !! for (y = maskImage.height() - 1; y >= 0; y--) buffer.write((char*)maskImage.scanLine(y), maskImage.bytesPerLine()); |