org.apache.batik.ext.awt.image.codec.png

Class PNGEncodeParam.Palette

public static class PNGEncodeParam.Palette extends PNGEncodeParam

Constructor Summary
Palette()
Constructs an instance of PNGEncodeParam.Palette.
Method Summary
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.

Constructor Detail

Palette

public Palette()
Constructs an instance of PNGEncodeParam.Palette.

Method Detail

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 IllegalStateException will be thrown.

Throws: IllegalStateException if the palette index is not set.

getPalette

public int[] getPalette()
Returns the current RGB palette.

If the palette has not previously been set, or has been unset, an IllegalStateException will be thrown.

Returns: An array of ints.

Throws: IllegalStateException if the palette is not set.

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 IllegalStateException will be thrown.

Throws: IllegalStateException if the palette transparency is not set.

isBackgroundSet

public boolean isBackgroundSet()
Returns true if a 'bKGD' chunk will be 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.

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 an IllegalArgumentException will be thrown.

setPalette

public void setPalette(int[] rgb)
Sets the RGB palette of the image to be encoded. The rgb parameter 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 of ints.

setPaletteTransparency

public void setPaletteTransparency(byte[] alpha)
Sets the alpha values associated with each palette entry. The alpha parameter should have as many entries as there are RGB triples in the palette.

The 'tRNS' chunk will encode this information.

unsetBackground

public void unsetBackground()
Suppresses the 'bKGD' chunk from being output.

unsetPalette

public void unsetPalette()
Suppresses the 'PLTE' chunk from being output.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.