AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2000

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2000.11.23 20:06 "Using libtiff without reading from a file", by Wolfram Bettermann
2000.11.23 21:06 "Re: Using libtiff without reading from a file", by Joris Van Damme
2000.11.23 22:00 "Re: Using libtiff without reading from a file", by Alex Cherepanov
2000.11.23 22:16 "Re: Using libtiff without reading from a file", by Joris Van Damme
2000.11.23 23:39 "Re: Using libtiff without reading from a file", by Alex Cherepanov
2000.11.24 04:17 "Re: Using libtiff without reading from a file", by Joris Van Damme
2000.11.24 13:32 "Re: Using libtiff without reading from a file", by Wolfram Bettermann
2000.11.24 13:52 "Re: Using libtiff without reading from a file", by Bjorn Brox
2000.11.24 00:30 "Re: Using libtiff without reading from a file", by Leonard Rosenthol
2000.11.24 16:48 "Re: Using libtiff without reading from a file", by Bob Friesenhahn

2000.11.24 13:52 "Re: Using libtiff without reading from a file", by Bjorn Brox

Wolfram Bettermann wrote this:
> 
> Somehow I'm lost. Can I now use TIFFClientOpen to pass a memory blob
> to libtiff, and use TIFFRGBA to get it decoded or do I have to use
> ImageMagick (thanks, Leonhard!)
> 
> The only problem with passing a blob of memory to libtiff using TIFFOpen I 
> saw was that libtiff uses internally a "tif" handle

It is this handle that is the client part, - not an internal tiff handle.

Just define any structure you want, fill in the values needed for managing
io, opening files etc, and pass it to TIFFClientOpen() together with
pointers to your own io functions, where the first parameter, thandle_t, is
the handle you supplied to TIFFClientOpen(). In your own io-functions you
just cast the thandle_t parameter to your own struct typedef and use it.

Example reading from memory:

typedef struct {
        char *data;
        size_t data_size;
        size_t io_pos;
    } Fm_TiffInfo;

static tsize_t FM_tiffReadProc(thandle_t th, tdata_t buf, tsize_t size)
{
    Fm_TiffInfo *fmti = (Fm_TiffInfo *)th;

    if (fmti->io_pos + size > fmti->data_size)
        size = fmti->data_size - fmti->io_pos;

    (void)memcpy(buf, fmti->data + fmti->io_pos, size);
    fmti->io_pos += size;
    return size;
}

...
    Fm_TiffInfo fmti;

    fmti.data = data;
    fmti.data_size = data_size;
    fmti.io_pos = 0;

    (void)TIFFSetWarningHandler(FM_tiffWarningHandler);
    (void)TIFFSetErrorHandler(FM_tiffErrorHandler);

    tif = TIFFClientOpen("dummy", "r", (thandle_t) &fmti,
                         FM_tiffReadProc, FM_tiffWriteProc,
                         FM_tiffSeekProc, FM_tiffCloseProc,
                         FM_tiffSizeProc, FM_tiffMapProc,
                         FM_tiffUnmapProc);


- Brox, CORENA Norge AS, http://www.corena.no/, ICQ 17872043
Kirkegaardsvn. 45, P.O.Box 1024, N-3601 Kongsberg, NORWAY
Phone: +47 32287435, Fax: +47 32736877, Mobile: +47 92638590