Top Description Fields Constructors Methods
java.awt.image

public Class AffineTransformOp

extends Object
implements BufferedImageOp, RasterOp
Class Inheritance
All Implemented Interfaces
java.awt.image.RasterOp, java.awt.image.BufferedImageOp
Imports
java.awt.geom.AffineTransform, .NoninvertibleTransformException, .Rectangle2D, .Point2D, java.awt.AlphaComposite, .GraphicsEnvironment, .Rectangle, .RenderingHints, .Transparency, java.lang.annotation.Native, sun.awt.image.ImagingLib

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 that is used is specified through 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 operation. The color rendering hint and the dithering hint can be used when color conversion is required.

Note that the following constraints have to be met:

See Also
AffineTransform, BufferedImageFilter, java.awt.RenderingHints#KEY_INTERPOLATION, java.awt.RenderingHints#KEY_RENDERING, java.awt.RenderingHints#KEY_COLOR_RENDERING, java.awt.RenderingHints#KEY_DITHERING

Field Summary

Modifier and TypeField and Description
pack-priv RenderingHints
pack-priv int
public static final int
TYPE_BICUBIC

Bicubic interpolation type.

public static final int
TYPE_BILINEAR

Bilinear interpolation type.

public static final int
TYPE_NEAREST_NEIGHBOR

Nearest-neighbor interpolation type.

private AffineTransform

Constructor Summary

AccessConstructor and Description
public
AffineTransformOp(AffineTransform
The AffineTransform to use for the operation.
xform
,
RenderingHints
The RenderingHints object used to specify the interpolation type for the operation.
hints
)

Constructs an AffineTransformOp given an affine transform.

public
AffineTransformOp(AffineTransform
The AffineTransform to use for the operation.
xform
,
int
One of the integer interpolation type constants defined by this class: TYPE_NEAREST_NEIGHBOR, TYPE_BILINEAR, TYPE_BICUBIC.
interpolationType
)

Constructs an AffineTransformOp given an affine transform and the interpolation type.

Method Summary

Modifier and TypeMethod and Description
public BufferedImage

Returns:

The zeroed destination image.
createCompatibleDestImage
(BufferedImage
The BufferedImage to be transformed.
src
,
ColorModel
ColorModel of the destination. If null, an appropriate ColorModel is used.
destCM
)

Implements java.awt.image.BufferedImageOp.createCompatibleDestImage.

Creates a zeroed destination image with the correct size and number of bands.
public WritableRaster

Returns:

The zeroed destination Raster.
createCompatibleDestRaster
(Raster
The Raster to be transformed.
src
)

Implements java.awt.image.RasterOp.createCompatibleDestRaster.

Creates a zeroed destination Raster with the correct size and number of bands.
public final BufferedImage

Returns:

The filtered BufferedImage.
filter
(BufferedImage
The BufferedImage to transform.
src
,
BufferedImage
The BufferedImage in which to store the results of the transformation.
dst
)

Implements java.awt.image.BufferedImageOp.filter.

Transforms the source BufferedImage and stores the results in the destination BufferedImage.
public final WritableRaster

Returns:

The transformed Raster.
filter
(Raster
The Raster to transform.
src
,
WritableRaster
The Raster in which to store the results of the transformation.
dst
)

Implements java.awt.image.RasterOp.filter.

Transforms the source Raster and stores the results in the destination Raster.
public final Rectangle2D

Returns:

The Rectangle2D representing the destination's bounding box.
getBounds2D
(BufferedImage
The BufferedImage to be transformed.
src
)

Implements java.awt.image.BufferedImageOp.getBounds2D.

Returns the bounding box of the transformed destination.
public final Rectangle2D

Returns:

The Rectangle2D representing the destination's bounding box.
getBounds2D
(Raster
The Raster to be transformed.
src
)

Implements java.awt.image.RasterOp.getBounds2D.

Returns the bounding box of the transformed destination.
public final int

Returns:

the interpolation type.
getInterpolationType
()

Returns the interpolation type used by this op.

public final Point2D

Returns:

The Point2D in the destination that corresponds to the specified point in the source.
getPoint2D
(Point2D
The Point2D that represents the source point.
srcPt
,
Point2D
The Point2D in which to store the result.
dstPt
)

Implements java.awt.image.BufferedImageOp.getPoint2D, java.awt.image.RasterOp.getPoint2D.

Returns the location of the corresponding destination point given a point in the source.
public final RenderingHints

Returns:

The RenderingHints object associated with this op.
getRenderingHints
()

Implements java.awt.image.BufferedImageOp.getRenderingHints, java.awt.image.RasterOp.getRenderingHints.

Returns the rendering hints used by this transform operation.
public final AffineTransform

Returns:

The AffineTransform associated with this op.
getTransform
()

Returns the affine transform used by this transform operation.

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hintsback to summary
pack-priv RenderingHints hints
interpolationTypeback to summary
pack-priv int interpolationType
TYPE_BICUBICback to summary
public static final int TYPE_BICUBIC

Bicubic interpolation type.

Annotations
@Native
TYPE_BILINEARback to summary
public static final int TYPE_BILINEAR

Bilinear interpolation type.

Annotations
@Native
TYPE_NEAREST_NEIGHBORback to summary
public static final int TYPE_NEAREST_NEIGHBOR

Nearest-neighbor interpolation type.

Annotations
@Native
xformback to summary
private AffineTransform xform

Constructor Detail

AffineTransformOpback to summary
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 no hints are specified (hints is null), the interpolation type is TYPE_NEAREST_NEIGHBOR.

Parameters
xform:AffineTransform

The AffineTransform to use for the operation.

hints:RenderingHints

The RenderingHints object used to specify the interpolation type for the operation.

Exceptions
ImagingOpException:
if the transform is non-invertible.
See Also
java.awt.RenderingHints#KEY_INTERPOLATION, java.awt.RenderingHints#KEY_RENDERING
AffineTransformOpback to summary
public AffineTransformOp(AffineTransform xform, int interpolationType)

Constructs an AffineTransformOp given an affine transform and the interpolation type.

Parameters
xform:AffineTransform

The AffineTransform to use for the operation.

interpolationType:int

One of the integer interpolation type constants defined by this class: TYPE_NEAREST_NEIGHBOR, TYPE_BILINEAR, TYPE_BICUBIC.

Exceptions
ImagingOpException:
if the transform is non-invertible.

Method Detail

createCompatibleDestImageback to summary
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM)

Implements java.awt.image.BufferedImageOp.createCompatibleDestImage.

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 is used; this ColorModel may have an alpha channel even if the source ColorModel is opaque.

Parameters
src:BufferedImage

The BufferedImage to be transformed.

destCM:ColorModel

ColorModel of the destination. If null, an appropriate ColorModel is used.

Returns:BufferedImage

The zeroed destination image.

createCompatibleDestRasterback to summary
public WritableRaster createCompatibleDestRaster(Raster src)

Implements java.awt.image.RasterOp.createCompatibleDestRaster.

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.

Parameters
src:Raster

The Raster to be transformed.

Returns:WritableRaster

The zeroed destination Raster.

filterback to summary
public final BufferedImage filter(BufferedImage src, BufferedImage dst)

Implements java.awt.image.BufferedImageOp.filter.

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 is performed. If the destination image is null, a BufferedImage is created with the source ColorModel.

The coordinates of the rectangle returned by getBounds2D(BufferedImage) are not necessarily the same as the coordinates of the BufferedImage returned by this method. If the upper-left corner coordinates of the rectangle are negative then this part of the rectangle is not drawn. If the upper-left corner coordinates of the rectangle are positive then the filtered image is drawn at that position in the destination BufferedImage.

An IllegalArgumentException is thrown if the source is the same as the destination.

Parameters
src:BufferedImage

The BufferedImage to transform.

dst:BufferedImage

The BufferedImage in which to store the results of the transformation.

Returns:BufferedImage

The filtered BufferedImage.

Exceptions
IllegalArgumentException:
if src and dst are the same
ImagingOpException:
if the image cannot be transformed because of a data-processing error that might be caused by an invalid image format, tile format, or image-processing operation, or any other unsupported operation.
filterback to summary
public final WritableRaster filter(Raster src, WritableRaster dst)

Implements java.awt.image.RasterOp.filter.

Transforms the source Raster and stores the results in the destination Raster. This operation performs the transform band by band.

If the destination Raster is null, a new Raster is 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.

The coordinates of the rectangle returned by getBounds2D(Raster) are not necessarily the same as the coordinates of the WritableRaster returned by this method. If the upper-left corner coordinates of rectangle are negative then this part of the rectangle is not drawn. If the coordinates of the rectangle are positive then the filtered image is drawn at that position in the destination Raster.

Parameters
src:Raster

The Raster to transform.

dst:WritableRaster

The Raster in which to store the results of the transformation.

Returns:WritableRaster

The transformed Raster.

Exceptions
ImagingOpException:
if the raster cannot be transformed because of a data-processing error that might be caused by an invalid image format, tile format, or image-processing operation, or any other unsupported operation.
getBounds2Dback to summary
public final Rectangle2D getBounds2D(BufferedImage src)

Implements java.awt.image.BufferedImageOp.getBounds2D.

Returns the bounding box of the transformed destination. The rectangle returned is the actual bounding box of the transformed points. The coordinates of the upper-left corner of the returned rectangle might not be (0, 0).

Parameters
src:BufferedImage

The BufferedImage to be transformed.

Returns:Rectangle2D

The Rectangle2D representing the destination's bounding box.

getBounds2Dback to summary
public final Rectangle2D getBounds2D(Raster src)

Implements java.awt.image.RasterOp.getBounds2D.

Returns the bounding box of the transformed destination. The rectangle returned will be the actual bounding box of the transformed points. The coordinates of the upper-left corner of the returned rectangle might not be (0, 0).

Parameters
src:Raster

The Raster to be transformed.

Returns:Rectangle2D

The Rectangle2D representing the destination's bounding box.

getInterpolationTypeback to summary
public final int getInterpolationType()

Returns the interpolation type used by this op.

Returns:int

the interpolation type.

See Also
TYPE_NEAREST_NEIGHBOR, TYPE_BILINEAR, TYPE_BICUBIC
getPoint2Dback to summary
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt)

Implements java.awt.image.BufferedImageOp.getPoint2D, java.awt.image.RasterOp.getPoint2D.

Returns the location of the corresponding destination point given a point in the source. If dstPt is specified, it is used to hold the return value.

Parameters
srcPt:Point2D

The Point2D that represents the source point.

dstPt:Point2D

The Point2D in which to store the result.

Returns:Point2D

The Point2D in the destination that corresponds to the specified point in the source.

getRenderingHintsback to summary
public final RenderingHints getRenderingHints()

Implements java.awt.image.BufferedImageOp.getRenderingHints, java.awt.image.RasterOp.getRenderingHints.

Returns the rendering hints used by this transform operation.

Returns:RenderingHints

The RenderingHints object associated with this op.

getTransformback to summary
public final AffineTransform getTransform()

Returns the affine transform used by this transform operation.

Returns:AffineTransform

The AffineTransform associated with this op.

validateTransformback to summary
pack-priv void validateTransform(AffineTransform xform)