|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
open/write/close tiff in local buffer instead of using file?Dear TIFF forum members,
Is there any possibility to let the following simple (modified) sample from http://www.ibm.com/developerworks/linux/library/l-libtiff/ use the tiffbuffer instead of writing the output.tif to the filesystem? I'll need this, because I'm trying to write mxf files (single large file), which will contain a sequence of DNG/TIFF images... Thanks in advance Johann -------------------------------------------- #include <stdio.h> #include <tiffio.h> int main(int argc, char *argv[]){ // Define an image char buffer[25 * 144] = { /* boring hex omitted */ }; /* tiff output buffer, somewhat bigger than the original buffer */ char tiffbuffer[25*144*2]; TIFF *image; // Open the TIFF file if((image = TIFFOpen("output.tif", "w")) == NULL){ printf("Could not open output.tif for writing\n"); exit(42); } // We need to set some values for basic tags before we can add any data TIFFSetField(image, TIFFTAG_IMAGEWIDTH, 25 * 8); TIFFSetField(image, TIFFTAG_IMAGELENGTH, 144); TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 144); TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0); TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0); TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); // Write the information to the file TIFFWriteEncodedStrip(image, 0, buffer, 25 * 144); // Close the file TIFFClose(image); } -------------------------------------------- _______________________________________________ Tiff mailing list: Tiff@... http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/ |
|
|
Re: open/write/close tiff in local buffer instead of using file?On Mon, 19 Oct 2009, Horvat Johann wrote:
> Dear TIFF forum members, > > Is there any possibility to let the following simple (modified) sample > from http://www.ibm.com/developerworks/linux/library/l-libtiff/ use the > tiffbuffer instead of writing the output.tif to the filesystem? > > I'll need this, because I'm trying to write mxf files (single large > file), > which will contain a sequence of DNG/TIFF images... If you use TIFFClientOpen() then you can supply your own I/O callbacks in order to use a buffer in memory. After the TIFF has been written to a memory buffer, you can append it to your MXF file. There is also the option to use TIFFClientOpen() and have your I/O wrapper functions adjust the file offsets so that a new TIFF appends to the file. TIFF I/O does seeks and requests the file size so you would need to intercept these requests and lie appropriately. Bob -- Bob Friesenhahn bfriesen@..., http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ _______________________________________________ Tiff mailing list: Tiff@... http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/ |
|
|
Re: open/write/close tiff in local buffer instead of using file?Bob Friesenhahn wrote:
> If you use TIFFClientOpen() then you can supply your own I/O callbacks > in order to use a buffer in memory. After the TIFF has been written > to a memory buffer, you can append it to your MXF file. There is also > the option to use TIFFClientOpen() and have your I/O wrapper functions > adjust the file offsets so that a new TIFF appends to the file. TIFF > I/O does seeks and requests the file size so you would need to > intercept these requests and lie appropriately. There's a similar example that can be found under the contrib/stream directory in the libtiff source distribution. If you're using C++, then you can probably use it directly, calling TiffStream::makeFileStream() with an ostrstream of your buffer. Regards, -Edward _______________________________________________ Tiff mailing list: Tiff@... http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/ |
| Free embeddable forum powered by Nabble | Forum Help |