Class PNGEncodeParam.Palette
- java.lang.Object
-
- org.apache.batik.ext.awt.image.codec.png.PNGEncodeParam
-
- org.apache.batik.ext.awt.image.codec.png.PNGEncodeParam.Palette
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ImageDecodeParam,ImageEncodeParam
- Enclosing class:
- PNGEncodeParam
public static class PNGEncodeParam.Palette extends PNGEncodeParam
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.batik.ext.awt.image.codec.png.PNGEncodeParam
PNGEncodeParam.Gray, PNGEncodeParam.Palette, PNGEncodeParam.RGB
-
-
Field Summary
Fields Modifier and Type Field Description private intbackgroundPaletteIndexprivate booleanbackgroundSetprivate int[]paletteprivate booleanpaletteSetprivate int[]transparency-
Fields inherited from class org.apache.batik.ext.awt.image.codec.png.PNGEncodeParam
bitDepth, bitDepthSet, chunkData, chunkType, INTENT_ABSOLUTE, INTENT_PERCEPTUAL, INTENT_RELATIVE, INTENT_SATURATION, PNG_FILTER_AVERAGE, PNG_FILTER_NONE, PNG_FILTER_PAETH, PNG_FILTER_SUB, PNG_FILTER_UP, transparencySet
-
-
Constructor Summary
Constructors Constructor Description Palette()Constructs an instance ofPNGEncodeParam.Palette.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBackgroundPaletteIndex()Returns the palette index of the suggested background color.int[]getPalette()Returns the current RGB palette.byte[]getPaletteTransparency()Returns the alpha values associated with each palette entry.booleanisBackgroundSet()Returns true if a 'bKGD' chunk will be output.booleanisPaletteSet()Returns true if a 'PLTE' chunk will be output.voidsetBackgroundPaletteIndex(int index)Sets the palette index of the suggested background color.voidsetBitDepth(int bitDepth)Sets the desired bit depth for a palette image.voidsetPalette(int[] rgb)Sets the RGB palette of the image to be encoded.voidsetPaletteTransparency(byte[] alpha)Sets the alpha values associated with each palette entry.voidunsetBackground()Suppresses the 'bKGD' chunk from being output.voidunsetPalette()Suppresses the 'PLTE' chunk from being output.-
Methods inherited from class org.apache.batik.ext.awt.image.codec.png.PNGEncodeParam
addPrivateChunk, filterRow, getBitDepth, getChromaticity, getCompressedText, getDefaultEncodeParam, getGamma, getICCProfileData, getInterlacing, getModificationTime, getNumPrivateChunks, getPaletteHistogram, getPhysicalDimension, getPrivateChunkData, getPrivateChunkType, getSignificantBits, getSRGBIntent, getSuggestedPalette, getText, isChromaticitySet, isCompressedTextSet, isGammaSet, isICCProfileDataSet, isModificationTimeSet, isPaletteHistogramSet, isPhysicalDimensionSet, isSignificantBitsSet, isSRGBIntentSet, isSuggestedPaletteSet, isTextSet, isTransparencySet, paethPredictor, removeAllPrivateChunks, removeUnsafeToCopyPrivateChunks, setChromaticity, setChromaticity, setCompressedText, setGamma, setICCProfileData, setInterlacing, setModificationTime, setPaletteHistogram, setPhysicalDimension, setPhysicalDimension, setSignificantBits, setSRGBIntent, setSuggestedPalette, setText, unsetBitDepth, unsetChromaticity, unsetCompressedText, unsetGamma, unsetICCProfileData, unsetModificationTime, unsetPaletteHistogram, unsetPhysicalDimension, unsetSignificantBits, unsetSRGBIntent, unsetSuggestedPalette, unsetText, unsetTransparency
-
-
-
-
Method Detail
-
unsetBackground
public void unsetBackground()
Suppresses the 'bKGD' chunk from being output.- Overrides:
unsetBackgroundin classPNGEncodeParam
-
isBackgroundSet
public boolean isBackgroundSet()
Returns true if a 'bKGD' chunk will be output.- Overrides:
isBackgroundSetin classPNGEncodeParam
-
setBitDepth
public void setBitDepth(int bitDepth)
Sets the desired bit depth for a palette image. The bit depth must be one of 1, 2, 4, or 8, or else anIllegalArgumentExceptionwill be thrown.- Specified by:
setBitDepthin classPNGEncodeParam
-
setPalette
public void setPalette(int[] rgb)
Sets the RGB palette of the image to be encoded. Thergbparameter contains alternating R, G, B values for each color index used in the image. The number of elements must be a multiple of 3 between 3 and 3*256.The 'PLTE' chunk will encode this information.
- Parameters:
rgb- An array ofints.
-
getPalette
public int[] getPalette()
Returns the current RGB palette.If the palette has not previously been set, or has been unset, an
IllegalStateExceptionwill be thrown.- Returns:
- An array of
ints. - Throws:
java.lang.IllegalStateException- if the palette is not set.
-
unsetPalette
public void unsetPalette()
Suppresses the 'PLTE' chunk from being output.
-
isPaletteSet
public boolean isPaletteSet()
Returns true if a 'PLTE' chunk will be output.
-
setBackgroundPaletteIndex
public void setBackgroundPaletteIndex(int index)
Sets the palette index of the suggested background color.The 'bKGD' chunk will encode this information.
-
getBackgroundPaletteIndex
public int getBackgroundPaletteIndex()
Returns the palette index of the suggested background color.If the background palette index has not previously been set, or has been unset, an
IllegalStateExceptionwill be thrown.- Throws:
java.lang.IllegalStateException- if the palette index is not set.
-
setPaletteTransparency
public void setPaletteTransparency(byte[] alpha)
Sets the alpha values associated with each palette entry. Thealphaparameter should have as many entries as there are RGB triples in the palette.The 'tRNS' chunk will encode this information.
-
getPaletteTransparency
public byte[] getPaletteTransparency()
Returns the alpha values associated with each palette entry.If the palette transparency has not previously been set, or has been unset, an
IllegalStateExceptionwill be thrown.- Throws:
java.lang.IllegalStateException- if the palette transparency is not set.
-
-