Class Colorize

  • All Implemented Interfaces:
    ImageFilter

    public final class Colorize
    extends java.lang.Object
    implements ImageFilter
    An image filter which will add a color tint to an image.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Color c
      The color to tint a target image with.
    • Constructor Summary

      Constructors 
      Constructor Description
      Colorize​(java.awt.Color c)
      Instantiates this filter with the color to use to tint the target image with.
      Colorize​(java.awt.Color c, float alpha)
      Instantiates this filter with the color to use to tint the target image with and the transparency level provided as a float ranging from 0.0f to 1.0f, where 0.0f indicates completely transparent, and 1.0f indicates completely opaque.
      Colorize​(java.awt.Color c, int alpha)
      Instantiates this filter with the color to use to tint the target image with and the transparency level provided as a int ranging from 0 to 255, where 0 indicates completely transparent, and 255 indicates completely opaque.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.image.BufferedImage apply​(java.awt.image.BufferedImage img)
      Applies a image filtering operation on an image.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • c

        private final java.awt.Color c
        The color to tint a target image with.
    • Constructor Detail

      • Colorize

        public Colorize​(java.awt.Color c)
        Instantiates this filter with the color to use to tint the target image with.

        Note: If the provided Color does not have an alpha channel (transparency channel), then the target image will be painted with an opaque color, resulting in an image with only the specified color.

        Parameters:
        c - Color to tint with.
      • Colorize

        public Colorize​(java.awt.Color c,
                        float alpha)
        Instantiates this filter with the color to use to tint the target image with and the transparency level provided as a float ranging from 0.0f to 1.0f, where 0.0f indicates completely transparent, and 1.0f indicates completely opaque.
        Parameters:
        c - Color to tint with.
        alpha - The opacity of the tint.
      • Colorize

        public Colorize​(java.awt.Color c,
                        int alpha)
        Instantiates this filter with the color to use to tint the target image with and the transparency level provided as a int ranging from 0 to 255, where 0 indicates completely transparent, and 255 indicates completely opaque.
        Parameters:
        c - Color to tint with.
        alpha - The opacity of the tint.
    • Method Detail

      • apply

        public java.awt.image.BufferedImage apply​(java.awt.image.BufferedImage img)
        Description copied from interface: ImageFilter
        Applies a image filtering operation on an image.
        Specified by:
        apply in interface ImageFilter
        Parameters:
        img - The image to apply the filtering on.
        Returns:
        The resulting image after applying this filter.