[gdal-dev] 24bit RGB colors raster (PNG or JPEG) to 256 colormap TIF conversion

Even Rouault even.rouault at mines-paris.org
Thu Dec 27 14:07:53 EST 2007


Le Thursday 27 December 2007 20:02:52 Christopher Barker, vous avez écrit :
> Even Rouault wrote:
> > There are 2 main interesting functions in GDAL API to convert from 24 bit
> > to colormap :
>
> While we're talking about this -- does GDAL have built-in functions for
> the reverse -- converting a color map (or pallet, or whatever you want
> to call it) into an RGB image?
>
> -Chris

No, there's not a single magic call to do that. But you can take inspiration 
from pct2rgb.py.
Basically you get the data for the whole source raster band (by lines), 
iterate on each pixel, look at the relevant entry in the color table, and 
output the r, g, b component into the destination raster data bands.


More information about the gdal-dev mailing list