|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
cdox.util.image.CorrectorSlider
cdox.util.image.Contrast
This class highers or loweres the contrast of a BufferedImage. It uses a lookupTable to do so. To use this class you can call one of its two constructors. If you've designed your own Jslider classes you can use the constructor which takes a float-value. You than can use the setValue(float val) method to set the value to work with. And than call the filter method to filter the BufferedImage.If value == 0f the original (source-image) will be returned.
CorrectorSlider
Field Summary |
Fields inherited from class cdox.util.image.CorrectorSlider |
corSlider, imageCorrector, obs, sliderPane, value |
Constructor Summary | |
Contrast(float val)
This constructor creates a new Contrast Object with its initial-Value set to val. |
|
Contrast(java.util.Observer obs,
java.lang.String paneTitle)
This constructor creates a new Contrast Object, with a JSlider in a JPanel with a titledBorder set with the name paneTitle. |
Method Summary | |
java.awt.image.BufferedImage |
filter(java.awt.image.BufferedImage source,
java.awt.image.BufferedImage dest)
The actual filtering is done in this method defined in ImageCorrector. |
Methods inherited from class cdox.util.image.CorrectorSlider |
getRedrawnImage, getSliderPane, getValue, setValue, stateChanged |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cdox.util.image.ImageCorrector |
getValue |
Constructor Detail |
public Contrast(java.util.Observer obs, java.lang.String paneTitle)
obs
- The Observer to handle the BufferedImage.paneTitle
- the title of the titledBorder of the JPane surrounding the JSlider.CorrectorSlider.CorrectorSlider(Observer, String, int, int, int, int, int, boolean).
public Contrast(float val)
val
- the initial float value.CorrectorSlider.CorrectorSlider(float)
,
CorrectorSlider.setValue(float)
Method Detail |
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage source, java.awt.image.BufferedImage dest)
The actual filtering is done in this method defined in ImageCorrector. It uses a ShortLookupTable to make the contrast higher or lower for all the four chanels (Red, Green, Blue, Alpha). First the short-array is filled with the values, if the colornumber = i(0-255)>127, a hundreth*i-127*value (set by the JSlider or setValue(float val)) is added to the colornumber, causing it to be slightly higher / lower as the original color in the middle (80 - 170) and a lot higher/lower for the low/high colors (black (i=0), white(i=255)). After that this short-array is copied in a 2-dimensional-short-array, which represent the color-chanels. With BufferedImageOp a new LookupOp is done, which will be used to filter the source BufferedImage.
To make sure the source-BufferedImage can be "contrasted" the image is redrawn on a new BufferedImage which will be filtered. If the destination BufferedImage is null, a new BufferedImage is returned, if not it must have the same height and width as the source-BufferedImage. If not a new BufferedImage is returned.
filter
in interface ImageCorrector
source
- the BufferedImage to be filtered,dest
- the Destination-BufferedImage with the same height and width as Source,
and which may be null.
ImageCorrector
,
CorrectorSlider.setValue(float)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |