Class AffineTransformOp
- All Implemented Interfaces:
-
BufferedImageOp,RasterOp
public class AffineTransformOp extends Object implements BufferedImageOp, RasterOp
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:
- The source and destination must be different.
- For
Rasterobjects, the number of bands in the source must be equal to the number of bands in the destination.
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
static final int |
TYPE_BICUBIC |
Bicubic interpolation type. |
static final int |
TYPE_BILINEAR |
Bilinear interpolation type. |
static final int |
TYPE_NEAREST_NEIGHBOR |
Nearest-neighbor interpolation type. |
Constructor Summary
| Constructor | Description |
|---|---|
AffineTransformOp |
Constructs an AffineTransformOp given an affine transform and the interpolation type. |
AffineTransformOp |
Constructs an AffineTransformOp given an affine transform. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
BufferedImage |
createCompatibleDestImage |
Creates a zeroed destination image with the correct size and number of bands. |
WritableRaster |
createCompatibleDestRaster |
Creates a zeroed destination Raster with the correct size and number of bands. |
final BufferedImage |
filter |
Transforms the source BufferedImage and stores the results in the destination BufferedImage. |
final WritableRaster |
filter |
Transforms the source Raster and stores the results in the destination Raster. |
final Rectangle2D |
getBounds2D |
Returns the bounding box of the transformed destination. |
final Rectangle2D |
getBounds2D |
Returns the bounding box of the transformed destination. |
final int |
getInterpolationType() |
Returns the interpolation type used by this op. |
final Point2D |
getPoint2D |
Returns the location of the corresponding destination point given a point in the source. |
final RenderingHints |
getRenderingHints() |
Returns the rendering hints used by this transform operation. |
final AffineTransform |
getTransform() |
Returns the affine transform used by this transform operation. |
Field Details
TYPE_NEAREST_NEIGHBOR
@Native public static final int TYPE_NEAREST_NEIGHBOR
- See Also:
TYPE_BILINEAR
@Native public static final int TYPE_BILINEAR
- See Also:
TYPE_BICUBIC
@Native public static final int TYPE_BICUBIC
- See Also:
Constructor Details
AffineTransformOp
public AffineTransformOp(AffineTransform xform, RenderingHints hints)
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- TheAffineTransformto use for the operation. -
hints- TheRenderingHintsobject used to specify the interpolation type for the operation. - Throws:
-
ImagingOpException- if the transform is non-invertible. - See Also:
AffineTransformOp
public AffineTransformOp(AffineTransform xform, int interpolationType)
AffineTransformOp given an affine transform and the interpolation type.- Parameters:
-
xform- TheAffineTransformto use for the operation. -
interpolationType- One of the integer interpolation type constants defined by this class:TYPE_NEAREST_NEIGHBOR,TYPE_BILINEAR,TYPE_BICUBIC. - Throws:
-
ImagingOpException- if the transform is non-invertible.
Method Details
getInterpolationType
public final int getInterpolationType()
- Returns:
- the interpolation type.
- See Also:
filter
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
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.
- Specified by:
-
filterin interfaceBufferedImageOp - Parameters:
-
src- TheBufferedImageto transform. -
dst- TheBufferedImagein which to store the results of the transformation. - Returns:
- The filtered
BufferedImage. - Throws:
-
IllegalArgumentException- ifsrcanddstare 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.
filter
public final WritableRaster filter(Raster src, WritableRaster dst)
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.
- Specified by:
-
filterin interfaceRasterOp - Parameters:
-
src- TheRasterto transform. -
dst- TheRasterin which to store the results of the transformation. - Returns:
- The transformed
Raster. - Throws:
-
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.
getBounds2D
public final Rectangle2D getBounds2D(BufferedImage src)
- Specified by:
-
getBounds2Din interfaceBufferedImageOp - Parameters:
-
src- TheBufferedImageto be transformed. - Returns:
- The
Rectangle2Drepresenting the destination's bounding box.
getBounds2D
public final Rectangle2D getBounds2D(Raster src)
- Specified by:
-
getBounds2Din interfaceRasterOp - Parameters:
-
src- TheRasterto be transformed. - Returns:
- The
Rectangle2Drepresenting the destination's bounding box.
createCompatibleDestImage
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM)
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.
- Specified by:
-
createCompatibleDestImagein interfaceBufferedImageOp - Parameters:
-
src- TheBufferedImageto be transformed. -
destCM-ColorModelof the destination. If null, an appropriateColorModelis used. - Returns:
- The zeroed destination image.
createCompatibleDestRaster
public WritableRaster createCompatibleDestRaster(Raster src)
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:
-
createCompatibleDestRasterin interfaceRasterOp - Parameters:
-
src- TheRasterto be transformed. - Returns:
- The zeroed destination
Raster.
getPoint2D
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
dstPt is specified, it is used to hold the return value.- Specified by:
-
getPoint2Din interfaceBufferedImageOp - Specified by:
-
getPoint2Din interfaceRasterOp - Parameters:
-
srcPt- ThePoint2Dthat represents the source point. -
dstPt- ThePoint2Din which to store the result. - Returns:
- The
Point2Din the destination that corresponds to the specified point in the source.
getTransform
public final AffineTransform getTransform()
- Returns:
- The
AffineTransformassociated with this op.
getRenderingHints
public final RenderingHints getRenderingHints()
- Specified by:
-
getRenderingHintsin interfaceBufferedImageOp - Specified by:
-
getRenderingHintsin interfaceRasterOp - Returns:
- The
RenderingHintsobject associated with this op.
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/image/AffineTransformOp.html