Class ColorFilter

All Implemented Interfaces:
ImageConsumer, Cloneable

public class ColorFilter extends RGBImageFilter
An image filter that brightens or darkens an existing image.
  • Constructor Details

    • ColorFilter

      public ColorFilter(boolean b, int p)
      Constructs a ColorFilter object that filters a color image to a brighter or a darker image. Please note, you can also use getInstance(boolean, int) to reuse the same instance of ColorFilter.
      Parameters:
      b - a boolean -- true if the pixels should be brightened
      p - an int in the range 0..100 that determines the percentage of gray, where 100 is the darkest gray, and 0 is the lightest
  • Method Details

    • getInstance

      public static ColorFilter getInstance(boolean brighter, int percent)
    • setBrighter

      public void setBrighter(boolean brighter)
    • setPercent

      public static void setPercent(int percent)
    • getPercent

      public static int getPercent()
    • createBrighterImage

      public static Image createBrighterImage(Image i)
      Creates a brighter image
      Parameters:
      i - the original image
      Returns:
      a brighter image
    • createBrighterImage

      public static Image createBrighterImage(Image i, int p)
      Creates a brighter image with a given percentage of brightness
      Parameters:
      i - the original image
      p - percentage of brightness
      Returns:
      a brighter image
    • createDarkerImage

      public static Image createDarkerImage(Image i)
      Creates a darker image
      Parameters:
      i - the original image
      Returns:
      a darker image.
    • createDarkerImage

      public static Image createDarkerImage(Image i, int p)
      Creates a darker image with a given percentage of darkness
      Parameters:
      i - the original image
      p - percentage of darkness
      Returns:
      a darker image.
    • filterRGB

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