Vajram, You should check if the object ct, is null after band.GetRasterColorTable(). Perhaps there is no color table for D:\pr.IMG
On Mon, Jul 12, 2010 at 5:37 PM, mail2vajram <mail2vaj...@gmail.com> wrote: > > 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. > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev > -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev