|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.ColorReducer
com.davisor.graphics.DynamicColorReducer
com.davisor.graphics.OctreeColorReducer
OctreeColorReducer implements a fast high-quality color palette size reducers. As the name suggests, this class uses a well known octree color quantization algorithm. The algorithm and it's many variations have been widely published in basic computer graphics literature.
This particular implementation uses various speed optimizations that produce slightly less optimal color quantizations, but significantly faster than a stricly optimal solution would. The current implementation works also only with RGB color models with 8 bits per component, and with BITMASK transparency. In particular, colors with the alpha -value above a 0x80 threshold are considered fully opaque, other fully transparent.
This implementation supports also color component quantization, by
allowing a color bit mask to be applied on colors before they are
inserted into the tree. Please see addColor(int) for more
information.
| Nested Class Summary | |
protected class |
OctreeColorReducer.ColorNode
ColorNode represents one OctreeColorReducer.ColorTree color node. |
protected class |
OctreeColorReducer.ColorTree
ColorTree implements a color octree that orginizes colors into a hierarchy of similar colors. |
| Field Summary | |
protected OctreeColorReducer.ColorTree |
M_tree
Current color tree. |
| Fields inherited from class com.davisor.graphics.ColorReducer |
COLORMASK_12BITS, COLORMASK_18BITS, COLORMASK_24BITS, COLORMASK_6BITS, M_colorMask |
| Constructor Summary | |
OctreeColorReducer(int maxColors)
Creates a new color reducer. |
|
OctreeColorReducer(int maxColors,
int colorMask)
Creates a new color reducer with given color mask. |
|
OctreeColorReducer(int maxColors,
int colorMask,
java.awt.image.RenderedImage image)
Creates a new color reducer with given color mask, then applies the colors in given image to it. |
|
OctreeColorReducer(int maxColors,
java.awt.image.RenderedImage image)
Creates a new color reducer, then applies the colors in given image to it. |
|
| Method Summary | |
void |
addColor(int argb)
Adds a ARGB color into the reducer source color set. |
int |
getColor(int argb)
Gets the replacement color value from the current color tree for the given color. |
int |
getColorCount()
Gets the number of different colors, including the fully transparent color, if defined. |
int[] |
getColorsFromTree()
Simple helper method to get access to the tree colors |
int |
getIndex(int argb)
Gets the replacement color index from the current color tree for the given color. |
java.awt.image.IndexColorModel |
getPalette()
Gets current reduced color palette. |
| Methods inherited from class com.davisor.graphics.DynamicColorReducer |
addColors |
| Methods inherited from class com.davisor.graphics.ColorReducer |
createCompatibleDestImage, filter, getBounds2D, getColor, getColorBits, getColorMask, getColorMask, getColorMask, getPoint2D, getRenderingHints, setAlphaBits, setAlphaMask, setBlueBits, setBlueMask, setColorBits, setColorMask, setGreenBits, setGreenMask, setRedBits, setRedMask |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected OctreeColorReducer.ColorTree M_tree
| Constructor Detail |
public OctreeColorReducer(int maxColors)
maxColors - the number of colors this reducer reduces colors to
public OctreeColorReducer(int maxColors,
int colorMask)
maxColors - the number of colors this reducer reduces colors tocolorMask - color quantization maskColorReducer.setColorMask(int)
public OctreeColorReducer(int maxColors,
java.awt.image.RenderedImage image)
maxColors - the number of colors this reducer reduces colors toimage - image to scan colors fromDynamicColorReducer.addColors(java.awt.image.RenderedImage),
ColorReducer.setColorMask(int)
public OctreeColorReducer(int maxColors,
int colorMask,
java.awt.image.RenderedImage image)
maxColors - the number of colors this reducer reduces colors tocolorMask - color quantization maskimage - image to scan colors fromDynamicColorReducer.addColors(java.awt.image.RenderedImage),
ColorReducer.setColorMask(int)| Method Detail |
public int getColor(int argb)
Color palettes provide typically only limited set of transparent colors, as typical color palette contains only fully opaque colors, and only one fully transparent color, if even that. The transparency component of the returned palette color may therefore be significantly different that of the source color.
getColor in class ColorReducerargb - standard sRGB color value (with alpha)
addColor(int),
getIndex(int),
OctreeColorReducer.ColorTree.getColor(int)public int getIndex(int argb)
getPalette() method.
Color palettes provide typically only limited set of transparent colors, as typical color palette contains only fully opaque colors, and only one fully transparent color, if even that. The transparency component of the returned palette color may therefore be significantly different that of the source color.
getIndex in class ColorReducerargb - standard sRGB color value (with alpha)
java.lang.IllegalStateException - if the color tree has not been
assosiated with any color paletteaddColor(int),
getColor(int),
OctreeColorReducer.ColorTree.getIndex(int)public int[] getColorsFromTree()
public java.awt.image.IndexColorModel getPalette()
getPalette in class ColorReducerpublic void addColor(int argb)
It must also be noted that color masking is applied only once, just before a source color is being added into the color tree. The actual octal tree color tree algorithm will then work with full sRGB colorspace, with full 8 bits color components. The resulting reduced color tree may therefore have colors that contain color component bits masked out from the source colors.
Color masking adds another level of color quantization on top of the reduction provided by the Octree algorithm. Color component level masking is usefull in particular when colors are prepared for LCD displays that support less than 256 color component intensity levels.
addColor in class DynamicColorReducerargb - standard 32 bit ARGB color value to addgetColor(int),
getIndex(int),
ColorReducer.setColorMask(int),
OctreeColorReducer.ColorTree.addColor(int)public int getColorCount()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||