Package ca.cgjennings.graphics.filters
Class BrightnessContrastFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractPixelwiseFilter
-
- ca.cgjennings.graphics.filters.AbstractFunctionFilter
-
- ca.cgjennings.graphics.filters.BrightnessContrastFilter
-
- All Implemented Interfaces:
Fn,java.awt.image.BufferedImageOp
public class BrightnessContrastFilter extends AbstractFunctionFilter
An image filter that adjusts the brightness and contrast of an image. The brightness and contrast adjustments are specified as values in the range -1 to +1 (inclusive). A value of 0 indicates no change, while values greater or less than 0 increase or decrease (respectively) the brightness or contrast.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 BrightnessContrastFilter()Creates a new filter with default brightness and contrast settings of 0, resulting in no change.BrightnessContrastFilter(double brightness, double contrast)Creates a new filter with the requested brightness and contrast adjustments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublef(double x)A transfer function for the current brightness and contrast settings.doublegetBrightness()Returns the current brightness adjustment setting, between -1 and 1 inclusive.doublegetContrast()Returns the current contrast adjustment setting, between -1 and 1 inclusive.voidsetBrightness(double brightness)Sets the current brightness adjustment setting, between -1 and 1 inclusive.voidsetContrast(double contrast)Sets the current contrast adjustment setting, between -1 and 1 inclusive.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractFunctionFilter
filterPixels, functionChanged
-
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
-
BrightnessContrastFilter
public BrightnessContrastFilter()
Creates a new filter with default brightness and contrast settings of 0, resulting in no change.
-
BrightnessContrastFilter
public BrightnessContrastFilter(double brightness, double contrast)Creates a new filter with the requested brightness and contrast adjustments.- Parameters:
brightness- the brightness adjustment factor to applycontrast- the contrast adjustment factor to apply- Throws:
java.lang.IllegalArgumentException- ifbrightnessorcontrastare not in the range -1 to 1 inclusive
-
-
Method Detail
-
getBrightness
public double getBrightness()
Returns the current brightness adjustment setting, between -1 and 1 inclusive.- Returns:
- the brightness adjustment setting
-
setBrightness
public void setBrightness(double brightness)
Sets the current brightness adjustment setting, between -1 and 1 inclusive. A value of 0 results in no brightness change, while negative and positive values decrease and increase brightness, respectively.- Parameters:
brightness- the brightness adjustment to apply to filtered images
-
getContrast
public double getContrast()
Returns the current contrast adjustment setting, between -1 and 1 inclusive.- Returns:
- the contrast adjustment setting
-
setContrast
public void setContrast(double contrast)
Sets the current contrast adjustment setting, between -1 and 1 inclusive. A value of 0 results in no contrast change, while negative and positive values decrease and increase contrast, respectively.- Parameters:
contrast- the contrast adjustment to apply to filtered images
-
f
public double f(double x)
A transfer function for the current brightness and contrast settings. SeeAbstractFunctionFilter.f(double).- Specified by:
fin interfaceFn- Specified by:
fin classAbstractFunctionFilter- Parameters:
x- the input value- Returns:
- the output value after applying the brightness and contrast adjustment
-
-