public class PaletteBuilder
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected class |
PaletteBuilder.ColorNode
The node of color tree.
|
Modifier and Type | Field and Description |
---|---|
protected int |
currLevel |
protected int |
currSize |
protected static int |
MAXLEVEL
maximum of tree depth
|
protected int |
maxNodes |
protected int |
numNodes |
protected PaletteBuilder.ColorNode[] |
palette |
protected PaletteBuilder.ColorNode[] |
reduceList |
protected int |
requiredSize |
protected PaletteBuilder.ColorNode |
root |
protected java.awt.image.RenderedImage |
src |
protected java.awt.image.ColorModel |
srcColorModel |
protected java.awt.image.Raster |
srcRaster |
protected PaletteBuilder.ColorNode |
transColor |
protected int |
transparency |
Modifier | Constructor and Description |
---|---|
protected |
PaletteBuilder(java.awt.image.RenderedImage src) |
protected |
PaletteBuilder(java.awt.image.RenderedImage src,
int size) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildPalette() |
static boolean |
canCreatePalette(javax.imageio.ImageTypeSpecifier type)
Returns
true if PaletteBuilder is able to create
palette for given image type. |
static boolean |
canCreatePalette(java.awt.image.RenderedImage image)
Returns
true if PaletteBuilder is able to create
palette for given rendered image. |
static java.awt.image.IndexColorModel |
createIndexColorModel(java.awt.image.RenderedImage img)
Creates an palette representing colors from given image
img . |
static java.awt.image.RenderedImage |
createIndexedImage(java.awt.image.RenderedImage src)
Creates an image representing given image
src using IndexColorModel |
protected int |
findColorIndex(PaletteBuilder.ColorNode aNode,
java.awt.Color aColor) |
protected int |
findPaletteEntry(PaletteBuilder.ColorNode aNode,
int index,
byte[] red,
byte[] green,
byte[] blue) |
protected PaletteBuilder.ColorNode |
freeTree(PaletteBuilder.ColorNode aNode) |
protected int |
getBranchIndex(java.awt.Color aColor,
int aLevel) |
protected java.awt.image.IndexColorModel |
getIndexColorModel() |
protected java.awt.image.RenderedImage |
getIndexedImage() |
protected PaletteBuilder.ColorNode |
insertNode(PaletteBuilder.ColorNode aNode,
java.awt.Color aColor,
int aLevel) |
protected void |
reduceTree() |
protected static final int MAXLEVEL
protected java.awt.image.RenderedImage src
protected java.awt.image.ColorModel srcColorModel
protected java.awt.image.Raster srcRaster
protected int requiredSize
protected PaletteBuilder.ColorNode root
protected int numNodes
protected int maxNodes
protected int currLevel
protected int currSize
protected PaletteBuilder.ColorNode[] reduceList
protected PaletteBuilder.ColorNode[] palette
protected int transparency
protected PaletteBuilder.ColorNode transColor
protected PaletteBuilder(java.awt.image.RenderedImage src)
protected PaletteBuilder(java.awt.image.RenderedImage src, int size)
public static java.awt.image.RenderedImage createIndexedImage(java.awt.image.RenderedImage src)
src
using IndexColorModel.
Lossless conversion is not always possible (e.g. if number
of colors in the given image exceeds maximum palette size).
Result image then is an approximation constructed by octree
quantization method.
java.lang.IllegalArgumentException
- if src
is
null
.java.lang.UnsupportedOperationException
- if implemented method
is unable to create approximation of src
and canCreatePalette
returns false
.createIndexColorModel
,
canCreatePalette
public static java.awt.image.IndexColorModel createIndexColorModel(java.awt.image.RenderedImage img)
img
. If number of colors in the given image exceeds
maximum palette size closest colors would be merged.java.lang.IllegalArgumentException
- if img
is
null
.java.lang.UnsupportedOperationException
- if implemented method
is unable to create approximation of img
and canCreatePalette
returns false
.createIndexedImage
,
canCreatePalette
public static boolean canCreatePalette(javax.imageio.ImageTypeSpecifier type)
true
if PaletteBuilder is able to create
palette for given image type.type
- an instance of ImageTypeSpecifier
to be
indexed.true
if the PaletteBuilder
is likely to be able to create palette for this image type.java.lang.IllegalArgumentException
- if type
is null
.public static boolean canCreatePalette(java.awt.image.RenderedImage image)
true
if PaletteBuilder is able to create
palette for given rendered image.image
- an instance of RenderedImage
to be
indexed.true
if the PaletteBuilder
is likely to be able to create palette for this image type.java.lang.IllegalArgumentException
- if image
is null
.protected java.awt.image.RenderedImage getIndexedImage()
protected int findColorIndex(PaletteBuilder.ColorNode aNode, java.awt.Color aColor)
protected void buildPalette()
protected PaletteBuilder.ColorNode insertNode(PaletteBuilder.ColorNode aNode, java.awt.Color aColor, int aLevel)
protected java.awt.image.IndexColorModel getIndexColorModel()
protected int findPaletteEntry(PaletteBuilder.ColorNode aNode, int index, byte[] red, byte[] green, byte[] blue)
protected int getBranchIndex(java.awt.Color aColor, int aLevel)
protected void reduceTree()
protected PaletteBuilder.ColorNode freeTree(PaletteBuilder.ColorNode aNode)
Copyright © 2014 Open Microscopy Environment