Bläddra i källkod

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
Lucas CHOLLET 1 år sedan
förälder
incheckning
ed1bdf3851
2 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      Tests/LibGfx/TestImageDecoder.cpp
  2. BIN
      Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff

+ 14 - 0
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)));

BIN
Tests/LibGfx/test-inputs/tiff/ccitt3_no_tags.tiff