public class PaletteBuilder extends 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 RenderedImage |
src |
protected ColorModel |
srcColorModel |
protected Raster |
srcRaster |
protected PaletteBuilder.ColorNode |
transColor |
protected int |
transparency |
Modifier | Constructor and Description |
---|---|
protected |
PaletteBuilder(RenderedImage src) |
protected |
PaletteBuilder(RenderedImage src,
int size) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildPalette() |
static boolean |
canCreatePalette(ImageTypeSpecifier type)
Returns
true if PaletteBuilder is able to create
palette for given image type. |
static boolean |
canCreatePalette(RenderedImage image)
Returns
true if PaletteBuilder is able to create
palette for given rendered image. |
static IndexColorModel |
createIndexColorModel(RenderedImage img)
Creates an palette representing colors from given image
img . |
static RenderedImage |
createIndexedImage(RenderedImage src)
Creates an image representing given image
src using IndexColorModel |
protected int |
findColorIndex(PaletteBuilder.ColorNode aNode,
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(Color aColor,
int aLevel) |
protected IndexColorModel |
getIndexColorModel() |
protected RenderedImage |
getIndexedImage() |
private Color |
getSrcColor(int x,
int y) |
protected PaletteBuilder.ColorNode |
insertNode(PaletteBuilder.ColorNode aNode,
Color aColor,
int aLevel) |
protected void |
reduceTree() |
protected static final int MAXLEVEL
protected RenderedImage src
protected ColorModel srcColorModel
protected 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(RenderedImage src)
protected PaletteBuilder(RenderedImage src, int size)
public static RenderedImage createIndexedImage(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.
IllegalArgumentException
- if src
is
null
.UnsupportedOperationException
- if implemented method
is unable to create approximation of src
and canCreatePalette
returns false
.createIndexColorModel(RenderedImage)
,
canCreatePalette(RenderedImage)
public static IndexColorModel createIndexColorModel(RenderedImage img)
img
. If number of colors in the given image exceeds
maximum palette size closest colors would be merged.IllegalArgumentException
- if img
is
null
.UnsupportedOperationException
- if implemented method
is unable to create approximation of img
and canCreatePalette
returns false
.createIndexedImage(RenderedImage)
,
canCreatePalette(RenderedImage)
public static boolean canCreatePalette(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.IllegalArgumentException
- if type
is null
.public static boolean canCreatePalette(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.IllegalArgumentException
- if image
is null
.protected RenderedImage getIndexedImage()
private Color getSrcColor(int x, int y)
protected int findColorIndex(PaletteBuilder.ColorNode aNode, Color aColor)
protected void buildPalette()
protected PaletteBuilder.ColorNode insertNode(PaletteBuilder.ColorNode aNode, Color aColor, int aLevel)
protected IndexColorModel getIndexColorModel()
protected int findPaletteEntry(PaletteBuilder.ColorNode aNode, int index, byte[] red, byte[] green, byte[] blue)
protected int getBranchIndex(Color aColor, int aLevel)
protected void reduceTree()
protected PaletteBuilder.ColorNode freeTree(PaletteBuilder.ColorNode aNode)
Copyright © 2017 Open Microscopy Environment