Hi Even,

D'accord. I am already using this technique for reading and it seams to be 
working correctly.

But I am not sure that I am doing the right thing when writing. See, if I have 
that buffer:

{{{
   ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * xsize);
   FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();

   band.WriteRaster_Direct(0, row, xsize, 1, (4 * xsize), 1, gdal.GDT_Float32, 
byteBuffer);
}}}

I got the wrong impression that the wrapper is taking "byteBuffer" to the C API as it is, byte, not as a Float32. Therefore it is wrongly converting every byte to float, one by one. Note that "band" was created as Float32. But I might be wrong.

I will keep trying.

Thanks,

Ivan

Even Rouault wrote:
Selon Ivan <[email protected]>:

The Java API only uses ByteBuffer. But you can use the asDoubleBuffer(),
asFloatBuffer(), asIntBuffer() or asShortBuffer() methods to create views of the
byte buffer as double, float, int or short buffer.

For example :

ByteBuffer byteBuffer = ByteBuffer.allocateDirect(8 * buf_xsize * buf_ysize);
band.ReadRaster_Direct(0, 0, xsize, ysize, buf_xsize, buf_ysize,
gdal.GDT_Float64, byteBuffer);
DoubleBuffer doubleBuffer = byteBuffer.asDoubleBuffer();

Hi,

Does anybody know how to write a FloatBuffer, IntBuffer or ShotBuffer using
the Java API?

Thanks,

Ivan
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev





_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to