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 intUse bilinear interpolation.static final intClamp pixels to the image edges.protected intThe action to take for pixels off the image edge.protected intThe type of interpolation to use.static final intUse nearest-neighbout interpolation.protected RectangleThe input image rectangle.static final intClamp pixels RGB to the image edges, but zero the alpha.protected RectangleThe output image rectangle.static final intWrap pixels off the edge onto the oppsoite edge.static final intTreat pixels off the edge as zero. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilter(BufferedImage src, BufferedImage dst) protected BufferedImagefilterPixelsNN(BufferedImage dst, int width, int height, int[] inPixels, Rectangle transformedSpace) intGet the action to perform for pixels off the edge of the image.intGet the type of interpolation to perform.voidsetEdgeAction(int edgeAction) Set the action to perform for pixels off the edge of the image.voidsetInterpolation(int interpolation) Set the type of interpolation to perform.protected abstract voidtransformInverse(int x, int y, float[] out) Inverse transform a point.protected voidtransformSpace(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)
-