Javatpoint Logo
Javatpoint Logo

Color Codes Conversion

Different color codes

As we know that color here is of 24-bit format, which means 8 bits of red, 8 bits of green, 8 bits of blue. By changing the quantity of the 3 portions, you can made different colors.

Binary color format

Color: Black

Image:

Color Codes Conversion

Decimal code : RGB(0,0,0)

Explanation:

For pure black color, all the three portions of R, G, B is 0

Color: White

Image : Color Codes Conversion

Decimal : RGB(255, 255, 255)

Explanation:

For pure white color, all the three portions of R, G, B is 255

RGB color model

Color: Red

Image :

Color Codes Conversion

Decimal code: RGB(255, 0, 0)

Explanation:

For the red color, green and blue should be set 0, and for the red portion, we have to give its maximum value, i.e. 255.

Color: Green

Image :

Color Codes Conversion

Decimal code: RGB(0, 255, 0)

Explanation:

For green color, red and blue should be set 0, and for the green portion, we have to give its maximum value, i.e. 255.

Color: Blue

Image :

Color Codes Conversion

Decimal code: RGB(0, 0, 255)

Explanation:

For blue color, red and green should be set to 0, and for the blue portion, we have to give its maximum value, i.e. 255.

Gray color

Color: gray

Image :

Color Codes Conversion

Decimal code: RGB(128, 128, 128)

Explanation:

For gray color, All the value should be 128.

CMYK color model

CMYK model is used for printers in which two carters are used, one for CMY color and other for black color. CMY can be changed to RGB.

In CMYK color model C stands for cyan, M stands for magenta, Y stands for yellow, and K stands for black.

Color: Cyan

Image :

Color Codes Conversion

Decimal code: RGB(0, 255, 255)

Explanation:

For cyan color, red should be set 0, and for the green and blue portion, we have to give its maximum value, i.e. 255.

Color: Magenta

Image :

Color Codes Conversion

Decimal code: RGB(255, 0, 255)

Explanation:

For magenta color, green should be set 0, and for the red and blue portion, we have to give its maximum value, i.e. 255.

Color: Yellow

Image :

Color Codes Conversion

Decimal code: RGB(255, 255, 0)

Explanation:

For magenta color, blue should be set 0, and for the red and green portion, we have to give its maximum value, i.e. 255.

Color: Black

Image :

Color Codes Conversion

Decimal code : RGB(0,0,0)

Explanation:

For pure black color, all the three portions of R, G, B is 0


Conversion

RGB to Hex code

For example, if we want to convert the white color code (255, 255, 255) to hex code.

Following are the steps for RGB to Hex code conversion:

  1. Taking the 1s portion i.e. value of red(R) 255.
  2. Dividing it by 16. We will get 15 as a factor as well as remainder which is FF.
  3. Repeat step 1 and 2 for another 2 portions.
  4. Combine all the three hex code into one we will get #FFFFFF

Hex to RGB code

For example, if we want to convert white color code #FFFFFF

Following are the steps for converting hex code to RGB decimal format:

  1. Divide the number into 3 equal parts: FF FF FF
  2. Taking the 1st part and separating it: F F
  3. Now convert each part into binary separately: (1111) (1111)
  4. Combine both the binary values into one: 11111111
  5. Now convert the binary number into a decimal number: 255
  6. Now, repeat step 1 to 5 for another two portions.
  7. Combine all the three hex code into one we will get (255, 255, 255)

Following are some colors and their hex code

Color Hex Code
Black #000000
White #FFFFFF
Gray #808080
Red #FF0000
Green #00FF00
Blue #0000FF
Cyan #00FFFF
Magenta #FF00FF
Yellow #FFFF00






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA