<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma" size="2">Using the following code I only can read aproximately 500 x 500 pixels.</font><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim ecwDS As Dataset = Gdal.Open("C:\h10_1024_1-2.ecw", Access.GA_ReadOnly)</font></div><div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim banda As Band = ecwDS.GetRasterBand(1)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim bmp As Bitmap = New Bitmap(ecwDS.RasterXSize, ecwDS.RasterYSize, PixelFormat.Format8bppIndexed)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim bmpData As BitmapData = bmp.LockBits(New Rectangle(0, 0, ecwDS.RasterXSize, ecwDS.RasterYSize), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Try</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim pal As ColorPalette = bmp.Palette</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> For i As Integer = 0 To 255</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> pal.Entries(i) = Color.FromArgb(255, i, i, i)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Next</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> bmp.Palette = pal</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim stride As Integer = bmpData.Stride</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Dim buf As IntPtr = bmpData.Scan0</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> banda.ReadRaster(0, 0, ecwDS.RasterXSize, ecwDS.RasterYSize, buf, ecwDS.RasterXSize, _</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> ecwDS.RasterYSize, DataType.GDT_Byte, 1, stride)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> Finally</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> bmp.UnlockBits(bmpData)</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> End Try</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> PictureBox1.Image = bmp</font></div></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">If I change the ecwDS.RasterXSize and ecwDS.RasterYSize to 500 pixels i can get the rasterband into my picturebox.</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div style="font-family: Tahoma; font-size: 10pt; ">I obtain a memory exception. Not enough memory!<br><br><hr id="stopSpelling">Date: Tue, 19 Apr 2011 16:10:27 +0200<br>Subject: Re: [gdal-dev] Problem with GDALDatasetRasterIO.cs and ECW files<br>From: szekerest@gmail.com<br>To: gistdt08@hotmail.es<br>CC: gdal-dev@lists.osgeo.org<br><br>Not sure what is the actual value of 'pixelFormat__1' in your program.<br><br>Best regards,<br><br>Tamas<br><br><br><div class="ecxgmail_quote">2011/4/19 Francisco José Reyes Peralta <span dir="ltr"><<a href="mailto:gistdt08@hotmail.es">gistdt08@hotmail.es</a>></span><br>
<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">
<div>
<pre style="font-family:'Times New Roman';font-size:12pt">The parameter is not valid is the error that I get.</pre><pre style="font-family:'Times New Roman';font-size:12pt">I use an adaptation of the source .cs code in <a href="http://VB.NET" target="_blank">VB.NET</a>.</pre>
<pre style="font-family:'Times New Roman';font-size:12pt">Here is part of the code:</pre><pre><span style="font-size:21px"><br></span></pre><pre><font size="4"> Dim pixelFormat As PixelFormat</font></pre><pre><font size="4"><span style="white-space:pre-wrap">        </span>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
<b><span style="font-weight:normal"><b><span style="font-family:'Times New Roman';font-weight:normal;white-space:normal;font-size:medium"><pre style="text-indent:0px !important;font-family:'Times New Roman';font-size:12pt;display:inline !important">And the Error is in the following line:</pre></span></b></span></b></font></pre><pre><font size="4">
Dim bitmap As New Bitmap(imageWidth, imageHeight, pixelFormat__1)</font></pre><pre><font size="4"><br></font></pre><pre><font size="4"><font face="'Times New Roman'">Is possible to read the dataset and write to a bitmap or picturebox without save as file?</font></font></pre>
<pre><font size="4"><font face="'Times New Roman'"><br></font></font></pre><pre><font size="4">Thanks for your reply.</font></pre><pre><font size="4"><br></font></pre><pre><font size="4">Francisco J.</font></pre><pre><font size="4"><br></font></pre><pre><font size="4"><br></font></pre><pre style="font-family:'Times New Roman';font-size:12pt">2011/4/19 Francisco José Reyes Peralta <<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">gistdt08 at hotmail.es</a>>
><i> Dear friends, I'm vieweing the *GDALDatasetRasterIO.cs* from the Csharp
</i>><i> samples of GDAL and I'm getting an error in the following line *Bitmap
</i>><i> bitmap = new Bitmap(imageWidth, imageHeight, pixelFormat);* In the *
</i>><i> pixelFormat* argument.
</i>><i>
</i>
Hi,
What is the error message specifically?
Best regards,
Tamas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <a href="http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110419/cc8baab2/attachment-0001.html" target="_blank">http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110419/cc8baab2/attachment-0001.html</a></pre>
                                           </div>
<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></blockquote></div><br><div style="visibility:hidden;left:-5000px;z-index:9999;padding:0px;margin-left:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%" id="ecxavg_ls_inline_popup">
</div></div>                                            </body>
</html>