mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 10:27:35 +00:00
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.
This commit is contained in:
parent
3c1be9879f
commit
a35f4bf14e
1 changed files with 5 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <AK/FixedArray.h>
|
#include <AK/FixedArray.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibCompress/Brotli.h>
|
#include <LibCompress/Brotli.h>
|
||||||
|
#include <LibGfx/ImageFormats/ExifOrientedBitmap.h>
|
||||||
#include <LibGfx/ImageFormats/JPEGXLLoader.h>
|
#include <LibGfx/ImageFormats/JPEGXLLoader.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -1582,7 +1583,8 @@ public:
|
||||||
auto const width = m_channels[0].width();
|
auto const width = m_channels[0].width();
|
||||||
auto const height = m_channels[0].height();
|
auto const height = m_channels[0].height();
|
||||||
|
|
||||||
auto bitmap = TRY(Bitmap::create(BitmapFormat::BGRA8888, { width, height }));
|
auto const orientation = static_cast<ExifOrientedBitmap::Orientation>(metadata.orientation);
|
||||||
|
auto oriented_bitmap = TRY(ExifOrientedBitmap::create(BitmapFormat::BGRA8888, { width, height }, orientation));
|
||||||
|
|
||||||
auto const alpha_channel = metadata.alpha_channel();
|
auto const alpha_channel = metadata.alpha_channel();
|
||||||
|
|
||||||
|
@ -1613,11 +1615,11 @@ public:
|
||||||
to_u8(m_channels[*alpha_channel].get(x, y)),
|
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<Channel>& channels()
|
Vector<Channel>& channels()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue