public class RGBA extends Object
The conversion is done in a number of static methods. This class is not supposed to be instantiated.
The method names of this class can be interpreted as follows.
If they contain
fromXYZ
(where XYZ is a pixel format type like Gray8, RGB24 etc.),
a conversion from another pixel format to RGBA is done.
If the names contains toXYZ
, a conversion from RGBA to that pixel
format will be performed.
Not all conversions are lossless or well-defined. If 48 bpp RGB truecolor is used as source, only the top eight bits of each 16 bit sample will be used (thus, the procedure is lossy). If RGBA data is to be converted to bilevel (black and white), the conversion is undefined if there are input RGBA pixels that are neither black nor white.
Modifier and Type | Field | Description |
---|---|---|
static int |
DEFAULT_ALPHA |
The default value for the alpha part of RGBA.
|
Modifier | Constructor | Description |
---|---|---|
private |
RGBA() |
Modifier and Type | Method | Description |
---|---|---|
static void |
convertFromGray16(short[] src,
int srcOffset,
int alpha,
int[] dest,
int destOffset,
int num) |
Convert a number of 16 bit grayscale pixels to RGBA type int pixels, adding the given
alpha value.
|
static void |
convertFromGray8(byte[] src,
int srcOffset,
int alpha,
int[] dest,
int destOffset,
int num) |
Convert a number of 8 bit grayscale pixels, shades of gray between 0 (for black)
and 255 (for white), given as bytes, to RGBA type int pixels, adding the given
alpha value.
|
static void |
convertFromPackedBilevel(byte[] src,
int srcOffset,
int alpha,
int[] dest,
int destOffset,
int num) |
Converts pixels from bilevel packed bytes to RGBA format.
|
static void |
convertFromPaletted8(byte[] src,
int srcOffset,
int alpha,
int[] red,
int[] green,
int[] blue,
int[] dest,
int destOffset,
int num) |
Converts a byte array of palette index values to an array of RGBA values,
using palette color data.
|
static void |
convertFromRGB24(byte[] srcRed,
int srcRedOffset,
byte[] srcGreen,
int srcGreenOffset,
byte[] srcBlue,
int srcBlueOffset,
int alpha,
int[] dest,
int destOffset,
int num) |
Converts 24 bit RGB truecolor data to RGBA int values.
|
static void |
convertFromRGB48(short[] srcRed,
int srcRedOffset,
short[] srcGreen,
int srcGreenOffset,
short[] srcBlue,
int srcBlueOffset,
int alpha,
int[] dest,
int destOffset,
int num) |
Converts 48 bit RGB truecolor data to RGBA int values, dropping the least
significant eight bits of each short sample.
|
public static final int DEFAULT_ALPHA
0xff000000
.public static void convertFromPackedBilevel(byte[] src, int srcOffset, int alpha, int[] dest, int destOffset, int num)
src
- the array with the packed bytessrcOffset
- the index of the first byte to be converted from srcalpha
- the alpha value to be used for the destination RGBA valuesdest
- the array where the destination RGBA pixels will be storeddestOffset
- the index of the first destination pixel in the dest array;
that array must be at least destOffset + ((num + 7) / 8) largenum
- the number of pixels (not bytes) to be convertedpublic static void convertFromGray8(byte[] src, int srcOffset, int alpha, int[] dest, int destOffset, int num)
src
- array with grayscale pixelssrcOffset
- index of first entry of src to be convertedalpha
- transparency value to be used in resulting RGBA array (only top eight bits can be set)dest
- array to store resulting RGBA pixelsdestOffset
- index of first entry in dest to be usednum
- number of pixels to be convertedpublic static void convertFromGray16(short[] src, int srcOffset, int alpha, int[] dest, int destOffset, int num)
src
- array with grayscale pixelssrcOffset
- index of first entry of src to be convertedalpha
- transparency value to be used in resulting RGBA array (only top eight bits can be set)dest
- array to store resulting RGBA pixelsdestOffset
- index of first entry in dest to be usednum
- number of pixels to be convertedpublic static void convertFromPaletted8(byte[] src, int srcOffset, int alpha, int[] red, int[] green, int[] blue, int[] dest, int destOffset, int num)
src
- the byte array with the palette index valuessrcOffset
- index of the first entry of src to be usedalpha
- transparency value to be used (only top eight bits should be set)red
- the red palette valuesgreen
- the green palette valuesblue
- the blue palette valuesdest
- the destination array to store the RGBA valuesdestOffset
- the first entry of dest to be usednum
- the number of pixels to be convertedpublic static void convertFromRGB24(byte[] srcRed, int srcRedOffset, byte[] srcGreen, int srcGreenOffset, byte[] srcBlue, int srcBlueOffset, int alpha, int[] dest, int destOffset, int num)
srcRed
- the red pixel valuessrcRedOffset
- the first entry of srcRed to be usedsrcGreen
- the green pixel valuessrcGreenOffset
- the first entry of srcGreen to be usedsrcBlue
- the blue pixel valuessrcBlueOffset
- the first entry of srcBlue to be usedalpha
- the transpancy value to be used in the destination RGBA array (only top 8 bits should be set)dest
- array to store RGBA pixel valuesdestOffset
- first entry of dest to be usednum
- number of pixels to be convertedpublic static void convertFromRGB48(short[] srcRed, int srcRedOffset, short[] srcGreen, int srcGreenOffset, short[] srcBlue, int srcBlueOffset, int alpha, int[] dest, int destOffset, int num)
srcRed
- the red pixel valuessrcRedOffset
- the first entry of srcRed to be usedsrcGreen
- the green pixel valuessrcGreenOffset
- the first entry of srcGreen to be usedsrcBlue
- the blue pixel valuessrcBlueOffset
- the first entry of srcBlue to be usedalpha
- the transpancy value to be used in the destination RGBA array (only top 8 bits should be set)dest
- array to store RGBA pixel valuesdestOffset
- first entry of dest to be usednum
- number of pixels to be converted