By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,738 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,738 IT Pros & Developers. It's quick & easy.

need help: AffineTransformOp

P: n/a
I would greatly appreciate any help you can give.

I have a PlanarImage that I need to rotate. When I try to use the
AffineTransformOp, I get a java.awt.image.ImagingOpException. This
was my approach: I converted the PlanarImage to a BufferedImage, and
then constructed an appropriate AffineTransformOp and used the its
filter() method.

//--start code
BufferedImage srcImage, destImage;
AffineTransform rotation;
AffineTransformOp rotationOp;
RenderingHints hints;
WritableRaster destRaster;
Raster srcRaster;
double theta;
int xRotate, yRotate;//coordinates for rotation center

//rotation operation
xRotate = N/2;
yRotate = N/2;
theta = 15.0;
hints = new RenderingHints ( RenderingHints.KEY_INTERPOLATION,
rotation = AffineTransform.getRotateInstance ( theta*Math.PI/180.0,
xRotate, yRotate);
rotationOp = new AffineTransformOp ( rotation, hints );

//source and destination rasters
srcImage = pi.getAsBufferedImage();
srcRaster = srcImage.getRaster();
destRaster = rotationOp.createCompatibleDestRaster
(srcImage.getRaster() );

//perform the rotation
rotationOp.filter(srcRaster, destRaster);
//--end code

This compiles, but at runtime, I get the following exception:
java.awt.image.ImagingOpException: Unable to transform src image
at java.awt.image.AffineTransformOp.filter(AffineTran

I am developing on Linux, and I get the same problem with both
Blackdown JDK 1.4.1 and Sun JDK

Any suggestions for how I can rotate this image by an arbitrary angle?

Thanks in advance,
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.