1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:07:44 +00:00

LibGfx/TIFF: Add support for grayscale images

Images with a single sample per pixel should be interpreted as
grayscale.
This commit is contained in:
Lucas CHOLLET 2023-12-01 19:28:06 -05:00 committed by Sam Atkins
parent 923d9e834f
commit da134f6867
3 changed files with 22 additions and 1 deletions

View file

@ -408,6 +408,18 @@ TEST_CASE(test_tiff_packed_bits)
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
}
TEST_CASE(test_tiff_grayscale)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("tiff/grayscale.tiff"sv)));
EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
auto frame = expect_single_frame_of_size(*plugin_decoder, { 400, 300 });
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::White);
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color(130, 130, 130));
}
TEST_CASE(test_webp_simple_lossy)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/simple-vp8.webp"sv)));

Binary file not shown.