Package com.day.image
Class DistortOp
- java.lang.Object
-
- com.day.image.AbstractBufferedImageOp
-
- com.day.image.DistortOp
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public class DistortOp extends AbstractBufferedImageOp
TheDistortOp
class implements the distortion operation on aBufferedImage
. 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.
- Since:
- coati
-
-
Constructor Summary
Constructors Constructor Description DistortOp(float[][] coords)
Creates theDistortOp
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 theDistortOp
object by supplying the coordinates of the new corners of the image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.day.image.AbstractBufferedImageOp
createCompatibleDestImage, filter, getRenderingHints
-
-
-
-
Constructor Detail
-
DistortOp
public DistortOp(float[][] coords)
Creates theDistortOp
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.- Parameters:
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.- Throws:
java.lang.IllegalArgumentException
- if not enough - namely four - coordinate pairs are supplied to the constructor.java.lang.NullPointerException
- if the coords parameter isnull
or if any of the coordinates isnull
.
-
DistortOp
public DistortOp(float[][] coords, boolean crop, java.awt.Color bgColor)
Creates theDistortOp
object by supplying the coordinates of the new corners of the image.- Parameters:
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.- Throws:
java.lang.IllegalArgumentException
- if not enough - namely four - coordinate pairs are supplied to the constructor.java.lang.NullPointerException
- if the coords parameter isnull
or if any of the coordinates isnull
.
-
-
Method Detail
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
Returns the bounding box of the filtered destination image. The IllegalArgumentException may be thrown if the source image is incompatible with the types of images allowed by the class implementing this filter.- Specified by:
getBounds2D
in interfacejava.awt.image.BufferedImageOp
- Overrides:
getBounds2D
in classAbstractBufferedImageOp
-
getPoint2D
public 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. If dstPt is non-null, it will be used to hold the return value.- Specified by:
getPoint2D
in interfacejava.awt.image.BufferedImageOp
- Overrides:
getPoint2D
in classAbstractBufferedImageOp
-
-