mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 02:26:10 +00:00
LibGfx: Correctly handle OS/2 BMPs with 3-byte color entries
We now properly handle OS/2 format BMPs that use 3 bytes per color entry instead of 4. While OS/2 2.x officially specified 4 bytes per color, some tools still produce files with 3-byte entries. We can identify such files by checking the available color table space.
This commit is contained in:
parent
4d8717fa3a
commit
e5944a4d9e
Notes:
github-actions[bot]
2025-05-09 19:49:19 +00:00
Author: https://github.com/aplefull
Commit: e5944a4d9e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4660
Reviewed-by: https://github.com/gmta ✅
3 changed files with 33 additions and 3 deletions
|
@ -94,6 +94,17 @@ TEST_CASE(test_bmp_v4)
|
|||
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::Red);
|
||||
}
|
||||
|
||||
TEST_CASE(test_bmp_os2_3bit)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("bmp/os2_3bpc.bmp"sv)));
|
||||
EXPECT(Gfx::BMPImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::BMPImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 300, 200 }));
|
||||
EXPECT_EQ(frame.image->get_pixel(150, 100), Gfx::Color::NamedColor::Black);
|
||||
EXPECT_EQ(frame.image->get_pixel(152, 100), Gfx::Color::NamedColor::White);
|
||||
}
|
||||
|
||||
TEST_CASE(test_ico_malformed_frame)
|
||||
{
|
||||
Array test_inputs = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue