mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 04:35:41 +03:00
LibGfx/CCITT: Add PDF-specific options for CCITT3 1D
These two options are additions of the PDF specification. They are valid for both 1D and 2D, but let's bail out if we encounter them in a 2D image, as we don't have a test case yet.
This commit is contained in:
parent
6fc59039c4
commit
7730b743db
Notes:
sideshowbarker
2024-07-17 06:29:49 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/7730b743db Pull-request: https://github.com/SerenityOS/serenity/pull/23628 Issue: https://github.com/SerenityOS/serenity/issues/23623 Reviewed-by: https://github.com/nico ✅
@ -596,13 +596,19 @@ ErrorOr<ByteBuffer> decode_ccitt_group3(ReadonlyBytes bytes, u32 image_width, u3
|
||||
// NOTE: For whatever reason, the last EOL doesn't seem to be included
|
||||
|
||||
for (u32 i = 0; i < image_height; ++i) {
|
||||
TRY(read_eol(*bit_stream, options.use_fill_bits));
|
||||
if (options.require_end_of_line == Group3Options::RequireEndOfLine::Yes)
|
||||
TRY(read_eol(*bit_stream, options.use_fill_bits));
|
||||
TRY(decode_single_ccitt3_1d_line(*bit_stream, *decoded_bits, image_width));
|
||||
if (options.encoded_byte_aligned == Group3Options::EncodedByteAligned::Yes)
|
||||
bit_stream->align_to_byte_boundary();
|
||||
}
|
||||
|
||||
return decoded_bytes;
|
||||
}
|
||||
|
||||
if (options.require_end_of_line == Group3Options::RequireEndOfLine::No || options.encoded_byte_aligned == Group3Options::EncodedByteAligned::Yes)
|
||||
return Error::from_string_literal("CCITTDecoder: Unsupported option for CCITT3 2D decoding");
|
||||
|
||||
TRY(decode_single_ccitt3_2d_block(*bit_stream, *decoded_bits, image_width, image_height, options.use_fill_bits));
|
||||
return decoded_bytes;
|
||||
}
|
||||
|
@ -43,9 +43,24 @@ struct Group3Options {
|
||||
Yes = 1,
|
||||
};
|
||||
|
||||
// Addition from the PDF specification
|
||||
enum class RequireEndOfLine : u8 {
|
||||
No = 0,
|
||||
Yes = 1,
|
||||
};
|
||||
|
||||
enum class EncodedByteAligned : u8 {
|
||||
No = 0,
|
||||
Yes = 1,
|
||||
};
|
||||
|
||||
Mode dimensions = Mode::OneDimension;
|
||||
Compression compression = Compression::Compressed;
|
||||
UseFillBits use_fill_bits = UseFillBits::No;
|
||||
|
||||
// Default values are set to be compatible with the CCITT specification
|
||||
RequireEndOfLine require_end_of_line = RequireEndOfLine::Yes;
|
||||
EncodedByteAligned encoded_byte_aligned = EncodedByteAligned::No;
|
||||
};
|
||||
|
||||
ErrorOr<ByteBuffer> decode_ccitt_group3(ReadonlyBytes bytes, u32 image_width, u32 image_height, Group3Options const& options);
|
||||
|
Loading…
Reference in New Issue
Block a user