I need to read a BufferedImage from file, which doesn’t use DataBufferInt (as normally), but DataBufferFloat.
Please note: I don’t just need some standalone DataBufferFloat, but really a BufferedImage with underlying DataBufferFloat.
The API around these things is very complex, I just can’t find how to do this.
Please help.
EDIT
Found out what is not working:
DataBufferDouble dbd = new DataBufferDouble(destWidth * destHeight * 4);
// Exception here:
// java.lang.IllegalArgumentException: Unsupported data type 5
WritableRaster wr = WritableRaster.createPackedRaster(
dbd, destWidth, destHeight, 32, new Point(0, 0));
BufferedImage bi = new BufferedImage(ColorModel.getRGBdefault(),
wr, false, (Hashtable<?, ?>) null);
createPackedRasteris not appropriate for this. It creates aRasterwith aSinglePixelPackedSampleModel, which stores r/g/b/a values in bit fields within anint, so itstransferTypecan only be an integral type.You probably want a generic raster with a
PixelInterleavedSampleModele.g.