diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 7e8a63048f..48cd495193 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -654,6 +654,18 @@ TEST_CASE(test_tiff_ccitt3_2d_fill) EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Black); } +TEST_CASE(test_tiff_ccitt4) +{ + auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt4.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, { 400, 300 })); + + EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::White); + EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Black); +} + TEST_CASE(test_tiff_lzw) { auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/lzw.tiff"sv))); diff --git a/Tests/LibGfx/test-inputs/tiff/ccitt4.tiff b/Tests/LibGfx/test-inputs/tiff/ccitt4.tiff new file mode 100644 index 0000000000..418b5cc244 Binary files /dev/null and b/Tests/LibGfx/test-inputs/tiff/ccitt4.tiff differ diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp index dfcbfa59ba..62384797b5 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp @@ -436,6 +436,20 @@ private: TRY(loop_over_pixels(move(decode_group3_segment))); break; } + case Compression::Group4Fax: { + TRY(ensure_tags_are_correct_for_ccitt()); + + // FIXME: We need to parse T6 options + ByteBuffer decoded_bytes {}; + auto decode_group3_segment = [&](u32 num_bytes, IntSize segment_size) -> ErrorOr { + auto const encoded_bytes = TRY(read_bytes_considering_fill_order(num_bytes)); + decoded_bytes = TRY(CCITT::decode_ccitt_group4(encoded_bytes, segment_size.width(), segment_size.height())); + return decoded_bytes; + }; + + TRY(loop_over_pixels(move(decode_group3_segment))); + break; + } case Compression::LZW: { ByteBuffer decoded_bytes {}; auto decode_lzw_segment = [&](u32 num_bytes, IntSize) -> ErrorOr {