mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/WebPLoader: Relax vp8x / vp8l alpha check
The check from 0805319d1e
is too strict for animated images: It's
possible that an animation has alpha, but a frame doesn't.
(For example, if the animation is 10x10 pixels, but one frame updates
just 1x1 pixels. But even a full-sized frame could just not have alpha.)
If the VP8X header claims that the animation has alpha, we could check
that at least one frame has alpha, but for now we just don't do any
checking for animated images.
This commit is contained in:
parent
c71b9fe6f8
commit
99d280a927
Notes:
sideshowbarker
2024-07-17 08:25:15 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/99d280a927 Pull-request: https://github.com/SerenityOS/serenity/pull/24468 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/LucasChollet ✅
1 changed files with 3 additions and 1 deletions
|
@ -518,7 +518,9 @@ static ErrorOr<NonnullRefPtr<Bitmap>> decode_webp_image_data(WebPLoadingContext&
|
|||
VERIFY(!image_data.alpha_chunk.has_value());
|
||||
auto vp8l_header = TRY(decode_webp_chunk_VP8L_header(image_data.image_data_chunk.data()));
|
||||
|
||||
if (context.first_chunk->id() == "VP8X" && context.vp8x_header.has_alpha != vp8l_header.is_alpha_used)
|
||||
// Check that the VP8X header alpha flag matches the VP8L header alpha flag.
|
||||
// FIXME: For animated images, if VP8X has alpha then at least one frame should have alpha. But we currently don't check this for animations.
|
||||
if (context.first_chunk->id() == "VP8X" && !context.animation_frame_chunks_data.has_value() && context.vp8x_header.has_alpha != vp8l_header.is_alpha_used)
|
||||
return Error::from_string_literal("WebPImageDecoderPlugin: VP8X header alpha flag doesn't match VP8L header");
|
||||
|
||||
return decode_webp_chunk_VP8L_contents(vp8l_header);
|
||||
|
|
Loading…
Reference in a new issue