Package ca.cgjennings.graphics.filters
Class CheckeredScreenFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractRowwiseFilter
-
- ca.cgjennings.graphics.filters.CheckeredScreenFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public final class CheckeredScreenFilter extends AbstractRowwiseFilter
A filter that applies a checkerboard pattern to the source image by multiplying the alpha channel of alternating pixels by different values. pattern. This filter is intended for use with translucent images; if the destination image has no alpha channel, then the filter will have no effect.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 CheckeredScreenFilter()
Creates a new filter with an even alpha multiplier of 0 and an odd multiplier of 1.CheckeredScreenFilter(float evenAlpha, float oddAlpha)
Creates a new filter with a size of 1 and the specified even and odd alpha multipliers.CheckeredScreenFilter(int checkSize, float evenAlpha, float oddAlpha)
Creates a new filter with the specified size of 1 and the specified even and odd alpha multipliers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
createCompatibleDestImage(java.awt.image.BufferedImage source, java.awt.image.ColorModel destinationColorModel)
void
filterPixels(int y, int[] argb)
This method is called with a block of ARGB values to be filtered.int
getCheckSize()
Returns the size of the checkered squares, in pixels.float
getEvenAlpha()
Returns the alpha multiplier for even squares.float
getOddAlpha()
Returns the alpha multiplier for odd squares.void
setCheckSize(int size)
Sets the size of the checkered squares, in pixels.void
setEvenAlpha(float evenAlpha)
Sets the alpha multiplier for even squares.void
setOddAlpha(float oddAlpha)
Sets the alpha multiplier for odd squares.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractRowwiseFilter
filter, workFactor
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
Constructor Detail
-
CheckeredScreenFilter
public CheckeredScreenFilter()
Creates a new filter with an even alpha multiplier of 0 and an odd multiplier of 1. This will cause even pixels to become completely transparent while odd pixels retain the same alpha value.
-
CheckeredScreenFilter
public CheckeredScreenFilter(float evenAlpha, float oddAlpha)
Creates a new filter with a size of 1 and the specified even and odd alpha multipliers.- Parameters:
evenAlpha
- the alpha value for even squaresoddAlpha
- the alpha value for odd squares
-
CheckeredScreenFilter
public CheckeredScreenFilter(int checkSize, float evenAlpha, float oddAlpha)
Creates a new filter with the specified size of 1 and the specified even and odd alpha multipliers.- Parameters:
checkSize
- the size of the squares in the check pattern, in pixelsevenAlpha
- the alpha value for even squaresoddAlpha
- the alpha value for odd squares
-
-
Method Detail
-
getEvenAlpha
public float getEvenAlpha()
Returns the alpha multiplier for even squares.- Returns:
- the non-negative even multiplier
-
setEvenAlpha
public void setEvenAlpha(float evenAlpha)
Sets the alpha multiplier for even squares. The existing alpha value in even squares will be multiplied by this amount. Typical values are between 0 and 1, but values above 1 are allowed.- Parameters:
evenAlpha
- the even multiplier
-
getOddAlpha
public float getOddAlpha()
Returns the alpha multiplier for odd squares.- Returns:
- the non-negative odd multiplier
-
setOddAlpha
public void setOddAlpha(float oddAlpha)
Sets the alpha multiplier for odd squares. The existing alpha value in odd squares will be multiplied by this amount. Typical values are between 0 and 1, but values above 1 are allowed.- Parameters:
oddAlpha
- the even multiplier
-
getCheckSize
public int getCheckSize()
Returns the size of the checkered squares, in pixels.- Returns:
- the square size, a positive integer
-
setCheckSize
public void setCheckSize(int size)
Sets the size of the checkered squares, in pixels.- Parameters:
size
- the size of check pattern squares
-
createCompatibleDestImage
public java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage source, java.awt.image.ColorModel destinationColorModel)
Description copied from class:AbstractImageFilter
- Specified by:
createCompatibleDestImage
in interfacejava.awt.image.BufferedImageOp
- Overrides:
createCompatibleDestImage
in classAbstractImageFilter
-
filterPixels
public void filterPixels(int y, int[] argb)
Description copied from class:AbstractRowwiseFilter
This method is called with a block of ARGB values to be filtered. Subclasses should override this method to implement the actual filtering algorithm, replacing each pixel in the supplied array with its filtered value.- Specified by:
filterPixels
in classAbstractRowwiseFilter
-
-