Hi list,<br>In the context of the GDAL ImageIO integration proposal I'm actually building the framework which will add writing capabilities to the project.<br><br>Today I'm fighting against a strange error with Driver.Create
(...) method.<br><br>From a stand-alone testCase (I'm using Junit) the following code works successfully: <br>------------------------------------------------------------------------------------------------<br>final File outputFile = new File ("d:\\DatiPlugin\\samples\\writingAttempt.jp2");
<br>final BufferedImage im =
ImageIO.read(new File("D:\\DatiPlugin\\bogota.tif"));<br>Driver driver = gdal.GetDriverByName("JP2ECW");<br>final int width = im.getWidth();<br>final int height = im.getHeight();<br>Dataset ds = driver.Create
(outFile.getAbsolutePath(), width, height, 1, gdalconstConstants.GDT_Byte,null);<br><br>... some code ...<br><br>ds.GetRasterBand(1).WriteRaster_Direct(0,0,width,height,width,height, gdalconstConstants.GDT_Byte,myByteBuffer);
<br>
ds.FlushCache();<br>ds.delete();<br>------------------------------------------------------------------------------------------------<br><br>However, using the SAME code within the body of the "write" method of the MyJP2KImageWriter class (which extends ImageWriter), it does not work.
<br>(Such a method will be called during an ImageWrite operation performed using JAI-ImageIO toolkit).
<br><br>I noticed that the code only works if I chose a filename with a path containing no subdirectory... As an instance, using "D:\\sample.jp2" instead of "D:\\DatiPlugin\\samples\\sample.jp2".<br>(Out of curiosity, I tried using a BMP driver and the problem still exist)
<br><br>After a deep debug, I finally noticed that the problem could be attributable to the GDAL methods:<br><br>FILE *VSIFOpenL( const char * pszFilename, const char * pszAccess ) [from cpl_vsil.cpp]<br><br>which calls
<br><br>
VSIVirtualHandle *VSIWin32FilesystemHandler::Open( const char *pszFilename, const char *pszAccess ) [from cpl_vsil_win32.cpp]<br><br>containing the code<br><br>hFile = CreateFile( pszFilename, dwDesiredAccess, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL );
<br><br>which makes hFile equal to INVALID_HANDLE_VALUE (By this reason, the Open method returns NULL).<br><br><br>Could someone provide me some suggestions?<br><br>Thanks a lot.<br> <br>Best Regards,<br>Daniele