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:
parent
633f0067c1
commit
4c15c87d0c
Notes:
sideshowbarker
2024-07-17 06:51:10 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/4c15c87d0c Pull-request: https://github.com/SerenityOS/serenity/pull/23564 Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 12 additions and 1 deletions
|
@ -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)));
|
||||
|
|
BIN
Tests/LibGfx/test-inputs/tvg/green-rgb565.tvg
Normal file
BIN
Tests/LibGfx/test-inputs/tvg/green-rgb565.tvg
Normal file
Binary file not shown.
|
@ -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>>());
|
||||
|
|
Loading…
Add table
Reference in a new issue