Package com.jhlabs.image
Class TransformFilter
- java.lang.Object
-
- com.jhlabs.image.AbstractBufferedImageOp
-
- com.jhlabs.image.TransformFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
,java.lang.Cloneable
- Direct Known Subclasses:
CircleFilter
,CurlFilter
,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 Summary
Fields Modifier and Type Field Description static int
BILINEAR
Use bilinear interpolation.static int
CLAMP
Clamp pixels to the image edges.protected int
edgeAction
The action to take for pixels off the image edge.protected int
interpolation
The type of interpolation to use.static int
NEAREST_NEIGHBOUR
Use nearest-neighbout interpolation.protected java.awt.Rectangle
originalSpace
The input image rectangle.static int
RGB_CLAMP
Clamp pixels RGB to the image edges, but zero the alpha.protected java.awt.Rectangle
transformedSpace
The output image rectangle.static int
WRAP
Wrap pixels off the edge onto the oppsoite edge.static int
ZERO
Treat pixels off the edge as zero.
-
Constructor Summary
Constructors Constructor Description TransformFilter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
protected java.awt.image.BufferedImage
filterPixelsNN(java.awt.image.BufferedImage dst, int width, int height, int[] inPixels, java.awt.Rectangle transformedSpace)
int
getEdgeAction()
Get the action to perform for pixels off the edge of the image.int
getInterpolation()
Get the type of interpolation to perform.void
setEdgeAction(int edgeAction)
Set the action to perform for pixels off the edge of the image.void
setInterpolation(int interpolation)
Set the type of interpolation to perform.protected abstract void
transformInverse(int x, int y, float[] out)
Inverse transform a point.protected void
transformSpace(java.awt.Rectangle rect)
Forward transform a rectangle.-
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints, getRGB, setRGB, stringToColor
-
-
-
-
Field Detail
-
ZERO
public static final int ZERO
Treat pixels off the edge as zero.- See Also:
- Constant Field Values
-
CLAMP
public static final int CLAMP
Clamp pixels to the image edges.- See Also:
- Constant Field Values
-
WRAP
public static final int WRAP
Wrap pixels off the edge onto the oppsoite edge.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
NEAREST_NEIGHBOUR
public static final int NEAREST_NEIGHBOUR
Use nearest-neighbout interpolation.- See Also:
- Constant Field Values
-
BILINEAR
public static final int BILINEAR
Use bilinear interpolation.- See Also:
- Constant Field Values
-
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 java.awt.Rectangle transformedSpace
The output image rectangle.
-
originalSpace
protected java.awt.Rectangle originalSpace
The input image rectangle.
-
-
Method Detail
-
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()
-
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:
setEdgeAction(int)
-
setInterpolation
public void setInterpolation(int interpolation)
Set the type of interpolation to perform.- Parameters:
interpolation
- one of NEAREST_NEIGHBOUR or BILINEAR- See Also:
getInterpolation()
-
getInterpolation
public int getInterpolation()
Get the type of interpolation to perform.- Returns:
- one of NEAREST_NEIGHBOUR or BILINEAR
- See Also:
setInterpolation(int)
-
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 imagey
- the Y position of the pixel in the output imageout
- the position of the pixel in the input image
-
transformSpace
protected void transformSpace(java.awt.Rectangle rect)
Forward transform a rectangle. Used to determine the size of the output image.- Parameters:
rect
- the rectangle to transform
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
-
filterPixelsNN
protected java.awt.image.BufferedImage filterPixelsNN(java.awt.image.BufferedImage dst, int width, int height, int[] inPixels, java.awt.Rectangle transformedSpace)
-
-