Package ca.cgjennings.graphics.filters
Class ChannelFunctionFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.ChannelFunctionFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public class ChannelFunctionFilter extends AbstractPixelwiseFilter
A image filter that applies a function to each channel. The function takes a value between 0 and 1 for a pixel's channel value, and returns a value between 0 and 1 for the output value. The returned value is clamped to lie in the allowed range, if necessary. That is, if the function returns a value less than 0, it is clamped to 0. Likewise, if it returns a value greater than 1, it is clamped to 1.In-place filtering: This class supports in-place filtering (the source and destination images may be the same).
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description ChannelFunctionFilter()
Creates a new function filter with all channel functions set to an identity function.ChannelFunctionFilter(Fn alpha, Fn red, Fn green, Fn blue)
Creates a new function filter with the specified channel functions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
void
filterPixels(int[] argb, int start, int end)
This method is called with a block of ARGB values to be filtered.Fn
getAlphaFunction()
Fn
getBlueFunction()
Fn
getGreenFunction()
Fn
getRedFunction()
void
setAlphaFunction(Fn alphaFunction)
void
setBlueFunction(Fn blueFunction)
void
setGreenFunction(Fn greenFunction)
void
setRedFunction(Fn redFunction)
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
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
-
-
-
-
Constructor Detail
-
ChannelFunctionFilter
public ChannelFunctionFilter()
Creates a new function filter with all channel functions set to an identity function.- See Also:
Fn.IDENTITY
-
ChannelFunctionFilter
public ChannelFunctionFilter(Fn alpha, Fn red, Fn green, Fn blue)
Creates a new function filter with the specified channel functions.- Parameters:
alpha
- the function applied to the alpha channelred
- the function applied to the red channelgreen
- the function applied to the green channelblue
- the function applied to the blue channel
-
-
Method Detail
-
getAlphaFunction
public Fn getAlphaFunction()
-
setAlphaFunction
public void setAlphaFunction(Fn alphaFunction)
-
getRedFunction
public Fn getRedFunction()
-
setRedFunction
public void setRedFunction(Fn redFunction)
-
getGreenFunction
public Fn getGreenFunction()
-
setGreenFunction
public void setGreenFunction(Fn greenFunction)
-
getBlueFunction
public Fn getBlueFunction()
-
setBlueFunction
public void setBlueFunction(Fn blueFunction)
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
- Specified by:
filter
in interfacejava.awt.image.BufferedImageOp
- Overrides:
filter
in classAbstractPixelwiseFilter
-
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
-
-