Hi!
I´m working with multiband TIF files and some of them have double data type.
I need to modify some pixels from int (0-255) values to double values; problem is that my original image has int values, so it always rounds new values to int. That´s why I want to change to double type.
ParameterBlock pbConvert = new ParameterBlock();
pbConvert.addSource(myPlanarImage);
pbConvert.add(DataBuffer.TYPE_DOUBLE);
PlanarImage im = JAI.create("format", pbConvert);
WritableRaster wr = (WritableRaster) im.getData();
//make some modifications to wr so it contains double data values
//now I would like to wrap it into a new BufferedImage
ComponentColorModel colorModel =
new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB),
null,
true,
false,
ComponentColorModel.TRANSLUCENT,
DataBuffer.TYPE_DOUBLE );
BufferedImage bufImg =
new BufferedImage (colorModel,
wr,
false,
null);
Output:
Exception in thread "main" java.lang.IllegalArgumentException: Raster sun.awt.image.SunWritableRaster@1195c2b is incompatible with ColorModel ColorModel: #pixelBits = 256 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@1f217ec transparency = 3 has alpha = true isAlphaPre = false
Please, can you help me to set my raster into a new BufferedImage please?
Thank you very much!!