2006.06.02 15:22 "[Tiff] TIFFWriteRawStrip with multi-strip?", by

2006.06.02 17:20 "Re: [Tiff] TIFFWriteRawStrip with multi-strip?", by Joris Van Damme

This type of compression, G4, encodes each scanline relative to previous scanline. The first scanline is encoded relative to a 'virtual' all-white line. So if you divide the block, the first part will make sense, the second will be corrupted. There's no way you can work around that.

Perhaps I was expressing myself too strongly.

You could scan through the image, decompressing it, holding on to the reference previous scanline and the newly decompressed scanline. Before decompression of the first scanline of the newly divided strip, you can flush previous data to previous strip as you now have its length.

Next, you could decompress first scanline of the new strip, using appropriate reference line. You could then recompress that first scanline, using an all-white reference line. Now the new strip has a suitable start. You could then scan on, and repeat the process.

So this saves nothing in the decompression departement. It does save you a huge decompressed buffer, replacing that need with a buffer to hold only two scanlines. And it does save in the recompression departement, replacing that need with recompression of only the first scanline of each newly divided strip (and some memory copy, likely, as the newly recompressed scanline is likely larger then its previous version). G4 being a lossless compression mode, this does not improve the results which are fine either way.

This comes at the cost of a lot of coding effort, and good knowledge of the G4 compression scheme. I'd guess it's not worth it, G4 (de)compression being fast as it is, unless you've got some special application like an absolute need to divide the G4 compressed blocks on very low memory devices or something... Do you?

Joris Van Damme
Download your free TIFF tag viewer for windows here: