AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2006

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



Valid HTML 4.01!



Thread

2006.07.14 04:09 "The problem of Convert tiff", by Robert Zhang
2006.07.14 04:41 "Re: The problem of Convert tiff", by Joris Van Damme
2006.07.14 05:47 "Re: The problem of Convert tiff", by Robert Zhang
2006.07.14 07:36 "Re: The problem of Convert tiff", by Joris Van Damme
2006.07.14 14:08 "Re: The problem of Convert tiff", by Bernie Pallek

2006.07.14 14:08 "Re: The problem of Convert tiff", by Bernie Pallek

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).