Class ReplaceHueSaturationFilter

  • All Implemented Interfaces:
    TintingFilter, java.awt.image.BufferedImageOp

    public class ReplaceHueSaturationFilter
    extends AbstractTintingFilter
    A tinting filter that replaces the hue and saturation of every pixel with fixed values, and scales the brightness. This tinting filter is useful when the image to be tinted is a template drawn in a single colour, possibly with variations in brightness. Typically the colour used is pure red; the following filter shows one way to convert an existing image to this format:
    new ChannelSwapFilter( ChannelSwapFilter.ALPHA, ChannelSwapFilter.GREY, 0, 0 );

    In-place filtering: This class supports in-place filtering (the source and destination image may be the same).

    • Constructor Detail

      • ReplaceHueSaturationFilter

        public ReplaceHueSaturationFilter()
      • ReplaceHueSaturationFilter

        public ReplaceHueSaturationFilter​(float h,
                                          float s,
                                          float b)
    • Method Detail

      • setFactors

        public void setFactors​(float h,
                               float s,
                               float b)
        Description copied from class: AbstractTintingFilter
        Sets the hue, saturation, and brightness factors to use for tinting.

        Implementation Note: if saturation or brightness are less than 0, they are clamped to 0. Values over 1 are not clamped. If your subclass requires that saturation or brightness are clamped at 1, override this method to do so, then call the super implementation.

        Specified by:
        setFactors in interface TintingFilter
        Overrides:
        setFactors in class AbstractTintingFilter
        Parameters:
        h - the hue factor
        s - the saturation factor
        b - the brightness factor
      • filterPixels

        public void filterPixels​(int[] argb,
                                 int start,
                                 int end)
        Description copied from class: AbstractPixelwiseFilter
        This method is called with a block of ARGB values to be filtered. Subclasses must override this method to implement the actual filtering algorithm by replacing each pixel value in the range argb[start] ... argb[end-1] with the filtered value.
        Specified by:
        filterPixels in class AbstractPixelwiseFilter
        Parameters:
        argb - an array of pixel data to filter
        start - the index of the first pixel to filter
        end - the index of the last pixel to filter, plus one