Skip to content

Commit

Permalink
Fix premultiplied image format check
Browse files Browse the repository at this point in the history
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 fdc29cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
Allan Sandfeld Jensen authored and Qt Cherry-pick Bot committed Oct 1, 2024
1 parent 4b5b645 commit 5fa19d4
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/gui/painting/qpaintengine_raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
QRgb color = img.pixel(sr_l, sr_t);
switch (img.format()) {
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:
if (img.pixelFormat().premultiplied() == QPixelFormat::Premultiplied) {
// Combine premultiplied color with the opacity set on the painter.
d->solid_color_filler.solidColor = multiplyAlpha256(QRgba64::fromArgb32(color), s->intOpacity);
break;
default:
} else {
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)
Expand Down

0 comments on commit 5fa19d4

Please sign in to comment.