org.geotools.image.palette
Class CustomPaletteBuilder

Object
  extended by CustomPaletteBuilder

public final class CustomPaletteBuilder
extends Object

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
protected  class CustomPaletteBuilder.ColorNode
          The node of color tree.
 
Field Summary
protected  int alphaThreshold
           
protected  int currLevel
           
protected  int currSize
           
static int DEFAULT_ALPHA_TH
          Default value for the threshold to decide whether a pixel is opaque (>=) or transparent (<).
protected  int maxLevel
          maximum of tree depth
protected  int maxNodes
           
protected  int numBands
           
protected  int numNodes
           
protected  CustomPaletteBuilder.ColorNode[] palette
           
protected  CustomPaletteBuilder.ColorNode[] reduceList
           
protected  int requiredSize
           
protected  CustomPaletteBuilder.ColorNode root
           
protected  RenderedImage src
           
protected  ColorModel srcColorModel
           
protected  int subsampleX
           
protected  int subsampley
           
protected  CustomPaletteBuilder.ColorNode transColor
           
protected  int transparency
           
 
Constructor Summary
CustomPaletteBuilder(RenderedImage src)
           
CustomPaletteBuilder(RenderedImage src, int size, int subsx, int subsy, int alpha_th)
           
 
Method Summary
 CustomPaletteBuilder 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.
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 freeTree(CustomPaletteBuilder.ColorNode aNode)
           
protected  int getBranchIndex(int[] rgba, int aLevel)
           
 IndexColorModel getIndexColorModel()
           
 RenderedImage getIndexedImage()
           
protected  CustomPaletteBuilder.ColorNode insertNode(CustomPaletteBuilder.ColorNode aNode, int[] rgba, int aLevel)
           
protected  void reduceTree()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ALPHA_TH

public static final int DEFAULT_ALPHA_TH
Default value for the threshold to decide whether a pixel is opaque (>=) or transparent (<). Default is 1 to try to preserve antialising

See Also:
Constant Field Values

maxLevel

protected int maxLevel
maximum of tree depth


src

protected RenderedImage src

srcColorModel

protected ColorModel srcColorModel

requiredSize

protected int requiredSize

root

protected CustomPaletteBuilder.ColorNode root

numNodes

protected int numNodes

maxNodes

protected int maxNodes

currLevel

protected int currLevel

currSize

protected int currSize

reduceList

protected CustomPaletteBuilder.ColorNode[] reduceList

palette

protected CustomPaletteBuilder.ColorNode[] palette

transparency

protected int transparency

transColor

protected CustomPaletteBuilder.ColorNode transColor

subsampleX

protected int subsampleX

subsampley

protected int subsampley

numBands

protected int numBands

alphaThreshold

protected int alphaThreshold
Constructor Detail

CustomPaletteBuilder

public CustomPaletteBuilder(RenderedImage src)

CustomPaletteBuilder

public CustomPaletteBuilder(RenderedImage src,
                            int size,
                            int subsx,
                            int subsy,
                            int alpha_th)
Method Detail

canCreatePalette

public static boolean canCreatePalette(ImageTypeSpecifier type)
Returns true if PaletteBuilder is able to create palette for given image type.

Parameters:
type - an instance of ImageTypeSpecifier to be indexed.
Returns:
true if the PaletteBuilder is likely to be able to create palette for this image type.
Throws:
IllegalArgumentException - if type is null.

canCreatePalette

public static boolean canCreatePalette(RenderedImage image)
Returns true if PaletteBuilder is able to create palette for given rendered image.

Parameters:
image - an instance of RenderedImage to be indexed.
Returns:
true if the PaletteBuilder is likely to be able to create palette for this image type.
Throws:
IllegalArgumentException - if image is null.

getIndexedImage

public RenderedImage getIndexedImage()

findColorIndex

protected int findColorIndex(CustomPaletteBuilder.ColorNode aNode,
                             int[] rgba,
                             int transpBand)

buildPalette

public CustomPaletteBuilder buildPalette()

insertNode

protected CustomPaletteBuilder.ColorNode insertNode(CustomPaletteBuilder.ColorNode aNode,
                                                    int[] rgba,
                                                    int aLevel)

getIndexColorModel

public IndexColorModel 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

protected CustomPaletteBuilder.ColorNode freeTree(CustomPaletteBuilder.ColorNode aNode)

findNearestColorIndex

public int findNearestColorIndex(int[] rgba,
                                 int transparentBand)


Copyright © 1996-2009 Geotools. All Rights Reserved.