AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2007.02.05 19:34 "[Tiff] The fake input in fax2tiff", by John Whitington
2007.02.06 05:03 "Re: [Tiff] The fake input in fax2tiff", by Joris Van Damme
2007.02.06 10:54 "Re: [Tiff] The fake input in fax2tiff", by John Whitington

2007.02.06 05:03 "Re: [Tiff] The fake input in fax2tiff", by Joris Van Damme

John,

I'm modifying the fax2tiff source to decode CCITT streams from PDF files into
raw data. Thus, I don't need to produce an output TIFF. It works, but now I'm
paring it down by removing the output code.

The fake input fax2tiff produces to make the fax input work is initialised in
the original source like this:

faxTIFF = TIFFClientOpen("(FakeInput)", "w",

/* TIFFClientOpen() fails if we don't set existing value here */ TIFFClientdata(out), TIFFGetReadProc(out), TIFFGetWriteProc(out), TIFFGetSeekProc(out), TIFFGetCloseProc(out), TIFFGetSizeProc(out), TIFFGetMapFileProc(out), TIFFGetUnmapFileProc(out));

(Where 'out' is the TIFF pointer being used for output).

How can I synthesize the values (TIFFClientdata etc.) without having to open an
actual output TIFF?

Perhaps I'm misunderstanding, but it seems to me there is a much easier approach. Work out a fake file header and fake IFD that for convinience you place right after the file header. Make the fake IFD have all appropriate settings for this kind of file, like appropriate Photometric and Compression etc. Make it specify one strip, located right after the fake IFD. This fake data, file header and IFD, make it a resource or even a constant array in your code, it shouldn't be too long. I'll call that length FakeLength from this point on.

Now make fake read and seek procs. For instance, when you receive a read for data that lies before FakeLength, return the appropriate part of your fake file header and IFD data. When you receive a read for data that lies beyond FakeLength, substract FakeLength from the offset, and provide the appropriate portion of the CCITT compressed data.

This should enable you to use a completely normal LibTiff decoding session, except that you call TIFFClientOpen and pass pointers to your modified seek and read procs.

Or am I missing something?

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