1994.02.18 09:21 "Re: Fax images gets inverted (sometimes)", by Karsten Spang
Blech. I was going to just say that libtiff is fine, and I would still like to think that, but TIFF 6.0 has some odd wording. First, the reason I prefer libtiff's behavior is that the fax encoding indeed deals with _white_ and _black_ pixels, not 0's or 1's.
BUT, TIFF 6.0, page 44, in italics at the bottom, says:
An encoded CCITT string is self-photometric... we adopt
the following convention:The "normal" PhotometricInterpretation for bilevel CCITT
compressed data is WhiteIsZero. In this case, the CCITT "white"
runs are to be interpretted as white, and the CCITT "black"
runs are to be interpretted as black. However, if the
PhotometricInterpretation is BlackIsZero, the TIFF reader
must reverse the meaning of white and black when displaying
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and printing the image.I find the underlined phrase terribly vague, but it seems to imply that "white" runs should be displayed as black with BlackIsZero. That is, code '1000' --> 'www' --> '000' --> 3 black pixels. Ick.
This is right. I agree, this is 'Ick', but never the less the standard. A good reason for changing libtiff's behaviour is the following: The client program does not (and should not) care about CCITT code words, it only has a series of *uncompressed* 0's and 1's AND an accompanying PhotometricInterpretation. In fact, the compression scheme should be completely transparent to the client.
As Soeren Pingel pointed out, the change is simple: remove all the handling of PhotometricInterpretation from tif_fax3.c, and always interpret 0 bits as white pixels.
Karsten
--------------------------------------------------------------------------------
E-mail: krs@kampsax.dk Karsten Spang
Phone: +45 36 77 22 23 Kampsax Data
Fax: +45 36 77 03 01 P.O. Box 1142
DK-2650 Hvidovre
Denmark