The RGB color model is probably the most familiar color model in the world. IT is an additive color model that uses Red, Green, and Blue primary colors of light mixed together in numerous ways to produce a broad array of other colors. For computers, these color values are stored as unsigned integer numbers ranging from 0 to 255 which is exactly the range that a single 8-bit byte can offer.
On the other hand, hexadecimal system is probably more familiar as a numeral system that is commonly used in computers and other digital systems. It is base 16 and it has 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, F.
Table #1: Decimal to hexadecimal conversion table
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
Instructions:
If you don't know hot to convert these values, which are essentially Integers (scope well within Decimal numbering system) feel free to consult our How to convert Decimal to Hexadecimal tutorial.
Example #1: Convert RED COLOR (255, 0, 0) into hexadecimal
Step description | Result |
---|---|
Convert 255 (RED) into 2-digit hexadecimal color code | FF |
Convert 0 (GREEN) into 2-digit hexadecimal color code | 00 |
Convert 0 (BLUE) into 2-digit hexadecimal color code | 00 |
Resulting hexadecimal number | #FF0000 |
Example #2: Convert BROWN COLOR (165,42, 42) into hexadecimal
Step description | Result |
---|---|
Convert 165 (RED) into 2-digit hexadecimal color code | A5 |
Convert 42 (GREEN) into 2-digit hexadecimal color code | 2A |
Convert 42 (BLUE) into 2-digit hexadecimal color code | 2A |
Resulting hexadecimal number | #A52A2A |