LibGfx/TinyVG: Fix decoding green channel of graphics RGB565 colors

The division was missed here, so this would produce overly bright greens
(or overflow).
This commit is contained in:
MacDue 2024-03-12 19:31:17 +00:00 committed by Sam Atkins
parent 633f0067c1
commit 4c15c87d0c
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00
3 changed files with 12 additions and 1 deletions

View file

@ -1204,6 +1204,17 @@ TEST_CASE(test_tvg_malformed)
}
}
TEST_CASE(test_tvg_rgb565)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tvg/green-rgb565.tvg"sv)));
EXPECT(Gfx::TinyVGImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::TinyVGImageDecoderPlugin::create(file->bytes()));
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 100, 100 }));
// Should be a solid dark green:
EXPECT_EQ(frame.image->get_pixel(50, 50), Gfx::Color(0, 130, 0));
}
TEST_CASE(test_jxl_modular_simple_tree_upsample2_10bits)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jxl/modular_simple_tree_upsample2_10bits_rct.jxl"sv)));

Binary file not shown.

View file

@ -147,7 +147,7 @@ static ErrorOr<Vector<Color>> decode_color_table(Stream& stream, ColorEncoding e
auto red = (color >> (6 + 5)) & 0x1f;
auto green = (color >> 5) & 0x3f;
auto blue = (color >> 0) & 0x1f;
return Color((red * 255 + 15) / 31, (green * 255 + 31), (blue * 255 + 15) / 31);
return Color((red * 255 + 15) / 31, (green * 255 + 31) / 63, (blue * 255 + 15) / 31);
}
case ColorEncoding::RGBAF32: {
auto red = TRY(stream.read_value<LittleEndian<f32>>());