mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/JPEGXL: Accept images with high bit depth
Instead of rejecting them, we truncate each value to 8 bits. This is clearly a hack, but given the lack of support of variable bit-depth in `Bitmap` this is the only sensible change. This allows us to display "Iceberg" on https://jpegxl.info/art/.
This commit is contained in:
parent
6710622bf7
commit
65565d377b
Notes:
sideshowbarker
2024-07-17 05:58:46 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/65565d377b Pull-request: https://github.com/SerenityOS/serenity/pull/20131
1 changed files with 7 additions and 2 deletions
|
@ -1081,11 +1081,16 @@ public:
|
|||
auto bitmap = TRY(Bitmap::create(BitmapFormat::BGRx8888, { width, height }));
|
||||
|
||||
// FIXME: This assumes a raw image with RGB channels, other cases are possible
|
||||
VERIFY(bits_per_sample == 8);
|
||||
VERIFY(bits_per_sample >= 8);
|
||||
for (u32 y {}; y < height; ++y) {
|
||||
for (u32 x {}; x < width; ++x) {
|
||||
auto const to_u8 = [&, bits_per_sample](i32 sample) -> u8 {
|
||||
return clamp(sample + .5, 0, (1 << bits_per_sample) - 1);
|
||||
// FIXME: Don't truncate the result to 8 bits
|
||||
static constexpr auto maximum_supported_bit_depth = 8;
|
||||
if (bits_per_sample > maximum_supported_bit_depth)
|
||||
sample >>= (bits_per_sample - maximum_supported_bit_depth);
|
||||
|
||||
return clamp(sample + .5, 0, (1 << maximum_supported_bit_depth) - 1);
|
||||
};
|
||||
|
||||
Color const color {
|
||||
|
|
Loading…
Reference in a new issue