com.jhlabs.image
Interface Quantizer
- OctTreeQuantizer
public interface Quantizer
The interface for an image quantizer. The addColor method is called (repeatedly
if necessary) with all the image pixels. A color table can then be returned by
calling the buildColorTable method.
void | addPixels(int[] pixels, int offset, int count) - Add pixels to the quantizer.
|
int[] | buildColorTable() - Build a color table from the added pixels.
|
int | getIndexForColor(int rgb) - Using the previously-built color table, return the index into that table for a pixel.
|
void | setup(int numColors) - Initialize the quantizer.
|
addPixels
public void addPixels(int[] pixels,
int offset,
int count)
Add pixels to the quantizer.
pixels
- the array of ARGB pixelsoffset
- the offset into the arraycount
- the count of pixels
buildColorTable
public int[] buildColorTable()
Build a color table from the added pixels.
- an array of ARGB pixels representing a color table
getIndexForColor
public int getIndexForColor(int rgb)
Using the previously-built color table, return the index into that table for a pixel.
This is guaranteed to return a valid index - returning the index of a color closer
to that requested if necessary.
- the pixel's index in the color table
setup
public void setup(int numColors)
Initialize the quantizer. This should be called before adding any pixels.
numColors
- the number of colors we're quantizing to.