1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:47:35 +00:00

LibGfx/JPEGXL: Fix property 8

The first implementation of this property was just plain wrong. Looks
like this property isn't used a lot as I found the issue by reviewing
the code and not because of a specific image.

The test image is a 32x32 mosaic of alternating black and yellow pixels,
it was generated using this code:

Bitdepth 8
RCT 1
Width 32
Height 32

if W-WW-NW+NWW > -300
 - Set -1000
 - Set 900
This commit is contained in:
Lucas CHOLLET 2023-07-31 16:56:12 -04:00 committed by Andreas Kling
parent 6b41fef2e4
commit 00240cb0b3
3 changed files with 29 additions and 6 deletions

View file

@ -574,3 +574,23 @@ TEST_CASE(test_jxl_modular_simple_tree_upsample2_10bits)
auto frame = MUST(plugin_decoder->frame(0));
EXPECT_EQ(frame.image->get_pixel(42, 57), Gfx::Color::from_string("#4c0072"sv));
}
TEST_CASE(test_jxl_modular_property_8)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("jxl/modular_property_8.jxl"sv)));
EXPECT(Gfx::JPEGXLImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::JPEGXLImageDecoderPlugin::create(file->bytes()));
expect_single_frame_of_size(*plugin_decoder, { 32, 32 });
auto frame = MUST(plugin_decoder->frame(0));
for (u8 i = 0; i < 32; ++i) {
for (u8 j = 0; j < 32; ++j) {
auto const color = frame.image->get_pixel(i, j);
if ((i + j) % 2 == 0)
EXPECT_EQ(color, Gfx::Color::Black);
else
EXPECT_EQ(color, Gfx::Color::Yellow);
}
}
}