Package com.jhlabs.image
Class DiffusionFilter
- java.lang.Object
-
- com.jhlabs.image.AbstractBufferedImageOp
-
- com.jhlabs.image.WholeImageFilter
-
- com.jhlabs.image.DiffusionFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp,java.lang.Cloneable
public class DiffusionFilter extends WholeImageFilter
A filter which uses Floyd-Steinberg error diffusion dithering to halftone an image.
-
-
Field Summary
-
Fields inherited from class com.jhlabs.image.WholeImageFilter
originalSpace, transformedSpace
-
-
Constructor Summary
Constructors Constructor Description DiffusionFilter()Construct a DiffusionFilter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int[]filterPixels(int width, int height, int[] inPixels, java.awt.Rectangle transformedSpace)Actually filter the pixels.booleangetColorDither()Get whether to use a color dither.intgetLevels()Get the number of dither levels.int[]getMatrix()Get the dither matrix.booleangetSerpentine()Return the serpentine setting.voidsetColorDither(boolean colorDither)Set whether to use a color dither.voidsetLevels(int levels)Set the number of dither levels.voidsetMatrix(int[] matrix)Set the dither matrix.voidsetSerpentine(boolean serpentine)Set whether to use a serpentine pattern for return or not.java.lang.StringtoString()-
Methods inherited from class com.jhlabs.image.WholeImageFilter
filter, transformSpace
-
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints, getRGB, setRGB, stringToColor
-
-
-
-
Method Detail
-
setSerpentine
public void setSerpentine(boolean serpentine)
Set whether to use a serpentine pattern for return or not. This can reduce 'avalanche' artifacts in the output.- Parameters:
serpentine- true to use serpentine pattern- See Also:
getSerpentine()
-
getSerpentine
public boolean getSerpentine()
Return the serpentine setting.- Returns:
- the current setting
- See Also:
setSerpentine(boolean)
-
setColorDither
public void setColorDither(boolean colorDither)
Set whether to use a color dither.- Parameters:
colorDither- true to use a color dither- See Also:
getColorDither()
-
getColorDither
public boolean getColorDither()
Get whether to use a color dither.- Returns:
- true to use a color dither
- See Also:
setColorDither(boolean)
-
setMatrix
public void setMatrix(int[] matrix)
Set the dither matrix.- Parameters:
matrix- the dither matrix- See Also:
getMatrix()
-
getMatrix
public int[] getMatrix()
Get the dither matrix.- Returns:
- the dither matrix
- See Also:
setMatrix(int[])
-
setLevels
public void setLevels(int levels)
Set the number of dither levels.- Parameters:
levels- the number of levels- See Also:
getLevels()
-
getLevels
public int getLevels()
Get the number of dither levels.- Returns:
- the number of levels
- See Also:
setLevels(int)
-
filterPixels
protected int[] filterPixels(int width, int height, int[] inPixels, java.awt.Rectangle transformedSpace)Description copied from class:WholeImageFilterActually filter the pixels.- Specified by:
filterPixelsin classWholeImageFilter- Parameters:
width- the image widthheight- the image heightinPixels- the image pixelstransformedSpace- the output bounds- Returns:
- the output pixels
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-