[Gdal-dev] 16 color TIFFs; buffering

Frank Warmerdam fwarmerdam at gmail.com
Fri Sep 9 09:06:35 EDT 2005


On 9/9/05, Matej Dular <matej.dular at realis.si> wrote:
>  
> Hello! I'm using GDAL for some months now so more or less I am still a
> newbi. I have two technical questions and hope you don't mind sending them
> in one single mail. 
>   
> 1. TIFFs: If a TIFF image is saved with an indexed palette of 256 colors,
> GDAL handels it as such (1 band, 256 color palette). But if a TIFF image is
> saved with an idexed palette of only 16 colors, GDAL handels it as 4 band
> RGB (unindexed!) color image. This seems strange to me, isn't it? 

Matej, 

I think you will find that GDAL 1.3.0 no longer internally converts 16 color
images (4 bit) to RGBA format.  If you are using something older, you 
should upgrade to get this improvement.  In fact, in 1.3.0 GDAL supports
essentially all bit pixels (1, 2, 3, 4, ..13, 14, 15, 16).  Of course the
odd sized bands are still represented as the next higher supported type. 
   
> 2. Buffering. GDAL bufferizes image data while reading it by RasterIO so
> next reading of same image blocks is quite faster than the first one. I'm
> asking myself is there any way (and any sense) to disable buffering to
> improve GDAL performance when no repeated reading of the same image is
> planed? I only have to read an image grid at once and that's it. Buffering
> seems like an activity that is not really needed in such a case, and could
> theoretically slow down the task. 

In theory you can use the ReadBlock() method on the band in C++ to
skip past all the GDAL level buffering.  However, for some drivers this
may result in other problems.  My suggestion for optimum performance
is to use RasterIO() but to read on block boundaries, and to configure
the cache size to be modest (5MB would likely be plenty) to avoid
tieing up extra memory in the GDAL level cache. 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list