Skip to main content

BufferedImage Created by ImageIO not compatible with AffineTransformOp

1 reply [Last post]
Joined: 2006-03-28

I am having some difficulties with BufferedImages created by the ImageIO class, they are causing the following excpetion to be thrown in the AffineTransformOp class;

Exception in thread "AWT-EventQueue-0" java.awt.image.ImagingOpException: Unable to transform src image
at java.awt.image.AffineTransformOp.filter(
at sun.java2d.pipe.DrawImage.renderImageXform(
at sun.java2d.pipe.DrawImage.transformImage(
at sun.java2d.pipe.DrawImage.transformImage(
at sun.java2d.pipe.DrawImage.transformImage(
at sun.java2d.pipe.ValidatePipe.transformImage(
at sun.java2d.SunGraphics2D.drawImage(
at sun.awt.datatransfer.DataTransferer.translateTransferable(
at sun.awt.datatransfer.SunClipboard.setContents(

This exception can be triggered by doing several different things with the BufferedImage, the exception listed above was triggered by sending the BufferedImage to the Clipboard, the exception can also be triggered by attempting to print the image.

The images are created using the following method;

Iterator iter = ImageIO.getImageReadersBySuffix("jpg");
if (iter.hasNext()) {
// Get the JPG reader
ImageReader reader = (ImageReader);
// Create the destination image, it must be TYPE_BYTE_GRAY
// to be suitable for the RipByteProcessor
BufferedImage image = new BufferedImage(640, 480, BufferedImage.TYPE_BYTE_GRAY);
// Use the ImageReadParam object to tell the reader what
// image type we want
ImageReadParam param = reader.getDefaultReadParam();
// Create an ImageInputStream object from the raw image
// byte[] and assign this input object to the reader
ImageInputStream stream = ImageIO.createImageInputStream(new ByteArrayInputStream(pRawJPGImageBytes));
reader.setInput(stream, true, true);
// Read, we expect 1 image, then do some house cleaning
image =, param);
catch (IOException e) {

If I create a ToolkitImage using the DefaultToolkit from the same raw JPG image bytes I do not get the exception thrown in the AffineTransformOp.

The API documantation is not very helpful, it states;

ImagingOpException is thrown if the image cannot be transformed because of a data-processing error that might be caused by an invalid image format, tile at, or image-processing operation, or any other unsupported operation.


I am using java version 1.5.0_22-b03 on Windows XP.

Any insight on how to create BufferedImages using the ImageIO package that are compatible with the AffineTransformOp would be much appreciated?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-03-28

Sorry, please disregard this question.

The cause of the incompatability of the BufferedImage and the AffineTransformOp is not the decoding of the source file by the ImageIO package but some processing done on the image by the ImageJ image processing package.

I will redirect my query to the ImageJ forum. I aplogise for wasting anybodies time.