|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdeadbeef.Tools.QuantizeFilter
public class QuantizeFilter
A filter which quantizes an image to a set number of colors - useful for producing images which are to be encoded using an index color model. The filter can perform Floyd-Steinberg error-diffusion dithering if required. At present, the quantization is done using an octtree algorithm but I eventually hope to add more quantization methods such as median cut. Note: at present, the filter produces an image which uses the RGB color model (because the application it was written for required it). I hope to extend it to produce an IndexColorModel by request.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constructor Summary | |
---|---|
QuantizeFilter()
|
Method Summary | |
---|---|
boolean |
getDither()
Return the dithering setting |
int |
getNumColors()
Get the number of colors to quantize to. |
boolean |
getSerpentine()
Return the serpentine setting |
int[] |
quantize(int[] inPixels,
byte[] outPixels,
int width,
int height,
int numColors,
boolean dither,
boolean serpentine)
Quantize picture |
void |
setDither(boolean dither)
Set whether to use dithering or not. |
void |
setNumColors(int numColors)
Set the number of colors to quantize to. |
void |
setSerpentine(boolean serpentine)
Set whether to use a serpentine pattern for return or not. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QuantizeFilter()
Method Detail |
---|
public void setNumColors(int numColors)
numColors
- Number of colors. The default is 256.public int getNumColors()
public void setDither(boolean dither)
dither
- True to use ditheringpublic boolean getDither()
public void setSerpentine(boolean serpentine)
serpentine
- True to use serpentine patternpublic boolean getSerpentine()
public int[] quantize(int[] inPixels, byte[] outPixels, int width, int height, int numColors, boolean dither, boolean serpentine)
inPixels
- Array of RGBA pixels to quantizeoutPixels
- Array with quantized palette entrieswidth
- Width of imageheight
- Height of imagenumColors
- Number of colors useddither
- Use dithering?serpentine
- Use serpentine for dithering?
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |