Fix premultiplied image format check

Check the QPixelFormat instead of relying on an easily outdated list of
formats.

Change-Id: I076391ac22bc9d4e70e53232c529d09d7aab13b9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit fdc29cf057e7e2ec095405ff2b07bc082b0d4cdf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Allan Sandfeld Jensen 2024-09-30 16:07:15 +02:00 committed by Qt Cherry-pick Bot
parent 4b5b6451f4
commit 5fa19d4ef5

View File

@ -2221,21 +2221,11 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
// Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied.
QRgb color = img.pixel(sr_l, sr_t); QRgb color = img.pixel(sr_l, sr_t);
switch (img.format()) { if (img.pixelFormat().premultiplied() == QPixelFormat::Premultiplied) {
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB8565_Premultiplied:
case QImage::Format_ARGB6666_Premultiplied:
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
case QImage::Format_RGBA8888_Premultiplied:
case QImage::Format_A2BGR30_Premultiplied:
case QImage::Format_A2RGB30_Premultiplied:
// Combine premultiplied color with the opacity set on the painter. // Combine premultiplied color with the opacity set on the painter.
d->solid_color_filler.solidColor = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity); d->solid_color_filler.solidColor = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity);
break; } else {
default:
d->solid_color_filler.solidColor = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity)); d->solid_color_filler.solidColor = qPremultiply(combineAlpha256(QRgba64::fromArgb32(color), s->intOpacity));
break;
} }
if (d->solid_color_filler.solidColor.alphaF() <= 0.0f && s->composition_mode == QPainter::CompositionMode_SourceOver) if (d->solid_color_filler.solidColor.alphaF() <= 0.0f && s->composition_mode == QPainter::CompositionMode_SourceOver)