From da0944f63d3264060bfc7ac5a75a9c49cd84beb0 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 26 Jul 2023 13:55:10 -0400 Subject: [PATCH] LibGfx/JPEGXL: Handle parsing `BlendingInfo` for extra channels Extra channels have more parameters than basic one. This patch allows us to read all these parameters. --- .../Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp index 6a20fec8d2..022040d51f 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp @@ -468,7 +468,7 @@ struct BlendingInfo { BlendMode mode {}; u8 alpha_channel {}; - u8 clamp {}; + bool clamp { false }; u8 source {}; }; @@ -481,7 +481,14 @@ static ErrorOr read_blending_info(LittleEndianInputBitStream& stre bool const extra = metadata.num_extra_channels > 0; if (extra) { - TODO(); + auto const blend_or_mul_add = blending_info.mode == BlendingInfo::BlendMode::kBlend + || blending_info.mode == BlendingInfo::BlendMode::kMulAdd; + + if (blend_or_mul_add) + blending_info.alpha_channel = U32(0, 1, 2, 3 + TRY(stream.read_bits(3))); + + if (blend_or_mul_add || blending_info.mode == BlendingInfo::BlendMode::kMul) + blending_info.clamp = TRY(stream.read_bit()); } if (blending_info.mode != BlendingInfo::BlendMode::kReplace