From ae5d1d5a2572fa895fb38b5e3e50ed3501ba86fe Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 22 May 2023 10:38:57 -0400 Subject: [PATCH] WebP: Let ALPH replace alpha channel instead of augmenting it Pixels will leave the lossy decoder with alpha set to 255. The old code would be a no-op in that case. No observable behavior change yet, since there still is no decoder for lossy webp. --- Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp index d5acb60019..2e869a8261 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp @@ -241,7 +241,7 @@ static ErrorOr decode_webp_chunk_ALPH(Chunk const& alph_chunk, Bitmap& bit if (alpha_data.size() < pixel_count) return Error::from_string_literal("WebPImageDecoderPlugin: uncompressed ALPH data too small"); for (size_t i = 0; i < pixel_count; ++i) - bitmap.begin()[i] |= alpha_data[i] << 24; + bitmap.begin()[i] = alpha_data[i] << 24 | (bitmap.begin()[i] & 0xffffff); return {}; } @@ -256,7 +256,7 @@ static ErrorOr decode_webp_chunk_ALPH(Chunk const& alph_chunk, Bitmap& bit return Error::from_string_literal("WebPImageDecoderPlugin: decompressed ALPH dimensions don't match VP8 dimensions"); for (size_t i = 0; i < pixel_count; ++i) - bitmap.begin()[i] |= (lossless_bitmap->begin()[i] & 0xff00) << 16; + bitmap.begin()[i] = (lossless_bitmap->begin()[i] & 0xff00) << 16 | (bitmap.begin()[i] & 0xffffff); return {}; }