Package org.jdesktop.swingx.image
Class GaussianBlurFilter
- java.lang.Object
-
- org.jdesktop.beans.AbstractBean
-
- org.jdesktop.swingx.image.AbstractFilter
-
- org.jdesktop.swingx.image.GaussianBlurFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public class GaussianBlurFilter extends AbstractFilter
-
-
Field Summary
Fields Modifier and Type Field Description private int
radius
-
Constructor Summary
Constructors Constructor Description GaussianBlurFilter()
Creates a new blur filter with a default radius of 3.GaussianBlurFilter(int radius)
Creates a new blur filter with the specified radius.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static void
blur(int[] srcPixels, int[] dstPixels, int width, int height, float[] kernel, int radius)
Blurs the source pixels into the destination pixels.(package private) static float[]
createGaussianKernel(int radius)
java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
int
getRadius()
Returns the radius used by this filter, in pixels.-
Methods inherited from class org.jdesktop.swingx.image.AbstractFilter
createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
-
Methods inherited from class org.jdesktop.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
GaussianBlurFilter
public GaussianBlurFilter()
Creates a new blur filter with a default radius of 3.
-
GaussianBlurFilter
public GaussianBlurFilter(int radius)
Creates a new blur filter with the specified radius. If the radius is lower than 1, a radius of 1 will be used automatically.
- Parameters:
radius
- the radius, in pixels, of the blur
-
-
Method Detail
-
getRadius
public int getRadius()
Returns the radius used by this filter, in pixels.
- Returns:
- the radius of the blur
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
- Specified by:
filter
in interfacejava.awt.image.BufferedImageOp
- Specified by:
filter
in classAbstractFilter
-
blur
static void blur(int[] srcPixels, int[] dstPixels, int width, int height, float[] kernel, int radius)
Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which must be greater than 0.
The source and destination pixels arrays are expected to be in the INT_ARGB format.
After this method is executed, dstPixels contains a transposed and filtered copy of srcPixels.
- Parameters:
srcPixels
- the source pixelsdstPixels
- the destination pixelswidth
- the width of the source pictureheight
- the height of the source picturekernel
- the kernel of the blur effectradius
- the radius of the blur effect
-
createGaussianKernel
static float[] createGaussianKernel(int radius)
-
-