Class RGBA
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.
- Author:
- Marco Schmidt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default value for the alpha part of RGBA. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Field Details
-
DEFAULT_ALPHA
public static final int DEFAULT_ALPHAThe default value for the alpha part of RGBA. The alpha value is eight bits long left-shifted by 24. This default value is no transparency - the underlying image cannot be seen:0xff000000
.- See Also:
-
-
Constructor Details
-
RGBA
private RGBA()
-
-
Method Details
-
convertFromPackedBilevel
public static void convertFromPackedBilevel(byte[] src, int srcOffset, int alpha, int[] dest, int destOffset, int num) Converts pixels from bilevel packed bytes to RGBA format. A byte is supposed to store eight pixels, the most significant bit being the leftmost pixel.- Parameters:
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 converted
-
convertFromGray8
public 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.- Parameters:
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 converted
-
convertFromGray16
public 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. Note that the lower 8 bits of each grayscale value are dropped.- Parameters:
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 converted
-
convertFromPaletted8
public 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.- Parameters:
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 converted
-
convertFromRGB24
public 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.- Parameters:
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
-
convertFromRGB48
public 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.- Parameters:
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- Since:
- 0.12.0
-