Package ca.cgjennings.graphics.filters
Class AlphaStrengthenFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.AlphaStrengthenFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
public final class AlphaStrengthenFilter extends AbstractPixelwiseFilter
A filter that increases the overall opacity of an image. The effect is similar to painting the source image overtop of itself a number of times equal to the filter strength.In-place filtering: This class supports in-place filtering (the source and destination images may be the same).
- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description AlphaStrengthenFilter()AlphaStrengthenFilter(int strength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)intfilterPixel(int argb)Returns the result of applying the filter to a single ARGB pixel value.voidfilterPixels(int[] argb, int start, int end)This method is called with a block of ARGB values to be filtered.intgetStrengthFactor()voidsetStrengthFactor(int strength)Sets the strength of the effect.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
filter, 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
-
-
-
-
Method Detail
-
getStrengthFactor
public int getStrengthFactor()
-
setStrengthFactor
public void setStrengthFactor(int strength)
Sets the strength of the effect. A strength of zero will result in the filter having no effect. Higher values will result in translucent pixels becoming successively more opaque, although completely transparent pixels (alpha == 0) are never affected.- Parameters:
strength-
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)- Specified by:
filterin interfacejava.awt.image.BufferedImageOp- Overrides:
filterin classAbstractPixelwiseFilter
-
filterPixels
public void filterPixels(int[] argb, int start, int end)Description copied from class:AbstractPixelwiseFilterThis 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:
filterPixelsin 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
-
filterPixel
public int filterPixel(int argb)
Description copied from class:AbstractPixelwiseFilterReturns the result of applying the filter to a single ARGB pixel value.The base class implementation creates a singleton array containing the pixel value and passes this to
AbstractPixelwiseFilter.filterPixels(int[], int, int), returning the result. Subclasses may wish override this to provide a more efficient implementation.- Overrides:
filterPixelin classAbstractPixelwiseFilter- Parameters:
argb- the pixel value to filter- Returns:
- the filtered pixel value
-
-