Class DiffusionFilter

All Implemented Interfaces:
BufferedImageOp, Cloneable

public class DiffusionFilter extends WholeImageFilter
A filter which uses Floyd-Steinberg error diffusion dithering to halftone an image.
  • Constructor Details

    • DiffusionFilter

      public DiffusionFilter()
      Construct a DiffusionFilter.
  • Method Details

    • 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

      public boolean getSerpentine()
      Return the serpentine setting.
      Returns:
      the current setting
      See Also:
    • setColorDither

      public void setColorDither(boolean colorDither)
      Set whether to use a color dither.
      Parameters:
      colorDither - true to use a color dither
      See Also:
    • getColorDither

      public boolean getColorDither()
      Get whether to use a color dither.
      Returns:
      true to use a color dither
      See Also:
    • setMatrix

      public void setMatrix(int[] matrix)
      Set the dither matrix.
      Parameters:
      matrix - the dither matrix
      See Also:
    • getMatrix

      public int[] getMatrix()
      Get the dither matrix.
      Returns:
      the dither matrix
      See Also:
    • setLevels

      public void setLevels(int levels)
      Set the number of dither levels.
      Parameters:
      levels - the number of levels
      See Also:
    • getLevels

      public int getLevels()
      Get the number of dither levels.
      Returns:
      the number of levels
      See Also:
    • filterPixels

      protected int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace)
      Description copied from class: WholeImageFilter
      Actually filter the pixels.
      Specified by:
      filterPixels in class WholeImageFilter
      Parameters:
      width - the image width
      height - the image height
      inPixels - the image pixels
      transformedSpace - the output bounds
      Returns:
      the output pixels
    • toString

      public String toString()
      Overrides:
      toString in class Object