mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibPDF: Read CCITT decode params
We don't do anything with them yet, so no behavior change.
This commit is contained in:
parent
454a10774e
commit
c201825cc8
3 changed files with 48 additions and 3 deletions
|
@ -22,6 +22,7 @@
|
||||||
X(BaseFont) \
|
X(BaseFont) \
|
||||||
X(BitsPerComponent) \
|
X(BitsPerComponent) \
|
||||||
X(BitsPerSample) \
|
X(BitsPerSample) \
|
||||||
|
X(BlackIs1) \
|
||||||
X(BlackPoint) \
|
X(BlackPoint) \
|
||||||
X(Bounds) \
|
X(Bounds) \
|
||||||
X(C) \
|
X(C) \
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
X(D) \
|
X(D) \
|
||||||
X(DCTDecode) \
|
X(DCTDecode) \
|
||||||
X(DW) \
|
X(DW) \
|
||||||
|
X(DamagedRowsBeforeError) \
|
||||||
X(Decode) \
|
X(Decode) \
|
||||||
X(DecodeParms) \
|
X(DecodeParms) \
|
||||||
X(DescendantFonts) \
|
X(DescendantFonts) \
|
||||||
|
@ -65,9 +67,12 @@
|
||||||
X(E) \
|
X(E) \
|
||||||
X(EarlyChange) \
|
X(EarlyChange) \
|
||||||
X(Encode) \
|
X(Encode) \
|
||||||
|
X(EncodedByteAlign) \
|
||||||
X(Encoding) \
|
X(Encoding) \
|
||||||
X(Encrypt) \
|
X(Encrypt) \
|
||||||
X(EncryptMetadata) \
|
X(EncryptMetadata) \
|
||||||
|
X(EndOfBlock) \
|
||||||
|
X(EndOfLine) \
|
||||||
X(ExtGState) \
|
X(ExtGState) \
|
||||||
X(F) \
|
X(F) \
|
||||||
X(FL) \
|
X(FL) \
|
||||||
|
@ -106,6 +111,7 @@
|
||||||
X(Intent) \
|
X(Intent) \
|
||||||
X(JBIG2Decode) \
|
X(JBIG2Decode) \
|
||||||
X(JPXDecode) \
|
X(JPXDecode) \
|
||||||
|
X(K) \
|
||||||
X(Keywords) \
|
X(Keywords) \
|
||||||
X(Kids) \
|
X(Kids) \
|
||||||
X(L) \
|
X(L) \
|
||||||
|
@ -152,6 +158,7 @@
|
||||||
X(Registry) \
|
X(Registry) \
|
||||||
X(Resources) \
|
X(Resources) \
|
||||||
X(Root) \
|
X(Root) \
|
||||||
|
X(Rows) \
|
||||||
X(Rotate) \
|
X(Rotate) \
|
||||||
X(RunLengthDecode) \
|
X(RunLengthDecode) \
|
||||||
X(S) \
|
X(S) \
|
||||||
|
|
|
@ -30,7 +30,7 @@ PDFErrorOr<ByteBuffer> Filter::decode(ReadonlyBytes bytes, DeprecatedFlyString c
|
||||||
if (encoding_type == CommonNames::RunLengthDecode)
|
if (encoding_type == CommonNames::RunLengthDecode)
|
||||||
return decode_run_length(bytes);
|
return decode_run_length(bytes);
|
||||||
if (encoding_type == CommonNames::CCITTFaxDecode)
|
if (encoding_type == CommonNames::CCITTFaxDecode)
|
||||||
return decode_ccitt(bytes);
|
return decode_ccitt(bytes, decode_parms);
|
||||||
if (encoding_type == CommonNames::JBIG2Decode)
|
if (encoding_type == CommonNames::JBIG2Decode)
|
||||||
return decode_jbig2(bytes);
|
return decode_jbig2(bytes);
|
||||||
if (encoding_type == CommonNames::DCTDecode)
|
if (encoding_type == CommonNames::DCTDecode)
|
||||||
|
@ -275,8 +275,46 @@ PDFErrorOr<ByteBuffer> Filter::decode_run_length(ReadonlyBytes bytes)
|
||||||
return TRY(Compress::PackBits::decode_all(bytes, OptionalNone {}, Compress::PackBits::CompatibilityMode::PDF));
|
return TRY(Compress::PackBits::decode_all(bytes, OptionalNone {}, Compress::PackBits::CompatibilityMode::PDF));
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFErrorOr<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes)
|
PDFErrorOr<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes, RefPtr<DictObject> decode_parms)
|
||||||
{
|
{
|
||||||
|
// Table 3.9 Optional parameters for the CCITTFaxDecode filter
|
||||||
|
int k = 0;
|
||||||
|
bool require_end_of_line = false;
|
||||||
|
bool encoded_byte_align = false;
|
||||||
|
int columns = 1728;
|
||||||
|
int rows = 0;
|
||||||
|
bool end_of_block = true;
|
||||||
|
bool black_is_1 = false;
|
||||||
|
int damaged_rows_before_error = 0;
|
||||||
|
if (decode_parms) {
|
||||||
|
if (decode_parms->contains(CommonNames::K))
|
||||||
|
k = decode_parms->get_value(CommonNames::K).get<int>();
|
||||||
|
if (decode_parms->contains(CommonNames::EndOfLine))
|
||||||
|
require_end_of_line = decode_parms->get_value(CommonNames::EndOfLine).get<bool>();
|
||||||
|
if (decode_parms->contains(CommonNames::EncodedByteAlign))
|
||||||
|
encoded_byte_align = decode_parms->get_value(CommonNames::EncodedByteAlign).get<bool>();
|
||||||
|
if (decode_parms->contains(CommonNames::Columns))
|
||||||
|
columns = decode_parms->get_value(CommonNames::Columns).get<int>();
|
||||||
|
if (decode_parms->contains(CommonNames::Rows))
|
||||||
|
rows = decode_parms->get_value(CommonNames::Rows).get<int>();
|
||||||
|
if (decode_parms->contains(CommonNames::EndOfBlock))
|
||||||
|
end_of_block = decode_parms->get_value(CommonNames::EndOfBlock).get<bool>();
|
||||||
|
if (decode_parms->contains(CommonNames::BlackIs1))
|
||||||
|
black_is_1 = decode_parms->get_value(CommonNames::BlackIs1).get<bool>();
|
||||||
|
if (decode_parms->contains(CommonNames::DamagedRowsBeforeError))
|
||||||
|
damaged_rows_before_error = decode_parms->get_value(CommonNames::DamagedRowsBeforeError).get<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Do something with these.
|
||||||
|
(void)k;
|
||||||
|
(void)require_end_of_line;
|
||||||
|
(void)encoded_byte_align;
|
||||||
|
(void)columns;
|
||||||
|
(void)rows;
|
||||||
|
(void)end_of_block;
|
||||||
|
(void)black_is_1;
|
||||||
|
(void)damaged_rows_before_error;
|
||||||
|
|
||||||
return Error::rendering_unsupported_error("CCITTFaxDecode Filter is unsupported");
|
return Error::rendering_unsupported_error("CCITTFaxDecode Filter is unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ private:
|
||||||
static PDFErrorOr<ByteBuffer> decode_lzw(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
static PDFErrorOr<ByteBuffer> decode_lzw(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||||
static PDFErrorOr<ByteBuffer> decode_flate(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
static PDFErrorOr<ByteBuffer> decode_flate(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||||
static PDFErrorOr<ByteBuffer> decode_run_length(ReadonlyBytes bytes);
|
static PDFErrorOr<ByteBuffer> decode_run_length(ReadonlyBytes bytes);
|
||||||
static PDFErrorOr<ByteBuffer> decode_ccitt(ReadonlyBytes bytes);
|
static PDFErrorOr<ByteBuffer> decode_ccitt(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||||
static PDFErrorOr<ByteBuffer> decode_jbig2(ReadonlyBytes bytes);
|
static PDFErrorOr<ByteBuffer> decode_jbig2(ReadonlyBytes bytes);
|
||||||
static PDFErrorOr<ByteBuffer> decode_dct(ReadonlyBytes bytes);
|
static PDFErrorOr<ByteBuffer> decode_dct(ReadonlyBytes bytes);
|
||||||
static PDFErrorOr<ByteBuffer> decode_jpx(ReadonlyBytes bytes);
|
static PDFErrorOr<ByteBuffer> decode_jpx(ReadonlyBytes bytes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue