AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
February 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2008.02.02 18:50 "Problem with large tiff images", by Jean-michel Frecinat
2008.02.02 21:09 "Re: Problem with large tiff images", by Bob Friesenhahn
2008.02.03 11:07 "Re: Problem with large tiff images", by Joris Van Damme

2008.02.03 11:07 "Re: Problem with large tiff images", by Joris Van Damme

Jean-Michel,

Jean-Michel FRECINAT wrote:
>   I am a developer in c# and c++ and i am working on tiff images. But
> i am a problem when i try to save image (22000x9000 pixels and
> 30000x10000 pixels) i have an error "No space to output buffer".
> How to save a large tiff file with libtiff?
> I use :
>
> unsigned char* scanline_data = (unsigned
> char*)_TIFFmalloc(exportWidth*spp*sizeof(unsigned char));
>
> if(scanline_data != NULL)
> {
> for(unsigned long row= 0 ; row < height ; row++)
> {
> memcpy(scanline_data,raster+row*exportWidth*spp,exportWidth*spp);
> TIFFWriteScanline(output,scanline_data, row,0);
> }
>
> _TIFFfree(scanline_data);
> }
> TIFFFlush(output);
> TIFFClose(output);
> _TIFFfree(raster);

Since you use the Scanline interface, you're likely writing a strip TIFF or 
this wouldn't succeed at all. Bear in mind that some stages in LibTiff may 
require buffers as large as one complete strip, though that may depend on 
the compression mode selected. Though it's not clear if you do any error 
checking, what tags you set with what values, and at what point exactly the 
error occurs, this might very well be related to your problem as you might 
be writing this as a single strip image.

So make sure you set the RowsPerStrip tag to an appropriatelly small value. 
A good value might be 10 or so, as 10*30000*4, with 30000 being about the 
highest width you have in mind, and 4 being a typical average bytesize of a 
pixel depending on your colourspace setting, is 1200000, is roughly about a 
bit more then a megabyte. That's not too much so as to not get large stalls 
on buffering decoders, and in the first place it will not get you into 
unscalable trouble in buffering encoders, and it's not too little such that 
the overhead in various places that comes from the division into strips is 
still negligable. If you're using JPEG compression, you might want to select 
a value of 16 instead, as that'll likely correspond to the height of a JPEG 
MCU if you use default subsampling values and result in efficient 
compression.


Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html