mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +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 {
|
||||
|
|
|
@ -133,6 +133,7 @@ known_tags: List[Tag] = [
|
|||
Tag('283', [TIFFType.UnsignedRational], [1], None, "YResolution"),
|
||||
Tag('284', [TIFFType.UnsignedShort], [1], PlanarConfiguration.Chunky, "PlanarConfiguration", PlanarConfiguration),
|
||||
Tag('285', [TIFFType.ASCII], [], None, "PageName"),
|
||||
Tag('292', [TIFFType.UnsignedLong], [1], 0, "T4Options"),
|
||||
Tag('296', [TIFFType.UnsignedShort], [1], ResolutionUnit.Inch, "ResolutionUnit", ResolutionUnit),
|
||||
Tag('305', [TIFFType.ASCII], [], None, "Software"),
|
||||
Tag('306', [TIFFType.ASCII], [20], None, "DateTime"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue