[gdal-dev] how to read the color value of particular pixel

mail2vajram mail2vajram at gmail.com
Mon Jul 12 08:07:00 EDT 2010


i want to know how to read the color value of particular pixel. and
previously i used the following code to read the color table.but now it 
throws null reference exception.why?. My objective is to prepare the Rater
legend control based on pixel values.


 Gdal.AllRegister();
            Dataset ds = Gdal.Open(@"D:\pr.IMG", Access.GA_ReadOnly);
            Band band = ds.GetRasterBand(1);
            ColorTable ct = band.GetRasterColorTable();
            ArrayList arraylist = new ArrayList();
            for (int i = 0; i < ct.GetCount(); i++)
            {
                ColorEntry ce = ct.GetColorEntry(i);
                Color cr1 = Color.FromArgb(ce.c4, ce.c1, ce.c2, ce.c3);
                arraylist.Add(cr1);
            }           
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/how-to-read-the-color-value-of-particular-pixel-tp5282620p5282620.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list