AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.05.23 16:01 "[Tiff] Problems with image tiff Compression CCITT 1D in Windows NT", by Jeronimo Torres
2006.05.24 08:12 "Re: [Tiff] Problems with image tiff Compression CCITT 1D in Windows NT", by Gerben Vos
2006.07.14 04:09 "[Tiff] The problem of Convert tiff", by
2006.07.14 04:41 "Re: [Tiff] The problem of Convert tiff", by Joris
2006.07.14 05:47 "Re: [Tiff] The problem of Convert tiff", by
2006.07.14 07:36 "Re: [Tiff] The problem of Convert tiff", by Joris
2006.07.14 14:08 "RE: [Tiff] The problem of Convert tiff", by
2006.07.14 07:31 "[Tiff] About the tag stripbytecount and stripoffset.", by
2006.07.18 01:56 "Re: [Tiff] About the tag stripbytecount and stripoffset.", by Chris Cox
2006.07.18 02:53 "Re: [Tiff] About the tag stripbytecount and stripoffset.", by

2006.07.14 14:08 "RE: [Tiff] The problem of Convert tiff", by

Robert Zhang wrote:

TIFFGetField(srcImage, TIFFTAG_IMAGEWIDTH, &wv);
TIFFGetField(srcImage, TIFFTAG_IMAGELENGTH, &lv);
for (uint32 x =0;x<CurrentPage;x++) {
 int readResult =TIFFSetDirectory (srcImage, (tdir_t )x);

I realize this isn't directly related to your issue, but are you sure all your pages are the same size? It just seems a little risky to assume they are by fetching the size only once, outside the page loop.

Also:

    TIFFReadEncodedStrip(srcImage, s, buf, cc);
   if (TIFFWriteEncodedStrip(image, s, buf, cc) < 0) {
    _TIFFfree(buf);
   }

TIFFReadEncodedStrip returns the number of bytes actually read; you should probably pass that value to TIFFWriteEncodedStrip, instead of re-using 'cc'. More significantly, conditionally freeing the buffer, but staying in the loop that uses that buffer, is guaranteed to give you a crash if the condition is ever satisfied, so either replace '_TIFFfree()' with 'break' (there's another free outside, after the loop, anyway), or just get rid of the condition altogether.

I'm only pointing these things out because as you clean up your code, you'll often stumble upon the actual problem you're trying to solve (at least in my experience).