public class ColorTintFilter extends AbstractFilter
A color tint filter can be used to mix a solid color to an image. The
result is an image tinted by the specified color. The force of the effect
can be controlled with the mixValue
, a number between 0.0 and
1.0 that can be seen as the percentage of the mix (0.0 does not affect the
source image and 1.0 replaces all the pixels by the solid color).
The color of the pixels in the resulting image is computed as follows:
cR = cS * (1 - mixValue) + cM * mixValue
Definition of the parameters:
cR
: color of the resulting pixelcS
: color of the source pixelcM
: the solid color to mix with the source imagemixValue
: strength of the mix, a value between 0.0 and 1.0Modifier and Type | Field and Description |
---|---|
private Color |
mixColor |
private float |
mixValue |
private int[] |
preMultipliedBlue |
private int[] |
preMultipliedGreen |
private int[] |
preMultipliedRed |
Constructor and Description |
---|
ColorTintFilter(Color mixColor,
float mixValue)
Creates a new color mixer filter.
|
Modifier and Type | Method and Description |
---|---|
BufferedImage |
filter(BufferedImage src,
BufferedImage dst) |
Color |
getMixColor()
Returns the solid mix color of this filter.
|
float |
getMixValue()
Returns the mix value of this filter.
|
private void |
mixColor(int[] pixels) |
createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
private final float mixValue
private int[] preMultipliedRed
private int[] preMultipliedGreen
private int[] preMultipliedBlue
public ColorTintFilter(Color mixColor, float mixValue)
Creates a new color mixer filter. The specified color will be used
to tint the source image, with a mixing strength defined by
mixValue
.
mixColor
- the solid color to mix with the source imagemixValue
- the strength of the mix, between 0.0 and 1.0; if the
specified value lies outside this range, it is clampedIllegalArgumentException
- if mixColor
is nullpublic float getMixValue()
Returns the mix value of this filter.
public Color getMixColor()
Returns the solid mix color of this filter.
public BufferedImage filter(BufferedImage src, BufferedImage dst)
filter
in interface BufferedImageOp
filter
in class AbstractFilter
private void mixColor(int[] pixels)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses