[gdal-dev] GDAL-Java: How to write Flot32, Int16?
ivan.lucena at pmldnet.com
Tue Nov 3 19:00:47 EST 2009
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.
Even Rouault wrote:
> Selon Ivan <ivan.lucena at pmldnet.com>:
> 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();
>> Does anybody know how to write a FloatBuffer, IntBuffer or ShotBuffer using
>> the Java API?
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
More information about the gdal-dev