[gdal-dev] Problem with GDALDatasetRasterIO.cs and ECW files
Francisco José Reyes Peralta
gistdt08 at hotmail.es
Wed Apr 20 03:03:00 EDT 2011
Using the following code I only can read aproximately 500 x 500 pixels.
Dim ecwDS As Dataset = Gdal.Open("C:\h10_1024_1-2.ecw", Access.GA_ReadOnly) Dim banda As Band = ecwDS.GetRasterBand(1) Dim bmp As Bitmap = New Bitmap(ecwDS.RasterXSize, ecwDS.RasterYSize, PixelFormat.Format8bppIndexed) Dim bmpData As BitmapData = bmp.LockBits(New Rectangle(0, 0, ecwDS.RasterXSize, ecwDS.RasterYSize), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed) Try Dim pal As ColorPalette = bmp.Palette For i As Integer = 0 To 255 pal.Entries(i) = Color.FromArgb(255, i, i, i) Next bmp.Palette = pal
Dim stride As Integer = bmpData.Stride Dim buf As IntPtr = bmpData.Scan0
banda.ReadRaster(0, 0, ecwDS.RasterXSize, ecwDS.RasterYSize, buf, ecwDS.RasterXSize, _ ecwDS.RasterYSize, DataType.GDT_Byte, 1, stride) Finally bmp.UnlockBits(bmpData) End Try
PictureBox1.Image = bmp
If I change the ecwDS.RasterXSize and ecwDS.RasterYSize to 500 pixels i can get the rasterband into my picturebox.
I obtain a memory exception. Not enough memory!
Date: Tue, 19 Apr 2011 16:10:27 +0200
Subject: Re: [gdal-dev] Problem with GDALDatasetRasterIO.cs and ECW files
From: szekerest at gmail.com
To: gistdt08 at hotmail.es
CC: gdal-dev at lists.osgeo.org
Not sure what is the actual value of 'pixelFormat__1' in your program.
Best regards,
Tamas
2011/4/19 Francisco José Reyes Peralta <gistdt08 at hotmail.es>
The parameter is not valid is the error that I get.I use an adaptation of the source .cs code in VB.NET.
Here is part of the code:
Dim pixelFormat As PixelFormat Dim dataType As DataType
Dim pixelSpace As Integer
If isIndexed Then
pixelFormat = PixelFormat.Format8bppIndexed
dataType = DataType.GDT_Byte
pixelSpace = 1
Else
If channelCount = 1 Then
If channelSize > 8 Then
pixelFormat = PixelFormat.Format16bppGrayScale
dataType = DataType.GDT_Int16
pixelSpace = 2
Else
pixelFormat = PixelFormat.Format24bppRgb
channelCount = 3
dataType = DataType.GDT_Byte
pixelSpace = 3
End If
Else
If hasAlpha Then
If channelSize > 8 Then
pixelFormat = PixelFormat.Format64bppArgb
dataType = DataType.GDT_UInt16
pixelSpace = 8
Else
pixelFormat = PixelFormat.Format32bppArgb
dataType = DataType.GDT_Byte
pixelSpace = 4
End If
channelCount = 4
Else
If channelSize > 8 Then
pixelFormat = PixelFormat.Format48bppRgb
dataType = DataType.GDT_UInt16
pixelSpace = 6
Else
pixelFormat = PixelFormat.Format24bppRgb
dataType = DataType.GDT_Byte
pixelSpace = 3
End If
channelCount = 3
End If
End If
End If
And the Error is in the following line:
Dim bitmap As New Bitmap(imageWidth, imageHeight, pixelFormat__1)
Is possible to read the dataset and write to a bitmap or picturebox without save as file?
Thanks for your reply.
Francisco J.
2011/4/19 Francisco José Reyes Peralta <gistdt08 at hotmail.es>
> Dear friends, I'm vieweing the *GDALDatasetRasterIO.cs* from the Csharp
> samples of GDAL and I'm getting an error in the following line *Bitmap
> bitmap = new Bitmap(imageWidth, imageHeight, pixelFormat);* In the *
> pixelFormat* argument.
>
Hi,
What is the error message specifically?
Best regards,
Tamas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110419/cc8baab2/attachment-0001.html
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110420/36dcbf36/attachment.html
More information about the gdal-dev
mailing list