Class MaskFilter

All Implemented Interfaces:
ImageConsumer, Cloneable

public class MaskFilter extends RGBImageFilter
An image filter that replaces one color in an image with another color.
  • Constructor Details

    • MaskFilter

      public MaskFilter(Color oldColor, Color newColor)
      Constructs a MaskFilter object that filters color of image to another color Please note, you can also use getInstance(java.awt.Color, java.awt.Color) to reuse the same instance of MaskFilter.
      Parameters:
      oldColor - old color in exist image that needs to be replaced by new color
      newColor - new color to replace the old color
  • Method Details

    • getInstance

      public static MaskFilter getInstance(Color oldColor, Color newColor)
    • createImage

      public static Image createImage(Image i, Color oldColor, Color newColor)
      Creates an image from an existing one by replacing the old color with the new color.
    • createNegativeImage

      public static Image createNegativeImage(Image i)
      Creates an image as negative of an existing one. It will basically replace the black color with white color.
    • filterRGB

      public int filterRGB(int x, int y, int rgb)
      Overrides RGBImageFilter.filterRGB.
      Specified by:
      filterRGB in class RGBImageFilter