AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1997.02.19 10:17 "Can libtiff handle data in memory instead of file?", by Miyata Yasuhiko
1997.02.19 11:45 "Re: Can libtiff handle data in memory instead of file?", by Karsten Spang
1997.02.24 03:23 "Re: Can libtiff handle data in memory instead of file?", by Miyata Yasuhiko

1997.02.19 11:45 "Re: Can libtiff handle data in memory instead of file?", by Karsten Spang

Hi Miyata

I would like to ask you how to handle data in memory instead of file.

Does anyone have a solution? Thank you for your kindness.

Take a look at TIFFClientOpen. This routine allows you to "open" a TIFF "file", in whatever way you like. You pass to the routine a set your own routines that do all the "I/O" operations: reading, writing, seeking, etc. The file name argument is used only in error messages, it is not used as a reference to a file, so you may pass some dummy value.

These routines all take a void* argument, that libtiff stores for you, and doesn't care about otherwise. You can use that to point to whatever context information you want, in your case I guess it could just be a struct containg a pointer to the data in memory and the current offset, and the size of the data.

Your routines could be a wrapper for memcpy and update offset for read, return error for write, set the offset for seek, do nothing or free for close, return the size for size, return the pointer and size for memory mapping, do nothing for unmap.

The use of the memory mapping routines could be useful, because it makes the copy unneccessary. Remember to compile libtiff with MMAP_SUPPORT defined to use this feature. You may start by just implementing the map and size routines, and make the rest do-nothing routines.

Karsten
--------------------------------------------------------------------------------
E-mail: krs@kampsax.dk                                      Karsten Spang
Phone:  +45 36 39 08 00                                     Kampsax Technology
Fax:    +45 36 77 03 01                                     P.O. Box 1142
WWW:    http://www.kampsax.dk/~krs/                         DK-2650 Hvidovre
Refer to my web page for PGP public key                     Denmark