public class PaletteFactory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
COMPONENTS |
Constructor and Description |
---|
PaletteFactory() |
Modifier and Type | Method and Description |
---|---|
int |
countTransparentColors(java.awt.image.BufferedImage src) |
int |
countTrasparentColors(int[] rgbs) |
boolean |
hasTransparency(java.awt.image.BufferedImage src) |
boolean |
hasTransparency(java.awt.image.BufferedImage src,
int threshold) |
boolean |
isGrayscale(java.awt.image.BufferedImage src) |
Palette |
makeExactRgbPaletteFancy(java.awt.image.BufferedImage src)
Builds an exact complete opaque palette containing all the colors in
src ,
using an algorithm that is faster than makeExactRgbPaletteSimple(java.awt.image.BufferedImage, int) for large images
but uses 2 mebibytes of working memory. |
SimplePalette |
makeExactRgbPaletteSimple(java.awt.image.BufferedImage src,
int max)
Builds an exact complete opaque palette containing all the colors in
src ,
and fails by returning null if there are more than max colors necessary to do this. |
Palette |
makeQuantizedRgbaPalette(java.awt.image.BufferedImage src,
boolean transparent,
int max)
Builds an inexact possibly translucent palette of at most
max colors in src
using the traditional Median Cut algorithm. |
Palette |
makeQuantizedRgbPalette(java.awt.image.BufferedImage src,
int max)
Builds an inexact opaque palette of at most
max colors in src
using a variation of the Median Cut algorithm. |
public static final int COMPONENTS
public Palette makeExactRgbPaletteFancy(java.awt.image.BufferedImage src)
src
,
using an algorithm that is faster than makeExactRgbPaletteSimple(java.awt.image.BufferedImage, int) for large images
but uses 2 mebibytes of working memory. Treats all the colors as opaque.src
- the image whose palette to buildpublic Palette makeQuantizedRgbPalette(java.awt.image.BufferedImage src, int max)
max
colors in src
using a variation of the Median Cut algorithm. Accurate to 6 bits per component,
and works by splitting the color bounding box most heavily populated by colors
along the component which splits the colors in that box most evenly.src
- the image whose palette to buildmax
- the maximum number of colors the palette can containmax
colorspublic Palette makeQuantizedRgbaPalette(java.awt.image.BufferedImage src, boolean transparent, int max) throws ImageWriteException
max
colors in src
using the traditional Median Cut algorithm. Color bounding boxes are split along the
longest axis, with each step splitting the box. All bits in each component are used.
The Algorithm is slower and seems exact than makeQuantizedRgbPalette(BufferedImage, int).src
- the image whose palette to buildtransparent
- whether to consider the alpha valuesmax
- the maximum number of colors the palette can containmax
colorsImageWriteException
public SimplePalette makeExactRgbPaletteSimple(java.awt.image.BufferedImage src, int max)
src
,
and fails by returning null
if there are more than max
colors necessary to do this.src
- the image whose palette to buildmax
- the maximum number of colors the palette can containmax
or less colors, or null
if more than max
colors are necessarypublic boolean isGrayscale(java.awt.image.BufferedImage src)
public boolean hasTransparency(java.awt.image.BufferedImage src)
public boolean hasTransparency(java.awt.image.BufferedImage src, int threshold)
public int countTrasparentColors(int[] rgbs)
public int countTransparentColors(java.awt.image.BufferedImage src)
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"