mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
LibGfx/TIFF: Parse the T4Options CCITT field
This field is described in: Section 11: CCITT Bilevel Encodings.
This commit is contained in:
parent
edffdc35a9
commit
26494600c4
3 changed files with 42 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue