feat: add CCITT Group 3 (Fax3) compression and FillOrder support

Add Group3Reader for decoding CCITT Group 3 (T.4) 1D compressed TIFF
images. The fax crate's Group3Decoder has a bug where new() verifies
but doesn't consume the initial EOL marker, causing its lookup tables
to destructively consume bits from the EOL code. We work around this
by using the crate's lower-level white::decode / black::decode
functions and handling EOL markers ourselves.

Also adds FillOrder tag (266) support: FillOrder=2 (LSB-to-MSB,
common in fax images) is handled by reversing bits in each byte
before decoding. This applies to both Group 3 and Group 4 readers.

Both libtiffpic fax test images (fax2d.tif, g3test.tif) now decode
correctly with verified CRC32 hashes.
This commit is contained in:
Lilith River committed 2026-03-10 22:41:03 -06:00
1 parent 83dbb750df
commit 26301fc3f1
3 files changed
+175 -4

No files matched your search

+2 -2
View File
@@ -174,10 +174,10 @@ const FILES: &[(&str, Option<u32>)] = &[
("tests/libtiffpic/depth/README.txt", None),
("tests/libtiffpic/depth/summary.txt", None),
("tests/libtiffpic/dscf0013.tif", Some(0)), // unsupported YCbCr chroma subsampling
("tests/libtiffpic/fax2d.tif", Some(0)), // unsupported Fax3 compression
("tests/libtiffpic/fax2d.tif", Some(0xc2f30c6f)),
// No support for direct CCITT Group 3 1D format
("tests/libtiffpic/g3test.g3", None),
("tests/libtiffpic/g3test.tif", Some(0)), // unsupported Fax3 compression
("tests/libtiffpic/g3test.tif", Some(0x304b606b)),
("tests/libtiffpic/jello.tif", Some(0xb03dbda9)),
("tests/libtiffpic/jim___ah.tif", Some(0x81a27b7f)),
("tests/libtiffpic/jim___cg.tif", Some(0xfd31747c)),