RGB Color Model
The RGB color model is used for specifying colors. This model specifies the intensity of red, green, and blue on a scale of 0 to 255, with 0 (zero) indicating the minimum intensity. The settings of the three colors are converted to a single integer value by using this formula:
RGB value= Red + (Green*256) + (Blue*256*256)
The following table shows examples.
| Red | Green | Blue | RGB value | Color |
|---|---|---|---|---|
|
255 |
0 |
0 |
255 |
Red |
|
0 |
255 |
0 |
65280 |
Green |
|
0 |
0 |
255 |
16711680 |
Blue |
|
0 |
255 |
255 |
16776960 |
Cyan |
|
255 |
0 |
255 |
16711935 |
Magenta |
|
255 |
255 |
0 |
65535 |
Yellow |
|
255 |
255 |
255 |
16777215 |
White |
|
128 |
128 |
128 |
8421504 |
Gray |
|
0 |
0 |
0 |
0 |
Black |
To extract the settings of the red, green, and blue elements from an RGB value, you can use the following method:
Convert the RGB value to a hexadecimal value. This will give you a hexadecimal number with up to six digits. From right to left, each pair of hexadecimal digits is the setting of red, green, and blue, respectively, and can be converted back to decimal. If the hexadecimal number contains less than six digits, fill out the number with zeroes on the left.
The following table shows examples.
| RGB | Hexadecimal RGB | Red | Green | Blue |
|---|---|---|---|---|
|
6579300 |
646464 |
100 |
100 |
100 |
|
16422450 |
FA9632 |
50 |
150 |
250 |
|
32896 |
008080 |
128 |
128 |
0 |