AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.03.04 22:36 "[Tiff] Advice on replacing use of tiffiop.h internals with public APIs", by Jon Leech
2005.04.06 12:19 "[Tiff] PB with TIFFWriteScanline, writing after data", by samuel
2005.04.06 12:53 "Re: [Tiff] PB with TIFFWriteScanline, writing after data", by Joris

2005.04.06 12:53 "Re: [Tiff] PB with TIFFWriteScanline, writing after data", by Joris

Samual,

But then when a want to alter one row by calling TIFFWriteScanline again, raster data are written after the existing raster data and before the ending directory (the different tags). So it doesn't overwrite the row I want to!

Is it normal?

Yes, that is normal. LibTiff does not support 'overwriting' existing already written raster data in this way. It would not be feasible, given the fact that the data can be compressed. You can use more complicated schemes to 'delete' a complete page in a TIFF file, and append another in its place, but then, TIFF does not have any kind of 'memory management' inside the file, deallocation of data blocks as such for subsequent reuse is not feasible, and thus your file will get larger every time...

In the end, the proper way to go is to make sure you know what you need to write, before writing it, instead of overwriting it afterwards.

If you don't compress, there might actually be a way to nevertheless do this 'overwriting' bit. You could write the $FF stuff like you do, and next look at the strip offset values. You could then write to these offsets directly, calling the writer procedure without passing through core LibTiff... I don't even know if LibTiff offers direct access to these offsets, though, from the top of my head, as opposed to providing full access to the actual strips.

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