Vajram,<br><br>You should check if the object ct, is null after band.GetRasterColorTable(). Perhaps there is no color table for D:\pr.IMG<br><br><div class="gmail_quote">On Mon, Jul 12, 2010 at 5:37 PM, mail2vajram <span dir="ltr">&lt;<a href="mailto:mail2vajram@gmail.com">mail2vajram@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
i want to know how to read the color value of particular pixel. and<br>
previously i used the following code to read the color table.but now it<br>
throws null reference exception.why?. My objective is to prepare the Rater<br>
legend control based on pixel values.<br>
<br>
<br>
 Gdal.AllRegister();<br>
            Dataset ds = Gdal.Open(@&quot;D:\pr.IMG&quot;, Access.GA_ReadOnly);<br>
            Band band = ds.GetRasterBand(1);<br>
            ColorTable ct = band.GetRasterColorTable();<br>
            ArrayList arraylist = new ArrayList();<br>
            for (int i = 0; i &lt; ct.GetCount(); i++)<br>
            {<br>
                ColorEntry ce = ct.GetColorEntry(i);<br>
                Color cr1 = Color.FromArgb(ce.c4, ce.c1, ce.c2, ce.c3);<br>
                arraylist.Add(cr1);<br>
            }<br>
<font color="#888888">--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/how-to-read-the-color-value-of-particular-pixel-tp5282620p5282620.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/how-to-read-the-color-value-of-particular-pixel-tp5282620p5282620.html</a><br>

Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9494447584<br>17.2416N 80.1426E<br>