From dcf8f2a31dd3b03c267e103169401a1de75dd48f Mon Sep 17 00:00:00 2001 From: Pavel Shliak Date: Sat, 2 Nov 2024 20:07:13 +0400 Subject: [PATCH] LibGfx: Respect unpremultiplied alpha for JPEG XL --- Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp index 8a4c5d2db00..cd9187165e6 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp @@ -135,6 +135,7 @@ private: m_size = { info.xsize, info.ysize }; m_animated = static_cast(info.have_animation); + m_alpha_premultiplied = info.alpha_premultiplied ? Gfx::AlphaType::Premultiplied : Gfx::AlphaType::Unpremultiplied; if (m_animated) m_loop_count = info.animation.num_loops; @@ -149,7 +150,7 @@ private: if (JxlDecoderProcessInput(m_decoder) != JXL_DEC_NEED_IMAGE_OUT_BUFFER) return Error::from_string_literal("JPEGXLImageDecoderPlugin: Decoder is in an unexpected state."); - auto bitmap = TRY(Bitmap::create(Gfx::BitmapFormat::RGBA8888, m_size)); + auto bitmap = TRY(Bitmap::create(Gfx::BitmapFormat::RGBA8888, m_alpha_premultiplied, m_size)); TRY(m_frame_descriptors.try_empend(bitmap, static_cast(duration))); JxlPixelFormat format = { 4, JXL_TYPE_UINT8, JXL_NATIVE_ENDIAN, 0 }; @@ -183,6 +184,7 @@ private: Vector m_frame_descriptors; bool m_animated { false }; + Gfx::AlphaType m_alpha_premultiplied { Gfx::AlphaType::Premultiplied }; u32 m_loop_count { 0 }; u32 m_frame_count { 0 }; };