Remove some uses of QImage::setAlphaChannel

Remove once where it did nothing, and once where using composition mode
masking avoids first creating a masking image.

Change-Id: Ia4c93eac6ebb11fcdab34d306d943a7f87906b7e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
Allan Sandfeld Jensen 2019-12-18 11:25:44 +01:00
parent 9d6b4d1142
commit 23d4c0c34b
2 changed files with 8 additions and 5 deletions

View File

@ -948,9 +948,8 @@ QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation,
if (section == 0) {
// ### TODO oh man this is ugly and doesn't even work all the way!
// it is still 2 pixels off
QImage pixmap(16, 1, QImage::Format_Mono);
pixmap.fill(0);
pixmap.setAlphaChannel(pixmap.createAlphaMask());
QImage pixmap(16, 1, QImage::Format_ARGB32_Premultiplied);
pixmap.fill(Qt::transparent);
return pixmap;
}
break;

View File

@ -1135,8 +1135,12 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
destImage = std::move(buffer);
}
if (srcImage.hasAlphaChannel())
destImage.setAlphaChannel(srcImage.alphaChannel());
if (srcImage.hasAlphaChannel()) {
Q_ASSERT(destImage.format() == QImage::Format_ARGB32_Premultiplied);
QPainter maskPainter(&destImage);
maskPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
maskPainter.drawImage(0, 0, srcImage);
}
painter->drawImage(dest, destImage);
}