Java Platform 1.2
Beta 4

Class java.awt.image.AffineTransformOp

java.lang.Object
  |
  +--java.awt.image.AffineTransformOp

public class AffineTransformOp
extends Object
implements BufferedImageOp, RasterOp
This class uses an affine transform to perform a linear mapping from 2D coordinates in the source image or Raster to 2D coordinates in the destination image or Raster. The type of interpolation used is specified via a constructor, either by a RenderingHints object or by one of the integer interpolation types defined in this class.

If a RenderingHints object is specified in the constructor, the interpolation hint and the rendering quality hint are used to set the interpolation type for this op. The color rendering hint and the dithering hint may be used when color conversion is required.

Note that the following constraints have to be met:

  • Source and Destination must be different.
  • For Rasters, the number of bands in the Source must be equal to the number of bands in the Destination.

    See Also:
    AffineTransform, BufferedImageFilter, RenderingHints.KEY_INTERPOLATION, RenderingHints.KEY_RENDERING, RenderingHints.KEY_COLOR_RENDERING, RenderingHints.KEY_DITHERING

    Field Summary
    static int TYPE_BILINEAR
              Bilinear interpolation type.
    static int TYPE_NEAREST_NEIGHBOR
              Nearest neighbor interpolation type.
     
    Constructor Summary
    AffineTransformOp(AffineTransform xform, RenderingHints hints)
              Constructs an AffineTransformOp given an affine transform.
     
    Method Summary
     BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM)
              Creates a zeroed destination image with the correct size and number of bands.
     WritableRaster createCompatibleDestRaster(Raster src)
              Creates a zeroed destination Raster with the correct size and number of bands.
     BufferedImage filter(BufferedImage src, BufferedImage dst)
              Transforms the source BufferedImage and stores the results in the destination BufferedImage.
     WritableRaster filter(Raster src, WritableRaster dst)
              Transforms the source Raster and stores the results in the destination Raster.
     Rectangle2D getBounds2D(BufferedImage src)
              Returns the bounding box of the transformed destination.
     Rectangle2D getBounds2D(Raster src)
              Returns the bounding box of the transformed destination.
     int getInterpolationType()
              Constructs an AffineTransformOp given an affine transform.
     Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
              Returns the location of the destination point given a point in the source.
     RenderingHints getRenderingHints()
              Returns the rendering hints used by this op.
     AffineTransform getTransform()
              Returns the transform used by this op.
     
    Methods inherited from class java.lang.Object
    clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
     

    Field Detail

    TYPE_NEAREST_NEIGHBOR

    public static final int TYPE_NEAREST_NEIGHBOR
    Nearest neighbor interpolation type.

    TYPE_BILINEAR

    public static final int TYPE_BILINEAR
    Bilinear interpolation type.
    Constructor Detail

    AffineTransformOp

    public AffineTransformOp(AffineTransform xform,
                             RenderingHints hints)
    Constructs an AffineTransformOp given an affine transform. The interpolation type is determined from the RenderingHints object. If the interpolation hint is defined, it will be used. Otherwise, if the rendering quality hint is defined, the interpolation type is determined from its value. If hints is null, the interpolation type is TYPE_NEAREST_NEIGHBOR.
    See Also:
    RenderingHints.KEY_INTERPOLATION, RenderingHints.KEY_RENDERING, TYPE_NEAREST_NEIGHBOR
    Method Detail

    getInterpolationType

    public final int getInterpolationType()
    Constructs an AffineTransformOp given an affine transform. The interpolation type is specified by one of the integer interpolation type constants defined by this class.
    See Also:
    TYPE_NEAREST_NEIGHBOR, public AffineTransformOp(AffineTransform xform, int interpolationType) { this.xform = (AffineTransform)xform.clone(); this.interpolationType = interpolationType; } /** Returns the interpolation type used by this op., TYPE_NEAREST_NEIGHBOR, TYPE_BILINEAR

    filter

    public final BufferedImage filter(BufferedImage src,
                                      BufferedImage dst)
    Transforms the source BufferedImage and stores the results in the destination BufferedImage. If the color models for the two images do not match, a color conversion into the destination color model will be performed. If the destination image is null, a BufferedImage will be created with the source ColorModel. An IllegalArgumentException may be thrown if the source is the same as the destination.
    Specified by:
    filter in interface BufferedImageOp
    Throws:
    ImagingOpException - if it is unable to transform the image.

    filter

    public final WritableRaster filter(Raster src,
                                       WritableRaster dst)
    Transforms the source Raster and stores the results in the destination Raster. This operation will perform the transform band by band. If the destination Raster is null, a new Raster will be created. An IllegalArgumentException may be thrown if the source is the same as the destination or if the number of bands in the source is not equal to the number of bands in the destination.
    Specified by:
    filter in interface RasterOp
    Throws:
    ImagingOpException - if it is unable to transform the image.

    getBounds2D

    public final Rectangle2D getBounds2D(BufferedImage src)
    Returns the bounding box of the transformed destination.
    Specified by:
    getBounds2D in interface BufferedImageOp

    getBounds2D

    public final Rectangle2D getBounds2D(Raster src)
    Returns the bounding box of the transformed destination.
    Specified by:
    getBounds2D in interface RasterOp

    createCompatibleDestImage

    public BufferedImage createCompatibleDestImage(BufferedImage src,
                                                   ColorModel destCM)
    Creates a zeroed destination image with the correct size and number of bands. A RasterFormatException may be thrown if the transformed width or height is equal to 0. If destCM is null, an appropriate ColorModel will be used; this ColorModel may have an alpha channel even if the src ColorModel is opaque.
    Specified by:
    createCompatibleDestImage in interface BufferedImageOp
    Parameters:
    src - Source image for the filter operation.
    destCM - ColorModel of the destination. If null, an appropriate ColorModel will be used.

    createCompatibleDestRaster

    public WritableRaster createCompatibleDestRaster(Raster src)
    Creates a zeroed destination Raster with the correct size and number of bands. A RasterFormatException may be thrown if the transformed width or height is equal to 0.
    Specified by:
    createCompatibleDestRaster in interface RasterOp

    getPoint2D

    public final Point2D getPoint2D(Point2D srcPt,
                                    Point2D dstPt)
    Returns the location of the destination point given a point in the source. If dstPt is non-null, it will be used to hold the return value.
    Specified by:
    getPoint2D in interface BufferedImageOp

    getTransform

    public final AffineTransform getTransform()
    Returns the transform used by this op.

    getRenderingHints

    public final RenderingHints getRenderingHints()
    Returns the rendering hints used by this op.
    Specified by:
    getRenderingHints in interface BufferedImageOp

    Java Platform 1.2
    Beta 4

    Submit a bug or feature
    Submit comments/suggestions about new javadoc look
    Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
    Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
    Palo Alto, California, 94303, U.S.A. All Rights Reserved.
    This documentation was generated with a post-Beta4 version of Javadoc.