Package ca.cgjennings.graphics.filters
Class ReplaceHueSaturationFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.AbstractTintingFilter
-
- ca.cgjennings.graphics.filters.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).
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.graphics.filters.AbstractTintingFilter
bFactor, hFactor, sFactor
-
-
Constructor Summary
Constructors Constructor Description ReplaceHueSaturationFilter()
ReplaceHueSaturationFilter(float h, float s, float b)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
filterPixels(int[] argb, int start, int end)
This method is called with a block of ARGB values to be filtered.void
setFactors(float h, float s, float b)
Sets the hue, saturation, and brightness factors to use for tinting.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractTintingFilter
getBFactor, getHFactor, getSFactor, isIdentity, setBFactor, setHFactor, setSFactor
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
filter, filter, filterPixel, workFactor
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, createCompatibleDestImage, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.awt.image.BufferedImageOp
createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
-
Methods inherited from interface ca.cgjennings.graphics.filters.TintingFilter
filter
-
-
-
-
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 interfaceTintingFilter
- Overrides:
setFactors
in classAbstractTintingFilter
- Parameters:
h
- the hue factors
- the saturation factorb
- 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 rangeargb[start] ... argb[end-1]
with the filtered value.- Specified by:
filterPixels
in classAbstractPixelwiseFilter
- Parameters:
argb
- an array of pixel data to filterstart
- the index of the first pixel to filterend
- the index of the last pixel to filter, plus one
-
-