| 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 |
Thread2000.11.24 13:52 "Re: Using libtiff without reading from a file", by Bjorn BroxWolfram 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
|
|||||||