[gdal-dev] Can't get colour table for GeoTIFF

Nik Sands nixanz at nixanz.com
Mon Jul 15 16:07:00 PDT 2013


Hi!

I'm using the code below as part of a routine to warp images.  For most images it works fine.  However, for one of my users, their images are being converted from full colour to black and white which is not supposed to happen.  I've narrowed down the issue to the code below where 'hCT' remains NULL.  An example of one such source image can be downloaded at:

	https://dl.dropboxusercontent.com/u/12436846/jrc_21.tiff

I guess I must be doing something wrong in my code, but can't figure it out.  Could somebody please help me to understand how to do this correctly?

Ie, how to I get the colour table from the image linked to above, and set that colour table for my destination image?

Cheers,
Nik.



GDALColorTableH hCT = GDALGetRasterColorTable( GDALGetRasterBand(hSrcDS,1) );

if ( hCT == NULL )
	NSLog(@"Failed to get colour table.");
else
	GDALSetRasterColorTable( GDALGetRasterBand(hDstDS,1), hCT );



More information about the gdal-dev mailing list