Package ca.cgjennings.graphics.filters
Class ClearFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.ClearFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public class ClearFilter extends AbstractPixelwiseFilter
Sets every pixel in an image to a single ARGB value. The new value is not mixed or painted onto the destination image, but set explicitly. To apply a solid color without disturbing the alpha channel, use aColorOverlayFilter
.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 ClearFilter()
Creates a filter that fills in 0x00000000.ClearFilter(int argb)
Creates a filter that fills in the specified ARGB value.ClearFilter(java.awt.Color c)
Creates a filter that uses the ARGB value specified by aColor
instance.
-
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.int
getColorRGB()
Returns the current fill colour as an ARGB value.void
setColorRGB(int argb)
Sets the current fill colour from an ARGB value.-
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
-
-
-
-
Constructor Detail
-
ClearFilter
public ClearFilter()
Creates a filter that fills in 0x00000000.
-
ClearFilter
public ClearFilter(int argb)
Creates a filter that fills in the specified ARGB value.- Parameters:
argb
-
-
ClearFilter
public ClearFilter(java.awt.Color c)
Creates a filter that uses the ARGB value specified by aColor
instance.- Parameters:
c
- the color to obtain an ARGB value from
-
-
Method Detail
-
getColorRGB
public int getColorRGB()
Returns the current fill colour as an ARGB value. This can be converted to aColor
, if required, using code like the following:new Color( this.getColorRGB(), true )
.- Returns:
- the ARGB (sRGB) value of the fill colour
-
setColorRGB
public void setColorRGB(int argb)
Sets the current fill colour from an ARGB value.- Parameters:
argb
- the new colour value in 0xAARRGGBB format
-
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
-
-