PaletteData

Instances of this class describe the color data used by an image. <p> Depending on the depth of the image, the PaletteData can take one of two forms, indicated by the isDirect field: </p> <dl> <dt> <em>isDirect is false</em> </dt> <dd> If isDirect is <code>false</code>, this palette is an indexed palette which maps pixel values to RGBs. The actual RGB values may be retrieved by using the getRGBs() method. </dd> <dt> <em>isDirect is true</em> </dt> <dd> If isDirect is <code>true</code>, this palette is a direct color palette. Instead of containing RGB values, it contains red, green and blue mask and shift information which indicates how the color components may be extracted from a given pixel. This means that the RGB value is actually encoded in the pixel value. <p> In this case, the shift data is the number of bits required to shift the RGB value to the left in order to align the high bit of the corresponding mask with the high bit of the first byte. This number may be negative, so care must be taken when shifting. For example, with a red mask of 0xFF0000, the red shift would be -16. With a red mask of 0x1F, the red shift would be 3. </p> </dd> </dl>

@see Image @see RGB @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(RGB[] colors)

Constructs a new indexed palette given an array of RGB values.

this
this(int redMask, int greenMask, int blueMask)

Constructs a new direct palette given the red, green and blue masks.

Members

Functions

getPixel
int getPixel(RGB rgb)

Returns the pixel value corresponding to the given <code>RGB</code>.

getRGB
RGB getRGB(int pixel)

Returns an <code>RGB</code> corresponding to the given pixel value.

getRGBs
RGB[] getRGBs()

Returns all the RGB values in the receiver if it is an indexed palette, or null if it is a direct palette.

shiftForMask
int shiftForMask(int mask)

Computes the shift value for a given mask.

Variables

blueMask
int blueMask;

the blue mask for a direct palette

blueShift
int blueShift;

the blue shift for a direct palette

colors
RGB[] colors;

the RGB values for an indexed palette, where the indices of the array correspond to pixel values

greenMask
int greenMask;

the green mask for a direct palette

greenShift
int greenShift;

the green shift for a direct palette

isDirect
bool isDirect;

true if the receiver is a direct palette, and false otherwise

redMask
int redMask;

the red mask for a direct palette

redShift
int redShift;

the red shift for a direct palette

Meta