Package com.day.image
Class DistortOp
java.lang.Object
com.day.image.AbstractBufferedImageOp
com.day.image.DistortOp
- All Implemented Interfaces:
BufferedImageOp
The
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.
- Since:
- coati
-
Constructor Summary
ConstructorsConstructorDescriptionDistortOp(float[][] coords) Creates theDistortOpobject 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.Creates theDistortOpobject by supplying the coordinates of the new corners of the image. -
Method Summary
Modifier and TypeMethodDescriptiongetBounds2D(BufferedImage src) Returns the bounding box of the filtered destination image.getPoint2D(Point2D srcPt, 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 Details
-
DistortOp
public DistortOp(float[][] coords) Creates theDistortOpobject 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:
IllegalArgumentException- if not enough - namely four - coordinate pairs are supplied to the constructor.NullPointerException- if the coords parameter isnullor if any of the coordinates isnull.
-
DistortOp
Creates theDistortOpobject 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-trueif 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:
IllegalArgumentException- if not enough - namely four - coordinate pairs are supplied to the constructor.NullPointerException- if the coords parameter isnullor if any of the coordinates isnull.
-
-
Method Details
-
getBounds2D
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:
getBounds2Din interfaceBufferedImageOp- Overrides:
getBounds2Din classAbstractBufferedImageOp
-
getPoint2D
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:
getPoint2Din interfaceBufferedImageOp- Overrides:
getPoint2Din classAbstractBufferedImageOp
-