need help: AffineTransformOp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mike

    need help: AffineTransformOp

    I would greatly appreciate any help you can give.

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

    //--start code
    BufferedImage srcImage, destImage;
    AffineTransform rotation;
    AffineTransform Op 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_INTERPOLATI ON,
    RenderingHints. VALUE_INTERPOLA TION_BILINEAR );
    rotation = AffineTransform .getRotateInsta nce ( theta*Math.PI/180.0,
    xRotate, yRotate);
    rotationOp = new AffineTransform Op ( rotation, hints );

    //source and destination rasters
    srcImage = pi.getAsBuffere dImage();
    srcRaster = srcImage.getRas ter();
    destRaster = rotationOp.crea teCompatibleDes tRaster
    (srcImage.getRa ster() );

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

    This compiles, but at runtime, I get the following exception:
    java.awt.image. ImagingOpExcept ion: Unable to transform src image
    at java.awt.image. AffineTransform Op.filter(Affin eTransformOp.ja va:336)

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

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

    Thanks in advance,
    mike
Working...