|
@@ -276,6 +276,12 @@ PDFErrorOr<ByteBuffer> Filter::decode_run_length(ReadonlyBytes bytes)
|
|
|
return TRY(Compress::PackBits::decode_all(bytes, OptionalNone {}, Compress::PackBits::CompatibilityMode::PDF));
|
|
|
}
|
|
|
|
|
|
+static void invert_bits(ByteBuffer& decoded)
|
|
|
+{
|
|
|
+ for (u8& byte : decoded.bytes())
|
|
|
+ byte = ~byte;
|
|
|
+}
|
|
|
+
|
|
|
PDFErrorOr<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms)
|
|
|
{
|
|
|
// Table 3.9 Optional parameters for the CCITTFaxDecode filter
|
|
@@ -310,14 +316,21 @@ PDFErrorOr<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes bytes, RefPtr<DictObje
|
|
|
// achieve to decode images that have it. Figure out what to do with it.
|
|
|
(void)end_of_block;
|
|
|
|
|
|
- if (require_end_of_line || encoded_byte_align || black_is_1 || damaged_rows_before_error > 0 || rows == 0)
|
|
|
+ if (require_end_of_line || encoded_byte_align || damaged_rows_before_error > 0 || rows == 0)
|
|
|
return Error::rendering_unsupported_error("Unimplemented option for the CCITTFaxDecode Filter");
|
|
|
|
|
|
+ ByteBuffer decoded {};
|
|
|
if (k < 0)
|
|
|
- return TRY(Gfx::CCITT::decode_ccitt_group4(bytes, columns, rows));
|
|
|
- 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");
|
|
|
- return Error::rendering_unsupported_error("CCITTFaxDecode Filter Group 3, 2-D is unsupported");
|
|
|
+ else
|
|
|
+ return Error::rendering_unsupported_error("CCITTFaxDecode Filter Group 3, 2-D is unsupported");
|
|
|
+
|
|
|
+ if (!black_is_1)
|
|
|
+ invert_bits(decoded);
|
|
|
+
|
|
|
+ return decoded;
|
|
|
}
|
|
|
|
|
|
PDFErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
|