| 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 |
Thread2007.01.04 18:44 "Re: Access to bare libtiff codecs?", by Joris Van DammeJohn, John Aldridge wrote: > We've got a requirement to create (from an array of bits) a CCITT > Group 3 or 4 encoded data stream which is /not/ wrapped up in a TIFF > file, and I wondered whether libtiff (which we already use for other > reasons) could do this. > > We could, I think, do this by creating a temporary TIFF file of the > right format, calling TIFFWriteEncodedStrip to encode the data, and > then calling TIFFReadRawStrip to get the encoded data back, but is > there an easier way? > > I've failed to find anything obvious following a quick perusal of the > documentation & source code, so if this is possible I'd welcome a > pointer or two to the places to look! There is one more direct way, but it's not easy or straightforward. Instead of using tif_unix.c or tif_win32.c, you can provide your own IO functions to TIFFClientOpen. You can design an output function that doesn't write anywhere at all, but simply ignores the data it's given, until you flick a switch and it start writing to your memory block or CCITT output file or such. Next, start building a TIFF in the usual manner. When you're reading to start calling TIFFWriteEncodedStrip, flick the switch first. Do you TIFFWriteEncodedStrip calls, having the compressed data dumped exactly in its final destination this way. Next, flick the switch back to its original 'ignore' position, and round things up. It's not straightforward, and you will need some trial and error, so I'm not sure it's worth it. But on the other hand, if you compare this to writing to a full-blown temp file and reading back from it... If I remember correctly, something similar is done in the tif2pdf tool. Best regards, 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 |
|||||||