RGB - It is a color combination value of Red Green Blue
Syntax: 0xRRGGBB
Example: -
0xFF0000 (or) 255, 0, 0 (Red color)
0x00FF00 (or) 0, 255, 0 (Green color)
0x0000FF (or) 0, 0, 255 (Blue color)
Red - the red component of the color being set in range 0-255
Green - the green component of the color being set in range 0-255
Blue - the blue component of the color being set in range 0-255
ARGB - It is a color combination value of Red Green Blue with Alpha channel
Syntax: 0xAARRGGBB
Example: -
0xFFFF0000 - Red color with white color background
0x00FF0000 - Red color with transparent background
Alpha – it specifies the opacity (transparency) of the pixel
[0x00 – Fully transparent and 0xFF – white background]
Red - the red component of the color being set in range 0-255
Green - the green component of the color being set in range 0-255
Blue - the blue component of the color being set in range 0-255
Convert RGB to ARGB
public int convert_RGB_to_ARGB(int rgb) {
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = (rgb >> 0) & 0xFF;
return 0xff000000 | (r <<>
}
Convert ARGB to RGB
public int convert_ARGB_to_RGB(int argb) {
int a = (argb >> 24) & 0xFF;
int r = (argb >> 16) & 0xFF;
int g = (argb >> 8) & 0xFF;
int b = (argb >> 0) & 0xFF;
return (r <<>
}
No comments:
Post a Comment