AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2012.09.06 15:30 "[Tiff] Managing the buffer", by
2012.09.06 17:10 "Re: [Tiff] Managing the buffer", by
2012.09.07 09:21 "Re: [Tiff] Managing the buffer", by
2012.09.07 09:57 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 10:26 "RE: [Tiff] Managing the buffer", by
2012.09.07 11:01 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 13:12 "RE: [Tiff] Managing the buffer", by
2012.09.07 13:39 "Re: [Tiff] Managing the buffer", by Joris Van Damme
2012.09.07 13:45 "RE: [Tiff] Managing the buffer", by
2012.09.07 14:16 "Re: [Tiff] Managing the buffer", by Bob Friesenhahn
2012.09.07 14:31 "Re: [Tiff] Managing the buffer", by
2012.09.07 15:52 "Re: [Tiff] Managing the buffer", by Bob Friesenhahn
2012.09.07 11:25 "Re: [Tiff] Managing the buffer", by

2012.09.06 17:10 "Re: [Tiff] Managing the buffer", by

Hi Robert,

On 6 September 2012 16:30, <Robert.Atwood@diamond.ac.uk> wrote:

I would like (for complicated reasons) to write a large number of TIFF images that are the same size. I wish to have a pre-allocated buffer and not allocate a new buffer each time I want to write an image.

The simplest solution is probably something like this:

---- update the memory buffer p with the pixels you want to write
---- tif = TIFFOpen (filename, "w")
---- TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, width);
---- etc. for the rest of the header
---- for y = 0; y < height; y++:
-------- TIFFWriteScanline (tif, p + y * sizeof (line), y, 0 );
---- TIFFClose (tif)

Something like that will have no trouble at all saturating your disc write.

You could also use a higher-level library to do the writing for you, but of course that adds another dependency which you might want to avoid. For example, vips (my library) would hide some of the detail for you.

John