
Thread
2002.02.20 00:27 "problem writing TIFF file in one strip", by David Strip
Here's a snippet of my writer:
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, image.rows());
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, image.cols());
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, image.rows());
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
int bytes_written = TIFFWriteRawStrip(tif, 1, reinterpret_cast<void *>(image[0]), image.n() * 4);
if (bytes_written != image.n() * 4)
uiReportError("writeRGBTIFF: problem writing data");
TIFFClose(tif);
I've traced td->td_nstrips through the writing of the raw strip. It is initially computed as one (correct), but by the end it has been incremented to 2 by this piece of TIFFWriteRawStrip:
if (strip >= td->td_nstrips) {
if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
TIFFError(tif->tif_name, "Can not grow image by strips when using separate planes");
return ((tsize_t) -1);
}
/*
* Watch out for a growing image. The value of
* strips/image will initially be 1 (since it
* can't be deduced until the imagelength is known).
*/
if (strip >= td->td_stripsperimage)
td->td_stripsperimage =
TIFFhowmany(td->td_imagelength,td->td_rowsperstrip);
if (!TIFFGrowStrips(tif, 1, module))
return ((tsize_t) -1);
by the time we get to writing the directory in TIFFClose, td->td_nstrips is still 2, and that's what gets written. When I then try to read the file with TIFFOpen, I get an error on the count of strip_offsets, which the reader computes (correctly) to be 1.
I'm compiling using VC++ 6.0 on NT, but as far as I can tell, the program is behaving exactly as the code demands.
All help appreciated.
David Strip Eastman Kodak Company
david.strip@kodak.com 2901 Juan Tabo NE, Suite 210
505-294-8515 Albuquerque, NM 87112-1881
505-294-8565 (fax)