From ed1bdf38511caa46b5ac4b0651378706911bcf2e Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Tue, 7 May 2024 08:20:18 -0400 Subject: [PATCH] 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 --- Tests/LibGfx/TestImageDecoder.cpp | 14 ++++++++++++++ Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff | Bin 0 -> 772 bytes 2 files changed, 14 insertions(+) create mode 100644 Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 4c144d53849..14947b39bc2 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -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))); diff --git a/Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff b/Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff new file mode 100644 index 0000000000000000000000000000000000000000..e3ba390735c4edd5e8891ce93350f5145451b596 GIT binary patch literal 772 zcmebD)M5~0VqjokYB{%kp*lH2Ll6x5R$kk5?c()2AMAoRnN=7z#sz^2brS+6$h!&WMpOlIhlch zk-?6U70kZFz`$V7$O?Av8;~Oy7#JS7F^e!TFgP%T@ri=yhC^R9Ky<k6>=*)u*Mnh`=bFhFPqrv5`;LE-{@H1Rn#;`s;@!nao-iGX6?0sz`X BJFNf! literal 0 HcmV?d00001