2006.05.23 16:01 "[Tiff] Problems with image tiff Compression CCITT 1D in Windows NT", by Jeronimo Torres

2006.07.14 07:36 "Re: [Tiff] The problem of Convert tiff", by Joris Van Damme

<hotmail>xiaotiger666 wrote:

    I convert Tiff  with LibTiff. I develop tiff for the Dialogic.  The Dialogic require the tiff of TIFF/F class. So i must convert the  all format of tiff  to   TIFF/F class.

I've never thought highly of the artificial classification of TIFF, but, as far as that classification makes any sense, I think your source image already is TIFF/F.

strTime.Format("%d-%2d-%2d

This is where the bogus format for the DateTime tag comes from. Look up the correct format in the TIFF spec. It's not crucial, but you may as well get it right.

TIFFGetField(srcImage,TIFFTAG_ROWSPERSTRIP,&rowperstrip);

You read the RowsPerStrip value from the source image, you next set that same value on the destination image...

TIFFSetField(image, TIFFTAG_ROWSPERSTRIP,rowperstrip);

...and next transcode all individual strips...

uint32 rowsperstrip;

(void) TIFFGetFieldDefaulted(srcImage, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); tstrip_t s, ns = TIFFNumberOfStrips(srcImage);

  uint32 row = 0;
  for (s = 0; s < ns; s++) {
   tsize_t cc = (row + rowsperstrip > lv)?
    TIFFVStripSize(srcImage, lv - row): stripsize;
   TIFFReadEncodedStrip(srcImage, s, buf, cc);
   if (TIFFWriteEncodedStrip(image, s, buf, cc) < 0) {
    _TIFFfree(buf);
   }
   row += rowsperstrip;
  }
  TIFFWriteDirectory(image);
  _TIFFfree(buf);

That seems OK, at first sight. Maybe someone else spots an error. If not, try moving the line where you set the TIFFTAG_ROWSPERSTRIP value of the destination image someplace else, like right before or right after the line where you set PLANARCONFIG, sometimes that makes a difference. Try doing the same with the setting of IMAGELENGTH.

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html