Writing out BMP files with DataBuffer.TYPE_FLOAT or DataBuffer.TYPE_DOUBLE in java
I had a problem working with the image classes in java.
I am creating a buffered image with DataBuffer.TYPE_DOUBLE. This all works fine in memory (I think). But the problem starts when I try to write it using ImageIO.write.
Initially I was getting no exception at all and instead was only getting an empty output file for my troubles..
After a bit of poking around in the code, i found out that the bmp writer doesnt support writing type_double type of files.
From: BMPImageWriterSpi.canEncodeImage:
if (dataType < DataBuffer.TYPE_BYTE || dataType > DataBuffer.TYPE_INT)
return false;
So my question is, does anyone have a way of writ开发者_Python百科ing out those kind of images to disk? any documentation or tutorial, or link would be helpful.
Thanks, Basil Dsouza
Since the BMP format doesn't use any floating-point representations, at a high level it doesn't quite make sense to use floating-point data to represent an image that you will write as a BMP. Do you really need to do that? Why not ints?
The javadoc for DataBuffer.TYPE_DOUBLE
suggests it's not currently intended for use.
精彩评论