- java.lang.Object
-
- java.awt.image.AffineTransformOp
-
- All Implemented Interfaces:
- BufferedImageOp, RasterOp
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 orRaster
to 2D coordinates in the destination image orRaster
. The type of interpolation that is used is specified through a constructor, either by aRenderingHints
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
Raster
objects, the number of bands in the source must be equal to the number of bands in the destination.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
TYPE_BICUBIC
Bicubic interpolation type.static int
TYPE_BILINEAR
Bilinear interpolation type.static int
TYPE_NEAREST_NEIGHBOR
Nearest-neighbor interpolation type.
-
Constructor Summary
Constructors Constructor and Description AffineTransformOp(AffineTransform xform, int interpolationType)
Constructs anAffineTransformOp
given an affine transform and the interpolation type.AffineTransformOp(AffineTransform xform, RenderingHints hints)
Constructs anAffineTransformOp
given an affine transform.
-
Method Summary
Methods Modifier and Type Method and Description 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 destinationRaster
with the correct size and number of bands.BufferedImage
filter(BufferedImage src, BufferedImage dst)
Transforms the sourceBufferedImage
and stores the results in the destinationBufferedImage
.WritableRaster
filter(Raster src, WritableRaster dst)
Transforms the sourceRaster
and stores the results in the destinationRaster
.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()
Returns the interpolation type used by this op.Point2D
getPoint2D(Point2D srcPt, Point2D dstPt)
Returns the location of the corresponding destination point given a point in the source.RenderingHints
getRenderingHints()
Returns the rendering hints used by this transform operation.AffineTransform
getTransform()
Returns the affine transform used by this transform operation.
-
-
-
Field Detail
-
TYPE_NEAREST_NEIGHBOR
public static final int TYPE_NEAREST_NEIGHBOR
Nearest-neighbor interpolation type.- See Also:
- Constant Field Values
-
TYPE_BILINEAR
public static final int TYPE_BILINEAR
Bilinear interpolation type.- See Also:
- Constant Field Values
-
TYPE_BICUBIC
public static final int TYPE_BICUBIC
Bicubic interpolation type.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AffineTransformOp
public AffineTransformOp(AffineTransform xform, RenderingHints hints)
Constructs anAffineTransformOp
given an affine transform. The interpolation type is determined from theRenderingHints
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 isTYPE_NEAREST_NEIGHBOR
.- Parameters:
xform
- TheAffineTransform
to use for the operation.hints
- TheRenderingHints
object used to specify the interpolation type for the operation.- Throws:
ImagingOpException
- if the transform is non-invertible.- See Also:
RenderingHints.KEY_INTERPOLATION
,RenderingHints.KEY_RENDERING
-
AffineTransformOp
public AffineTransformOp(AffineTransform xform, int interpolationType)
Constructs anAffineTransformOp
given an affine transform and the interpolation type.- Parameters:
xform
- TheAffineTransform
to 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 Detail
-
getInterpolationType
public final int getInterpolationType()
Returns the interpolation type used by this op.- Returns:
- the interpolation type.
- See Also:
TYPE_NEAREST_NEIGHBOR
,TYPE_BILINEAR
,TYPE_BICUBIC
-
filter
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
Transforms the sourceBufferedImage
and stores the results in the destinationBufferedImage
. 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, aBufferedImage
is created with the sourceColorModel
.The coordinates of the rectangle returned by
getBounds2D(BufferedImage)
are not necessarily the same as the coordinates of theBufferedImage
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 destinationBufferedImage
.An
IllegalArgumentException
is thrown if the source is the same as the destination.- Specified by:
filter
in interfaceBufferedImageOp
- Parameters:
src
- TheBufferedImage
to transform.dst
- TheBufferedImage
in which to store the results of the transformation.- Returns:
- The filtered
BufferedImage
. - Throws:
IllegalArgumentException
- ifsrc
anddst
are the sameImagingOpException
- 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)
Transforms the sourceRaster
and stores the results in the destinationRaster
. This operation performs the transform band by band.If the destination
Raster
is null, a newRaster
is created. AnIllegalArgumentException
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 theWritableRaster
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 destinationRaster
.- Specified by:
filter
in interfaceRasterOp
- Parameters:
src
- TheRaster
to transform.dst
- TheRaster
in 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)
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).- Specified by:
getBounds2D
in interfaceBufferedImageOp
- Parameters:
src
- TheBufferedImage
to be transformed.- Returns:
- The
Rectangle2D
representing the destination's bounding box.
-
getBounds2D
public final Rectangle2D getBounds2D(Raster src)
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).- Specified by:
getBounds2D
in interfaceRasterOp
- Parameters:
src
- TheRaster
to be transformed.- Returns:
- The
Rectangle2D
representing the destination's bounding box.
-
createCompatibleDestImage
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM)
Creates a zeroed destination image with the correct size and number of bands. ARasterFormatException
may be thrown if the transformed width or height is equal to 0.If
destCM
is null, an appropriateColorModel
is used; thisColorModel
may have an alpha channel even if the sourceColorModel
is opaque.- Specified by:
createCompatibleDestImage
in interfaceBufferedImageOp
- Parameters:
src
- TheBufferedImage
to be transformed.destCM
-ColorModel
of the destination. If null, an appropriateColorModel
is used.- Returns:
- The zeroed destination image.
-
createCompatibleDestRaster
public WritableRaster createCompatibleDestRaster(Raster src)
Creates a zeroed destinationRaster
with the correct size and number of bands. ARasterFormatException
may be thrown if the transformed width or height is equal to 0.- Specified by:
createCompatibleDestRaster
in interfaceRasterOp
- Parameters:
src
- TheRaster
to be transformed.- Returns:
- The zeroed destination
Raster
.
-
getPoint2D
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
Returns the location of the corresponding destination point given a point in the source. IfdstPt
is specified, it is used to hold the return value.- Specified by:
getPoint2D
in interfaceBufferedImageOp
- Specified by:
getPoint2D
in interfaceRasterOp
- Parameters:
srcPt
- ThePoint2D
that represents the source point.dstPt
- ThePoint2D
in which to store the result.- Returns:
- The
Point2D
in the destination that corresponds to the specified point in the source.
-
getTransform
public final AffineTransform getTransform()
Returns the affine transform used by this transform operation.- Returns:
- The
AffineTransform
associated with this op.
-
getRenderingHints
public final RenderingHints getRenderingHints()
Returns the rendering hints used by this transform operation.- Specified by:
getRenderingHints
in interfaceBufferedImageOp
- Specified by:
getRenderingHints
in interfaceRasterOp
- Returns:
- The
RenderingHints
object associated with this op.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/awt/image/affinetransformop.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.