Package com.jhlabs.image
Class TransformFilter
java.lang.Object
com.jhlabs.image.AbstractBufferedImageOp
com.jhlabs.image.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
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
FieldsModifier and TypeFieldDescriptionstatic final int
Use bilinear interpolation.static final int
Clamp pixels to the image edges.protected int
The action to take for pixels off the image edge.protected int
The type of interpolation to use.static final int
Use nearest-neighbout interpolation.protected Rectangle
The input image rectangle.static final int
Clamp pixels RGB to the image edges, but zero the alpha.protected Rectangle
The output image rectangle.static final int
Wrap pixels off the edge onto the oppsoite edge.static final int
Treat pixels off the edge as zero. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilter
(BufferedImage src, BufferedImage dst) protected BufferedImage
filterPixelsNN
(BufferedImage dst, int width, int height, int[] inPixels, Rectangle transformedSpace) int
Get the action to perform for pixels off the edge of the image.int
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
(Rectangle rect) Forward transform a rectangle.Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints, getRGB, setRGB
-
Field Details
-
ZERO
public static final int ZEROTreat pixels off the edge as zero.- See Also:
-
CLAMP
public static final int CLAMPClamp pixels to the image edges.- See Also:
-
WRAP
public static final int WRAPWrap pixels off the edge onto the oppsoite edge.- See Also:
-
RGB_CLAMP
public static final int RGB_CLAMPClamp 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_NEIGHBOURUse nearest-neighbout interpolation.- See Also:
-
BILINEAR
public static final int BILINEARUse bilinear interpolation.- See Also:
-
edgeAction
protected int edgeActionThe action to take for pixels off the image edge. -
interpolation
protected int interpolationThe type of interpolation to use. -
transformedSpace
The output image 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 imagey
- the Y position of the pixel in the output imageout
- the position of the pixel in the input image
-
transformSpace
Forward transform a rectangle. Used to determine the size of the output image.- Parameters:
rect
- the rectangle to transform
-
filter
-
filterPixelsNN
protected BufferedImage filterPixelsNN(BufferedImage dst, int width, int height, int[] inPixels, Rectangle transformedSpace)
-