Personal tools
You are here: Home High School Presentation What is Computer Science Activities Colors in Computers (Very Briefly)

Colors in Computers (Very Briefly)

Sidelight on representing colors in computers.

Every pixel (dot on the screen, from "picture element") can be assigned a color. The most common approach is that each pixel gets a quantity of red-ness chosen from 0 to 255, and similarly for green and blue. Under each of the 1--125 number guessing grids, is a note with the color name and the combination of red, green, and blue settings in the form (R,G,B). For example, red is (255,0,0), and yellow is (255,255,0).

The colors are also shown in a different notation, which is the more common choice for the direct notation. In this notation, a color is written in the form RRGGBB, where RR, GG, and BB, are each a two "digit" representation of the appropriate number from 0 to 255. How do we represent a number from 0 to 255 with just two digits? Each "digit" is actually chosen from the following list, with the number values shown:

digit0123456789ABCDEF
value0123456789101112131415
Then a two "digit" number is interpreted by multiplying the left "digit" by 16 and then adding the right "digit". For example, FA represents 16*15+10, which is 250.

Why such a strange notation? This notation is called hexadecimal notation, a base 16 system rather than our familiar base 10 system. Computer scientists like to use hexadecimal notation because it is a compact representation from which it is easy to determine the base 2 representation. (In a base 2 system, every number is represented by a string of just zeros and ones, and that's how all information is actually stored in digital computers, just strings of zeros and ones. The reason for this is because of the type of physical storage devices available, which we can think of as a series of switches, each of which is on or off.)

Document Actions