Tests/LibGfx: Add a test for bilevel images with only required tags

Bilevel images are not required to have a BitsPerSample or a
SamplesPerPixel tag, while this is unusual these images are still valid.

The test case has been generated by first making a copy of
ccitt3_1d_fill.tiff and then, using `tiffset` to remove both tags:
tiffset -u 258 ccitt3_no_tags.tiff
tiffset -u 277 ccitt3_no_tags.tiff
This commit is contained in:
Lucas CHOLLET 2024-05-07 08:20:18 -04:00 committed by Tim Flynn
parent cd1eeb3cdd
commit ed1bdf3851
Notes: sideshowbarker 2024-07-17 07:20:57 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -864,6 +864,20 @@ TEST_CASE(test_tiff_ccitt3)
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Black);
}
TEST_CASE(test_tiff_ccitt3_no_tags)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt3_no_tags.tiff"sv)));
EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 6, 4 }));
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::White);
EXPECT_EQ(frame.image->get_pixel(3, 0), Gfx::Color::NamedColor::Black);
EXPECT_EQ(frame.image->get_pixel(2, 2), Gfx::Color::NamedColor::White);
EXPECT_EQ(frame.image->get_pixel(5, 3), Gfx::Color::NamedColor::White);
}
TEST_CASE(test_tiff_ccitt3_fill)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt3_1d_fill.tiff"sv)));

Binary file not shown.