Package com.day.image

Class DistortOp

  • All Implemented Interfaces:
    BufferedImageOp

    public class DistortOp
    extends AbstractBufferedImageOp
    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 Detail

      • DistortOp

        public 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.
        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 is null or if any of the coordinates is null.
      • DistortOp

        public DistortOp​(float[][] coords,
                         boolean crop,
                         Color bgColor)
        Creates the DistortOp 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:
        IllegalArgumentException - if not enough - namely four - coordinate pairs are supplied to the constructor.
        NullPointerException - if the coords parameter is null or if any of the coordinates is null.