1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +00:00

LibGfx/TIFF: Parse the T4Options CCITT field

This field is described in: Section 11: CCITT Bilevel Encodings.
This commit is contained in:
Lucas CHOLLET 2024-01-14 15:03:54 -05:00 committed by Andreas Kling
parent edffdc35a9
commit 26494600c4
3 changed files with 42 additions and 0 deletions

View file

@ -23,4 +23,26 @@ namespace Gfx::CCITT {
// Section 10: Modified Huffman Compression
ErrorOr<ByteBuffer> decode_ccitt_rle(ReadonlyBytes bytes, u32 image_width, u32 image_height);
// While this is named for a CCITT context, this struct holds data like TIFF's T4Options tag
struct Group3Options {
enum class Mode : u8 {
OneDimension,
TwoDimensions,
};
enum class Compression : u8 {
Uncompressed,
Compressed,
};
enum class UseFillBits : u8 {
No = 0,
Yes = 1,
};
Mode dimensions = Mode::OneDimension;
Compression compression = Compression::Compressed;
UseFillBits use_fill_bits = UseFillBits::No;
};
}

View file

@ -18,6 +18,25 @@
namespace Gfx {
namespace {
CCITT::Group3Options parse_t4_options(u32 bit_field)
{
// Section 11: CCITT Bilevel Encodings
CCITT::Group3Options options {};
if (bit_field & 0b001)
options.dimensions = CCITT::Group3Options::Mode::TwoDimensions;
if (bit_field & 0b010)
options.compression = CCITT::Group3Options::Compression::Uncompressed;
if (bit_field & 0b100)
options.use_fill_bits = CCITT::Group3Options::UseFillBits::Yes;
return options;
}
}
namespace TIFF {
class TIFFLoadingContext {