From 1e023a589d35bc579df9fca86eaf8193478d97ac Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 18 Mar 2024 13:27:52 -0400 Subject: [PATCH] LibPDF: Plug in the CCITT3 1D decoder and pass corresponding options --- Userland/Libraries/LibPDF/Filter.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index 7a3a098d4db..a1fe31b2fa5 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -317,16 +317,22 @@ PDFErrorOr Filter::decode_ccitt(ReadonlyBytes bytes, RefPtr 0) + if (require_end_of_line || (encoded_byte_align && k != 0) || damaged_rows_before_error > 0) return Error::rendering_unsupported_error("Unimplemented option for the CCITTFaxDecode Filter"); ByteBuffer decoded {}; - if (k < 0) + if (k < 0) { decoded = TRY(Gfx::CCITT::decode_ccitt_group4(bytes, columns, rows)); - else if (k == 0) - return Error::rendering_unsupported_error("CCITTFaxDecode Filter Group 3, 1-D is unsupported"); - else + } else if (k == 0) { + Gfx::CCITT::Group3Options options { + .require_end_of_line = require_end_of_line ? Gfx::CCITT::Group3Options::RequireEndOfLine::Yes : Gfx::CCITT::Group3Options::RequireEndOfLine::No, + .encoded_byte_aligned = encoded_byte_align ? Gfx::CCITT::Group3Options::EncodedByteAligned::Yes : Gfx::CCITT::Group3Options::EncodedByteAligned::No, + }; + + decoded = TRY(Gfx::CCITT::decode_ccitt_group3(bytes, columns, rows, options)); + } else { return Error::rendering_unsupported_error("CCITTFaxDecode Filter Group 3, 2-D is unsupported"); + } if (!black_is_1) invert_bits(decoded);