[Gdal-dev] Problems reading grass raster color entry
Tim Sutton
tim at linfiniti.com
Wed Jan 7 09:58:20 EST 2004
Hi
I am having problems reading a grass raster layer using gdal. The same routine
I am having problems with (see snippet below) works fine on a geotiff image.
I have tested the same file with gdalinfo and it seems to read the palette
fine. Can anyone see an obvious reason why my code is not working?
Many thanks
Tim
QString colorInterp =
GDALGetColorInterpretationName(gdalBand->GetColorInterpretation());
//std::cout << "Colour Interpretation for this band is : " << colorInterp
<< std::endl;
if ( colorInterp == "Palette")
{
// print each point in scandata using color looked up in color table
GDALColorTable *colorTable = gdalBand->GetColorTable();
QImage myQImage=QImage(myLayerXDimInt,myLayerYDimInt,32);
myQImage.setAlphaBuffer(true);
for (int y = 0; y < myLayerYDimInt; y++)
{
for (int x =0; x < myLayerXDimInt; x++)
{
const GDALColorEntry *colorEntry = GDALGetColorEntry(colorTable,
scandata[y*myLayerXDimInt + x]);
//dont draw this point if it is no data !
if (myNoDataDouble != scandata[y*myLayerXDimInt + x])
{
int myRedValueInt=0; //color 1 int
int myGreenValueInt=0; //color 2 int
int myBlueValueInt=0; //color 3 int
//check for alternate color mappings
if (redBandNameQString=="Red") myRedValueInt=colorEntry->c1;
Last line fails on this : myRedValueInt=colorEntry->c1;
--
Get my public keys from:
http://tim.suttonfamily.co.uk/modules.php?name=Content&pa=showpage&pid=2
More information about the Gdal-dev
mailing list