<div style="direction: ltr;">Hi list,<br><br>I&#39;m unsuccessfully trying to write some raster data using &nbsp;GDAL Java<br>Bindings, by mean of the writeRaster_Direct method.<br></div><div style="direction: ltr;"><span class="q">
<br>This is my code:<br>------------------------------------------------------------<br>final File outFile = new File(&quot;d:\\DatiPlugin\\geotiff\\mysample22.tif&quot;);<br>final BufferedImage im = ImageIO.read(new File(&quot;D:\\DatiPlugin\\bogota.tif&quot;));
<br><br>Driver gtiffDriver = gdal.GetDriverByName(&quot;GTiff&quot;);<br>final int width = im.getWidth();<br>final int height = im.getHeight ();<br><br>Dataset ds = gtiffDriver.Create(outFile.getAbsolutePath(), width,<br>
height, 1, gdalconstConstants.GDT_Byte,null);<br><br>RenderedOp b0 = BandSelectDescriptor.create(im, new int[] { 0 }, null);<br><br>ByteBuffer bb0 = ByteBuffer.wrap(((DataBufferByte)<br>b0.getData().getDataBuffer()).getData(0));
<br><br>ByteBuffer scanline;<br>byte &nbsp;miniBuffer[] = new byte [width];<br><br>for (int i=0; i&lt;height;i++){<br> &nbsp; &nbsp;bb0.get(miniBuffer, width*i, width);<br> &nbsp; &nbsp;scanline = ByteBuffer.wrap(miniBuffer);<br> &nbsp; &nbsp;ds.GetRasterBand
(1).WriteRaster_Direct(0,height*i,width,1,width,1,gdalconstConstants.GDT_Byte,scanline);<br>}<br><br><br></span>ds.FlushCache();<br>ds.delete();<br><span class="q">------------------------------------------------------------
<br><br><br><br></span></div><div style="direction: ltr;">This code, generates this exception:<br></div><div style="direction: ltr;"><div class="ea"><span id="e_10fc47ae6a29bc4c_3">-------------------------------------------------------
<br></span></div><span class="q" id="q_10fc47ae6a29bc4c_3">An unexpected exception has been detected in native code outside the VM.<br>Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred<br>at PC=0x7C342EEE
<br>Function=memcpy+0x33<br>Library=C:\WINDOWS\system32\MSVCR71.dll<br>Source file = F:\VS70Builds\3052\vc\crtbld\crt\src\intel\memcpy.asm : 171<br><br><br>Current Java thread:<br> &nbsp; &nbsp;at org.gdal.gdal.gdalJNI.Band_WriteRaster_Direct
 (Native Method)<br> &nbsp; &nbsp;at org.gdal.gdal.Band.WriteRaster_Direct(Band.java:127)<br> &nbsp; &nbsp;at javax.imageio.plugins.jp2k.TestJaiRead.testWrite(TestJaiRead.java:178)<br> &nbsp; &nbsp;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<br> &nbsp; &nbsp;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br> &nbsp; &nbsp;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br> &nbsp; &nbsp;at java.lang.reflect.Method.invoke
 (Method.java:324)<br> &nbsp; &nbsp;at junit.framework.TestCase.runTest(TestCase.java:154)<br> &nbsp; &nbsp;at junit.framework.TestCase.runBare(TestCase.java:127)<br> &nbsp; &nbsp;at junit.framework.TestResult$1.protect(TestResult.java:106)<br> &nbsp; &nbsp;at 
junit.framework.TestResult.runProtected (TestResult.java:124)<br> &nbsp; &nbsp;at junit.framework.TestResult.run(TestResult.java:109)<br> &nbsp; &nbsp;at junit.framework.TestCase.run(TestCase.java:118)<br> &nbsp; &nbsp;at junit.framework.TestSuite.runTest
(TestSuite.java:208)<br> &nbsp; &nbsp;at junit.framework.TestSuite.run (TestSuite.java:203)<br> &nbsp; &nbsp;at junit.textui.TestRunner.doRun(TestRunner.java:116)<br> &nbsp; &nbsp;at junit.textui.TestRunner.doRun(TestRunner.java:109)<br> &nbsp; &nbsp;at junit.textui.TestRunner.run
(TestRunner.java:72)<br> &nbsp; &nbsp;at junit.textui.TestRunner.run (TestRunner.java:57)<br> &nbsp; &nbsp;at javax.imageio.plugins.jp2k.TestJaiRead.main(TestJaiRead.java:76)<br>------------------------------------------<br><br><br></span></div>
Does anybody have any clues about what I&#39;m doing wrong?<br><br>Moreover, I have one question. Did anybody tried to write data using<br>the java bindings directly? &nbsp;I mean without using DataSet CreateCopy or the<br>like but feeding data directly into a RasterBand?
<br><br><br>Best regards,<br>Daniele<br><br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br clear="all"><br><br><br><br><br>-- <br>Best Regards,<br>Daniele