[Gdal-dev] How to set a ColorTable from scratch?

Frank Warmerdam warmerdam at pobox.com
Thu Jun 22 15:59:38 EDT 2006


Joaquim Luis wrote:
> Frank,
> Thanks (it works now) but let me abuse of your patience with one last 
> question.
> the
> hColorTable = GDALCreateColorTable( GPI_RGB );
> aways allocates a 256 color table. Is it possible to control the number 
> of color entries ?
> Or, alternatively, to remove a certain number of colors from the 256?
> The code I'm working in is a Matlab MEX file. The only thing the code 
> knows is that it received
> a ML colormap and those, by default, have only 64  colors (but they can 
> also have up to 256).

Joaquim,

GDALCreateColorTable() creates a color table with zero elements.  It is
grown as you add entries.  But some file format drivers only support
particular fixed sizes of colormap. So for instance, if you write to
8bit tiff it will always use a 256 entry color table in the file because
that is the nature of the format.

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    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list