Package org.geotools.image.palette
Class CustomPaletteBuilder
Object
CustomPaletteBuilder
This class implements the octree quantization method as it is described in the "Graphics Gems" (ISBN 0-12-286166-3,
Chapter 4, pages 297-293)
- Author:
- Simone Giannecchini - GeoSolutions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
The node of color tree. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected int
protected int
static final int
Default value for the threshold to decide whether a pixel is opaque (>=) or transparent (<).protected int
maximum of tree depthprotected int
protected int
protected int
protected CustomPaletteBuilder.ColorNode[]
protected CustomPaletteBuilder.ColorNode[]
protected int
protected CustomPaletteBuilder.ColorNode
protected RenderedImage
protected ColorModel
protected int
protected int
protected CustomPaletteBuilder.ColorNode
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionCustomPaletteBuilder
(RenderedImage src, int size, int subsx, int subsy, int alpha_th) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canCreatePalette
(RenderedImage image) Returnstrue
if PaletteBuilder is able to create palette for given rendered image.static boolean
Returnstrue
if PaletteBuilder is able to create palette for given image type.protected int
findColorIndex
(CustomPaletteBuilder.ColorNode aNode, int[] rgba, int transpBand) int
findNearestColorIndex
(int[] rgba, int transparentBand) protected int
findPaletteEntry
(CustomPaletteBuilder.ColorNode aNode, int index, byte[] red, byte[] green, byte[] blue) protected CustomPaletteBuilder.ColorNode
protected int
getBranchIndex
(int[] rgba, int aLevel) protected CustomPaletteBuilder.ColorNode
insertNode
(CustomPaletteBuilder.ColorNode aNode, int[] rgba, int aLevel) protected void
-
Field Details
-
DEFAULT_ALPHA_TH
public static final int DEFAULT_ALPHA_THDefault value for the threshold to decide whether a pixel is opaque (>=) or transparent (<). Default is 1 to try to preserve antialising- See Also:
-
maxLevel
protected int maxLevelmaximum of tree depth -
src
-
srcColorModel
-
requiredSize
protected int requiredSize -
root
-
numNodes
protected int numNodes -
maxNodes
protected int maxNodes -
currLevel
protected int currLevel -
currSize
protected int currSize -
reduceList
-
palette
-
transparency
protected int transparency -
transColor
-
subsampleX
protected int subsampleX -
subsampley
protected int subsampley -
numBands
protected int numBands -
alphaThreshold
protected int alphaThreshold
-
-
Constructor Details
-
CustomPaletteBuilder
-
CustomPaletteBuilder
-
-
Method Details
-
canCreatePalette
Returnstrue
if PaletteBuilder is able to create palette for given image type.- Parameters:
type
- an instance ofImageTypeSpecifier
to be indexed.- Returns:
true
if thePaletteBuilder
is likely to be able to create palette for this image type.- Throws:
IllegalArgumentException
- iftype
isnull
.
-
canCreatePalette
Returnstrue
if PaletteBuilder is able to create palette for given rendered image.- Parameters:
image
- an instance ofRenderedImage
to be indexed.- Returns:
true
if thePaletteBuilder
is likely to be able to create palette for this image type.- Throws:
IllegalArgumentException
- ifimage
isnull
.
-
getIndexedImage
-
findColorIndex
-
buildPalette
-
insertNode
protected CustomPaletteBuilder.ColorNode insertNode(CustomPaletteBuilder.ColorNode aNode, int[] rgba, int aLevel) -
getIndexColorModel
-
findPaletteEntry
protected int findPaletteEntry(CustomPaletteBuilder.ColorNode aNode, int index, byte[] red, byte[] green, byte[] blue) -
getBranchIndex
protected int getBranchIndex(int[] rgba, int aLevel) -
reduceTree
protected void reduceTree() -
freeTree
-
findNearestColorIndex
public int findNearestColorIndex(int[] rgba, int transparentBand)
-