tags:

views:

71

answers:

1

Hi Guys,

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 writing out those kind of images to disk? any documentation or tutorial, or link would be helpful.

Thanks, Basil Dsouza

+1  A: 

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.

Sean Owen
Thanks for pointing that out. I went through so much sun source code, but didnt read the published java docs :)Though the rest of my code works with double. As in, i can set and read values through the raster when i use TYPE_DOUBLE, and i can normalize and denormalize them via other color models well. But it makes sense.What i really was trying to do was implement a steganography application. (In a somewhat misguided way). So its back to the drawing board, and perhaps i should read that paper on steganography staring at me from the shelf :)
Basil Dsouza