[Gdal-dev] Read one band image to a bitmap in csharp

Tamas Szekeres szekerest at gmail.com
Fri Mar 9 09:38:10 EST 2007

2007/3/9, Hallgren Johan E <jhhal at wmdata.com>:

> I have found a sample that describe how to use GDAL to convert a tree band
> image to a (DOTNET-) bitmap, but my image only have one band. How should I
> do in that case?

I've just updated the GDALRead.cs sample with a support for reading
images with GCI_GrayIndex and GCI_PaletteIndex bands.
When reading the images with indexed color interpretation you should
retrieve the color by using
band.GetRasterColorTable().GetColorEntry(). See the referred sample
for more details.

> I tried to find the extent information and as I understood I should use the
> dataset.getMetadata but I had no such a function available. I had
> getMetadata_List and getMetadata_Dict, but no one gave me the extent
> information. What are missing?

The GDALInfo.cs sample shows how to read the metadata information.
Checkout and use the current SVN HEAD when using this feature.

> Is it possible to create a bitmap based on a smaller rectangle of the input
> dataset?

You can use  xOff,  yOff,  xSize,  ySize parameters of ReadRaster to
specify the desired offset and image size.

Best regards,


More information about the Gdal-dev mailing list