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

Mateusz Loskot mateusz at loskot.net
Thu Dec 27 06:19:48 EST 2007


marcello ferrero wrote:
> I would like to know what GDAL "C" API function I have to use to convert 24bit RGB colors PNG/JPG images to 
> 256 colormap (8 bits) TIF files. I understood this is possible with MapServer using IMAGEMODE=PC256 (converted using the color cube), but I need to do this from my "C" program (a Win32 viewer ) that is already using the gdal lib.

Marcello,

You can find all necessary instructions in the GDAL API Tutorial at
http://www.gdal.org/gdal_tutorial.html

Also, I'd suggest to take a look at sources of the gdal_translate
program, especially at how CreateCopy is used:

http://trac.osgeo.org/gdal/browser/trunk/gdal/apps/gdal_translate.cpp#L588

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net


More information about the gdal-dev mailing list