From a35f4bf14eb3dfa9d077a38a8c8040ce4ceb1983 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 31 Jul 2023 23:20:31 -0400 Subject: [PATCH] LibGfx/JPEGXL: Honor the orientation parameter Since the introduction of the JPEG XL decoder, we always read the `orientation` field in the `ImageMetadata` bundle. This patch allows us to render the bitmap accordingly to this transformation. --- Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp index 17a09c0601..6d5238f159 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace Gfx { @@ -1582,7 +1583,8 @@ public: auto const width = m_channels[0].width(); auto const height = m_channels[0].height(); - auto bitmap = TRY(Bitmap::create(BitmapFormat::BGRA8888, { width, height })); + auto const orientation = static_cast(metadata.orientation); + auto oriented_bitmap = TRY(ExifOrientedBitmap::create(BitmapFormat::BGRA8888, { width, height }, orientation)); auto const alpha_channel = metadata.alpha_channel(); @@ -1613,11 +1615,11 @@ public: to_u8(m_channels[*alpha_channel].get(x, y)), }; }(); - bitmap->set_pixel(x, y, color); + oriented_bitmap.set_pixel(x, y, color); } } - return bitmap; + return oriented_bitmap.bitmap(); } Vector& channels()