If the source raster in linear RGB color space is transformed using the following Java code, the java.awt.image.ImagingOpException: Unable to transform src image
error is thrown when the filter is applied (the last line).
ColorModel linearRGBColorModel = new DirectColorModel(
ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), 32,
0xff0000, 0xff00, 0xff, 0xff000000, true, DataBuffer.TYPE_INT);
WritableRaster srcRaster = linearRGBColorModel.createCompatibleWritableRaster(100, 100);
WritableRaster dstRaster = linearRGBColorModel.createCompatibleWritableRaster(200, 200);
BufferedImage srcImage = new BufferedImage(linearRGBColorModel, srcRaster, false, null);
BufferedImage dstImage = new BufferedImage(linearRGBColorModel, dstRaster, false, null);
AffineTransform aff = new AffineTransform();
aff.scale(2.0, 2.0);
AffineTransformOp op = new AffineTransformOp(aff, null);
op.filter(srcImage, dstImage);
When ColorSpace.CS_sRGB
is used instead, it works properly.
In real case I manipulate image with gray blurred line. Is transformation of such source just missing JDK feature or it doesn't make sense at all?
Anyway, I plan to recalculate pixels to sRGB and make the transformation afterwards.