LibGfx: Fix AVIF alpha type to be unpremultiplied

libavif outputs straight (unpremultiplied) alpha by default, but the
AVIF loader was creating bitmaps without specifying an alpha type,
which defaults to premultiplied. This mismatch caused semi-transparent
pixels to render incorrectly.

Pass AlphaType::Unpremultiplied explicitly, matching what the PNG,
WebP, and BMP decoders already do.
This commit is contained in:
Andreas Kling 2026-03-27 18:29:15 +01:00 committed by Andreas Kling
parent ed6a5f25a0
commit 815f5e7d79

View file

@ -105,7 +105,7 @@ static ErrorOr<void> decode_avif_image(AVIFLoadingContext& context)
avifRGBImage rgb;
while (avifDecoderNextImage(context.decoder) == AVIF_RESULT_OK) {
auto bitmap_format = context.has_alpha ? BitmapFormat::BGRA8888 : BitmapFormat::BGRx8888;
auto bitmap = TRY(Bitmap::create(bitmap_format, context.size.value()));
auto bitmap = TRY(Bitmap::create(bitmap_format, AlphaType::Unpremultiplied, context.size.value()));
avifRGBImageSetDefaults(&rgb, context.decoder->image);
rgb.pixels = bitmap->scanline_u8(0);