com.sixlegs.png
Interface SuggestedPalette


public interface SuggestedPalette

A suggested palette. Suggested palettes can be useful when the display device is not capable of displaying the full range of colors present in the image.

See Also:
PngImage.getProperty(java.lang.String), PngConstants.SUGGESTED_PALETTES

Method Summary
 int getFrequency(int index)
          Retrieve a sample frequency value.
 String getName()
          Returns palette name.
 void getSample(int index, short[] pixel)
          Retrieve a sample value.
 int getSampleCount()
          Returns the number of samples.
 int getSampleDepth()
          Returns the sample depth.
 

Method Detail

getName

String getName()
Returns palette name. This is any convenient name for referring to the palette. The name will be unique across all suggested palettes in the same image.


getSampleCount

int getSampleCount()
Returns the number of samples.


getSampleDepth

int getSampleDepth()
Returns the sample depth. This specifies the width of each color and alpha component of each sample in this palette.

Returns:
8 or 16

getSample

void getSample(int index,
               short[] pixel)
Retrieve a sample value. The red, green, blue, and alpha components of the sample at the given index are stored into the short array. Each component is of the depth specified by getSampleDepth. The color samples are not premultiplied by alpha. An alpha value of 0 means fully transparent.

Parameters:
index - the sample index
pixel - the array in which to store the sample components
Throws:
IndexOutOfBoundsException - if index < 0, index >= getSampleCount, or pixel.length is less than 4
NullPointerException - if pixel is null

getFrequency

int getFrequency(int index)
Retrieve a sample frequency value. The frequency value is proportional to the fraction of pixels in the image that are closest to that palette entry in RGBA space. The range of individual values will reasonably fill 0 to 65535. Entries appear in decreasing order of frequency.

Parameters:
index - the sample index