[Gdal-dev] How to set a ColorTable from scratch?
Frank Warmerdam
warmerdam at pobox.com
Thu Jun 22 14:45:03 EDT 2006
Joaquim Luis wrote:
> Hi,
> I finally learned how to use the Create() method. However, I didn't find
> out how to create a new colortable.
> There is the GDALSetRasterColorTable(GDALRasterBandH, GDALColorTableH)
> but how do we fill the
> GDALColorTableH?
Joaquim ,
The following code from gdal/alg/gdalmediancut.cpp shows adding
a bunch of entries to a color table.
for (i = 0, ptr = usedboxes; ptr != NULL; ++i, ptr = ptr->next)
{
GDALColorEntry sEntry;
sEntry.c1 = (GByte) (((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2);
sEntry.c2 = (GByte) (((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2);
sEntry.c3 = (GByte) (((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2);
GDALSetColorEntry( hColorTable, i, &sEntry );
}
Hmm, it really ought to be explicitly setting sEntry.c4 = 255 (for opaque
colors).
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