1994.02.23 12:58 "CCITT-RLE patch-to-make-it-work", by Soren Pingel Dalsgaard
One person requested it so I though I'd post it to tiff@sgi.com instead.
The following changes will make it possible to write CCITT-RLE fax images using libtiff.
In tif_fax3.c changes have been made in functions Fax3Encode1DRow and Fax3Encode. Lines marked with a '+' in the first column have been added.
Also, in tif_ccitt.c the functions TIFFInitCCITTRLE and TIFFInitCCITTRLEW have been modified. The modification is actually a removal of the setting of Encoding-functions to point to a function producing an error message.
Sorry for not using diff, but I haven't got it right now...
---------------------------tif_fax3.c--------------------------------
In Fax3Encode1DRow():
if (bs >= bits)
break;
}
+ if ((tif->tif_options & (FAX3_BYTEALIGN | FAX3_WORDALIGN)) && sp->b.bit < 8)
+ Fax3PutBits(tif, 0, sp->b.bit);
+ if ((tif->tif_options & FAX3_WORDALIGN) && ((long)tif->tif_rawcp & 1))
+ Fax3PutBits(tif, 0, 8);
return (1);
}
In Fax3Encode():
Fax3EncodeState *sp = (Fax3EncodeState *)tif->tif_data;
while ((long)cc > 0) {
+ if ((tif->tif_options & FAX3_NOEOL) == 0)
Fax3PutEOL(tif);
if (is2DEncoding(tif)) {
if (sp->b.tag == G3_1D) {
---------------------------tif_ccitt.c--------------------------------
The functions are listed as they should be -- the difference should be obvious
int
TIFFInitCCITTRLE(TIFF* tif)
{
TIFFInitCCITTFax3(tif); /* reuse G3 compression */
/*
* This magic causes the regular G3 decompression
* code to not skip to the EOL mark at the end of
* a row, and to flush input data to a byte boundary
* at the end of each row.
*/
tif->tif_options |= FAX3_NOEOL|FAX3_BYTEALIGN;
return (1);
}
int
TIFFInitCCITTRLEW(TIFF* tif)
{
TIFFInitCCITTFax3(tif); /* reuse G3 compression */
/*
* This magic causes the regular G3 decompression
* code to not skip to the EOL mark at the end of
* a row, and to flush input data to a byte boundary
* at the end of each row.
*/
tif->tif_options |= FAX3_NOEOL|FAX3_WORDALIGN;
return (1);
}
---------------------------end-of-patch--------------------------------
--
Soren Pingel Dalsgaard
pingel@daimi.aau.dk
Department of Computer Science
Aarhus University
Ny Munkegade 116
DK-8000 Aarhus C
DENMARK