TIFF and LibTiff Mail List Archive


2002.02.03 05:00 "tiff (libtiff)", by Harring Figueiredo
2002.02.03 21:42 "Re: tiff (libtiff)", by Peter Montgomery
2002.02.05 12:33 "Re: tiff (libtiff)", by Jon Saxton
2002.02.05 14:20 "Re: tiff (libtiff)", by Bjorn Brox
2002.02.05 14:34 "RE: tiff (libtiff)", by Mark A. James
2002.02.05 14:55 "Re: tiff (libtiff)", by Harring Figueiredo

2002.02.05 14:20 "Re: tiff (libtiff)", by Bjorn Brox

I'm not sure of the best way to directly handle an image in memory, but perhaps letting the list know what platform you're working on may be of benefit to finding a solution.

Oh boy, I shall follow this discussion with interest.

There is absolutely no problems in using libtiff to read images stored in memory.

Just use the TIFFClientOpen() function to open the image.

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

Where for example the fmti structure is:

typedef struct {
         const char *gfx_name;
         char *data;
         size_t data_size;
         size_t io_pos;
     } Fm_DiMemIo;

and for example FM_tiffReadProc() is like this:

static tsize_t FM_tiffReadProc(thandle_t th, tdata_t buf, tsize_t size)
     Fm_DiMemIo *fmti = (Fm_DiMemIo *)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;

Bjorn Brox, CORENA Norge AS,, ICQ 17872043
Kirkegaardsvn. 45, P.O.Box 1024, N-3601 Kongsberg, NORWAY
Phone: +47 32287435, Fax: +47 32287430, Mobile: +47 92638590