[gdal-dev] GDALRasterBand to NSImage

Even Rouault even.rouault at mines-paris.org
Wed Apr 23 13:37:15 PDT 2014


Le mercredi 23 avril 2014 22:22:45, Patrick Cannon a écrit :
> Hello Everyone,
> 
> I have been trying to get a few raster files loaded via GDAL but it seems
> that all I get back from GDALRasterIO is a bunch of 1’s which then get set
> as 255 or white.
> 
> The call I am using is:
>     GDALRasterIO(ds->GetRasterBand(1), GF_Read,
>                  0, 0, pixWide, pixHigh,
>                  fileData, pixWide, pixHigh, GDT_Byte, 0, 0);
> 
> The meta data for the chart looks valid:
> BSB_KNP=SC=458596,GD=NAD83,PR=MERCATOR,PP=28.867,PI=30.000,SP=,SK=0.0021196
> ,TA=90.0021196,UN=FATHOMS,SD=MEAN LOWER LOW WATER,DX=45.86,DY=45.86

BSB datasets come with a color palette (GDALColorTable). So GDALRasterIO() 
returns you the index in the color palette for each pixel. You have then to 
combine that with the R,G,B components of the color table.

> 
> So I would expect the data to be getting filled correctly.
> 
> OS X 10.9 with Xcode 5.1.1.
> 
> If anyone has a suggestion or could point me to a working Objective-C
> example that would be great.
> 
> Thanks,
> Patrick

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list