public class DistortOp extends AbstractBufferedImageOp
DistortOp
class implements the distortion operation on a
BufferedImage
. The rectangular image is distorted such that the
orignal corners of the image are at four new coordinate locations. This
distortion is generally not linear and requires quite some calculation.
NOTE: This operation works uses copies of the full image to caclulate the new image. This takes an amount of memory relative to the size of the image. To calculate the needed space let srcWidth and srcHeight be the width and height, resp., of the source and dstWidth and dstHeight be the width and height, resp., of the destination image. Then the the source image needs : srcWidth * srcHeight * 4 channels * 4 bytes per sample bytes and the destination image needs dstWidth * dstHeight * 4 channels * 4 bytes.
Constructor and Description |
---|
DistortOp(float[][] coords)
Creates the
DistortOp object by supplying the coordinates
of the new corners of the image, where the result is not cropped and
pixels not filled with any part of the distorted image is replaced with
black. |
DistortOp(float[][] coords,
boolean crop,
java.awt.Color bgColor)
Creates the
DistortOp object by supplying the coordinates
of the new corners of the image. |
Modifier and Type | Method and Description |
---|---|
java.awt.geom.Rectangle2D |
getBounds2D(java.awt.image.BufferedImage src)
Returns the bounding box of the filtered destination image.
|
java.awt.geom.Point2D |
getPoint2D(java.awt.geom.Point2D srcPt,
java.awt.geom.Point2D dstPt)
Returns the location of the destination point given a
point in the source image.
|
createCompatibleDestImage, filter, getRenderingHints
public DistortOp(float[][] coords)
DistortOp
object by supplying the coordinates
of the new corners of the image, where the result is not cropped and
pixels not filled with any part of the distorted image is replaced with
black.coords
- 4x2 matrix describing an array of 4 scale factors by which
to transform each corner of an image distorted image in order
top/left, top/right, bottom/left, bottom/right.java.lang.IllegalArgumentException
- if not enough - namely four - coordinate
pairs are supplied to the constructor.java.lang.NullPointerException
- if the coords parameter is null
or if any of the coordinates is null
.public DistortOp(float[][] coords, boolean crop, java.awt.Color bgColor)
DistortOp
object by supplying the coordinates
of the new corners of the image.coords
- 4x2 matrix describing an array of 4 scale factors by which
to transform each corner of an image distorted image in order
top/left, top/right, bottom/left, bottom/right.crop
- true
if the result should be cropped to the
size of the source image.bgColor
- The color to use for pixels not covered by the distorted
part of the image.java.lang.IllegalArgumentException
- if not enough - namely four - coordinate
pairs are supplied to the constructor.java.lang.NullPointerException
- if the coords parameter is null
or if any of the coordinates is null
.public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
getBounds2D
in interface java.awt.image.BufferedImageOp
getBounds2D
in class AbstractBufferedImageOp
public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)
getPoint2D
in interface java.awt.image.BufferedImageOp
getPoint2D
in class AbstractBufferedImageOp
Copyright © 2010 - 2020 Adobe. All Rights Reserved