LibGfx: Fix incorrect colors in ICO-embedded BMPs

This commit is contained in:
aplefull 2025-04-23 21:40:41 +02:00 committed by Sam Atkins
commit e0ceb66580
Notes: github-actions[bot] 2025-04-24 12:47:55 +00:00
3 changed files with 22 additions and 5 deletions

View file

@ -192,6 +192,17 @@ TEST_CASE(test_bmp_embedded_in_ico)
EXPECT_EQ(frame.image->get_pixel(7, 4), Gfx::Color(161, 0, 0));
}
TEST_CASE(test_24bit_bmp_embedded_in_ico)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("ico/yt-favicon.ico"sv)));
EXPECT(Gfx::ICOImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::ICOImageDecoderPlugin::create(file->bytes()));
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 16, 16 }));
EXPECT_EQ(frame.image->get_pixel(14, 14), Gfx::Color(234, 0, 0));
EXPECT_EQ(frame.image->get_pixel(13, 15), Gfx::Color(255, 10, 15));
}
TEST_CASE(test_malformed_maskless_ico)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("ico/malformed_maskless.ico"sv)));