Class TransformFilter

All Implemented Interfaces:
BufferedImageOp, Cloneable
Direct Known Subclasses:
CircleFilter, DiffuseFilter, DisplaceFilter, FieldWarpFilter, KaleidoscopeFilter, MapFilter, MarbleFilter, OffsetFilter, PerspectiveFilter, PinchFilter, PolarFilter, RippleFilter, RotateFilter, ShearFilter, SphereFilter, SwimFilter, TwirlFilter, WaterFilter

public abstract class TransformFilter extends AbstractBufferedImageOp
An abstract superclass for filters which distort images in some way. The subclass only needs to override two methods to provide the mapping between source and destination pixels.
  • Field Details

    • ZERO

      public static final int ZERO
      Treat pixels off the edge as zero.
      See Also:
    • CLAMP

      public static final int CLAMP
      Clamp pixels to the image edges.
      See Also:
    • WRAP

      public static final int WRAP
      Wrap pixels off the edge onto the oppsoite edge.
      See Also:
    • RGB_CLAMP

      public static final int RGB_CLAMP
      Clamp pixels RGB to the image edges, but zero the alpha. This prevents gray borders on your image.
      See Also:
    • NEAREST_NEIGHBOUR

      public static final int NEAREST_NEIGHBOUR
      Use nearest-neighbout interpolation.
      See Also:
    • BILINEAR

      public static final int BILINEAR
      Use bilinear interpolation.
      See Also:
    • edgeAction

      protected int edgeAction
      The action to take for pixels off the image edge.
    • interpolation

      protected int interpolation
      The type of interpolation to use.
    • transformedSpace

      protected Rectangle transformedSpace
      The output image rectangle.
    • originalSpace

      protected Rectangle originalSpace
      The input image rectangle.
  • Constructor Details

    • TransformFilter

      public TransformFilter()
  • Method Details

    • setEdgeAction

      public void setEdgeAction(int edgeAction)
      Set the action to perform for pixels off the edge of the image.
      Parameters:
      edgeAction - one of ZERO, CLAMP or WRAP
      See Also:
    • getEdgeAction

      public int getEdgeAction()
      Get the action to perform for pixels off the edge of the image.
      Returns:
      one of ZERO, CLAMP or WRAP
      See Also:
    • setInterpolation

      public void setInterpolation(int interpolation)
      Set the type of interpolation to perform.
      Parameters:
      interpolation - one of NEAREST_NEIGHBOUR or BILINEAR
      See Also:
    • getInterpolation

      public int getInterpolation()
      Get the type of interpolation to perform.
      Returns:
      one of NEAREST_NEIGHBOUR or BILINEAR
      See Also:
    • transformInverse

      protected abstract void transformInverse(int x, int y, float[] out)
      Inverse transform a point. This method needs to be overriden by all subclasses.
      Parameters:
      x - the X position of the pixel in the output image
      y - the Y position of the pixel in the output image
      out - the position of the pixel in the input image
    • transformSpace

      protected void transformSpace(Rectangle rect)
      Forward transform a rectangle. Used to determine the size of the output image.
      Parameters:
      rect - the rectangle to transform
    • filter

      public BufferedImage filter(BufferedImage src, BufferedImage dst)
    • filterPixelsNN

      protected BufferedImage filterPixelsNN(BufferedImage dst, int width, int height, int[] inPixels, Rectangle transformedSpace)