LibGfx: Clamp BMP color palette to 1024

Other browsers don't think that BMP files with more than 1024 colors are
invalid. They clamp the palette instead, and now we do the same. This
allows us to load more BMPs.
This commit is contained in:
aplefull 2025-05-06 01:16:51 +02:00 committed by Jelle Raaijmakers
commit c908c14aac
Notes: github-actions[bot] 2025-05-09 19:49:41 +00:00
3 changed files with 13 additions and 8 deletions

View file

@ -75,6 +75,15 @@ TEST_CASE(test_bmp_1bpp)
EXPECT_EQ(frame.image->begin()[0], 0xff'ff'ff'ff);
}
TEST_CASE(test_bmp_too_many_palette_colors)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("bmp/too-many-palette-colors.bmp"sv)));
EXPECT(Gfx::BMPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::BMPImageDecoderPlugin::create(file->bytes()));
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 2, 2 }));
}
TEST_CASE(test_ico_malformed_frame)
{
Array test_inputs = {