DEV Community

Cover image for Why do the color values range from (0-255) only?
rahul negi
rahul negi

Posted on • Originally published at hashnode.com

Why do the color values range from (0-255) only?

Once upon a time...

Someone asked me this question "Why do the color values range from 0-255 only?".

I was surprised how I never noticed this small thing and began on a quest to know the Truth.

Not Surprisingly, the Truth is so simple.

The Truth

Most of the screens use 24 bits RGB pixels, each pixel has three components in order of** Red, Green, Blue** leaving 8 bits for each color component.

Screenshot (40).png
Check this RGB calculator here.

The minimum and maximum decimal number that can be represented through 8 bits is 0 and 255.

00000000 (binary) = 0 (decimal)
11111111 (binary) = 255 (decimal) 
Enter fullscreen mode Exit fullscreen mode

Each pixel component ranges through 256 different shades of their color (RGB), and each number just sets the brightness/contrast of that pixel component resulting in

256 x 256 x 256 = 16777216 possible colors

I hope you learned something new today, open to comments and suggestions.
Thanks for reading the article.

Top comments (0)