Package org.eclipse.swt.graphics
Class PaletteData
java.lang.Object
org.eclipse.swt.graphics.PaletteData
Instances of this class describe the color data used by an image.
 
Depending on the depth of the image, the PaletteData can take one of two forms, indicated by the isDirect field:
- isDirect is false
- 
 If isDirect is false, this palette is an indexed palette which maps pixel values to RGBs. The actual RGB values may be retrieved by using the getRGBs() method.
- isDirect is true
- 
 If isDirect is true, 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.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. 
- 
Field SummaryFieldsModifier and TypeFieldDescriptionintthe blue mask for a direct paletteintthe blue shift for a direct paletteRGB[]the RGB values for an indexed palette, where the indices of the array correspond to pixel valuesintthe green mask for a direct paletteintthe green shift for a direct palettebooleantrue if the receiver is a direct palette, and false otherwiseintthe red mask for a direct paletteintthe red shift for a direct palette
- 
Constructor SummaryConstructorsConstructorDescriptionPaletteData(int redMask, int greenMask, int blueMask) Constructs a new direct palette given the red, green and blue masks.PaletteData(RGB... colors) Constructs a new indexed palette given an array of RGB values.
- 
Method Summary
- 
Field Details- 
isDirectpublic boolean isDirecttrue if the receiver is a direct palette, and false otherwise
- 
colorsthe RGB values for an indexed palette, where the indices of the array correspond to pixel values
- 
redMaskpublic int redMaskthe red mask for a direct palette
- 
greenMaskpublic int greenMaskthe green mask for a direct palette
- 
blueMaskpublic int blueMaskthe blue mask for a direct palette
- 
redShiftpublic int redShiftthe red shift for a direct palette
- 
greenShiftpublic int greenShiftthe green shift for a direct palette
- 
blueShiftpublic int blueShiftthe blue shift for a direct palette
 
- 
- 
Constructor Details- 
PaletteDataConstructs a new indexed palette given an array of RGB values.- Parameters:
- colors- the array of- RGBs for the palette
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the argument is null
 
 
- 
PaletteDatapublic PaletteData(int redMask, int greenMask, int blueMask) Constructs a new direct palette given the red, green and blue masks.- Parameters:
- redMask- the red mask
- greenMask- the green mask
- blueMask- the blue mask
 
 
- 
- 
Method Details- 
getPixelReturns the pixel value corresponding to the givenRGB.- Parameters:
- rgb- the RGB to get the pixel value for
- Returns:
- the pixel value for the given RGB
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the argument is null
- ERROR_INVALID_ARGUMENT - if the RGB is not found in the palette
 
 
- 
getRGBReturns anRGBcorresponding to the given pixel value.- Parameters:
- pixel- the pixel to get the RGB value for
- Returns:
- the RGB value for the given pixel
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the argument is null
- ERROR_INVALID_ARGUMENT - if the pixel does not exist in the palette
 
 
- 
getRGBsReturns all the RGB values in the receiver if it is an indexed palette, or null if it is a direct palette.- Returns:
- the RGBs for the receiver or null
 
 
-