AWARE [SYSTEMS]
AWare Systems, , Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
June 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



New Datamatrix section



Valid HTML 4.01!



2008.06.18 12:27 "changing compression scheme", by Bogdan Cristea

    I need to convert a TIFF file into a TIFF Class F file. I am aware of the 
fax2tiff utility, but I need to add more flexibility.
    I have tried to decompress the data with TIFFReadEncodedStrip and 
recompress again with TIFFWriteEncodedStrip, but the generated tiff file 
seems to have problems with some readers (xv).
   Below is the piece of code I have used. Can anyone explain what I am doing 
wrong?

	TIFFSetField(outImage, TIFFTAG_IMAGEWIDTH, 1728);
	TIFFSetField(outImage, TIFFTAG_IMAGELENGTH, 2240);

	TIFFSetField(outImage, TIFFTAG_BITSPERSAMPLE, 1);
	TIFFSetField(outImage, TIFFTAG_SAMPLESPERPIXEL, 1);

	TIFFSetField(outImage, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4);
	TIFFSetField(outImage, TIFFTAG_T6OPTIONS, 0);

	rowsPerStrip = TIFFDefaultStripSize(outImage, 0);
	TIFFSetField(outImage, TIFFTAG_ROWSPERSTRIP, rowsPerStrip);
	
	TIFFSetField(outImage, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
	TIFFSetField(outImage, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);
	TIFFSetField(outImage, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

	TIFFSetField(outImage, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);

	TIFFSetField(outImage, TIFFTAG_XRESOLUTION, 200.0);
	TIFFSetField(outImage, TIFFTAG_YRESOLUTION, 200.0);
	TIFFSetField(outImage, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER);	

		for (U32 count=0;count<TIFFNumberOfStrips(inImage);count++)
		{
			if ((stripBufferLen = TIFFReadEncodedStrip(inImage, count, 
stripBuffer, -1)) == -1)
			{
				fprintf(stderr, "TP::tiff2ClassFTiff: read error on input strip number %d.
\n", count);
				break;
			}
			if (TIFFWriteEncodedStrip(outImage, count, stripBuffer, stripBufferLen) 
== -1)
			{
				fprintf(stderr, "TP::tiff2ClassFTiff: write error on input strip 
number %d.\n", count);
				break;
			}
		}

-- 
Bogdan Cristea