| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2006.07.14 14:08 "Re: The problem of Convert tiff", by Bernie PallekRobert 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).
|
|||||||