News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How can there be 16 colors?

Started by raleeper, July 13, 2007, 02:23:45 AM

Previous topic - Next topic

raleeper

1.  There are 3 and only 3 colors, Red, Green, and Blue.
2.  The number of bits that represent color intensity must be the same for each color.
3.  Therefore the number of possible colors is 2^(3*n) = 1, 8, 64, 512, 4096, ....

What am I missing?

Tedd

Quote from: raleeper on July 13, 2007, 02:23:45 AM
1.  There are 3 and only 3 colors, Red, Green, and Blue.
2.  The number of bits that represent color intensity must be the same for each color.
3.  Therefore the number of possible colors is 2^(3*n) = 1, 8, 64, 512, 4096, ....

What am I missing?

1. There are 3 and only 3 colour compnonents, there are an unlimited number of colours.
2. Not really, it's just convenient most of the time.
3. No..


There are two main ways to fit colours into 16-bits:

The first, and most common, is to use a palette. The palette contains up to 65536 colour entries, each giving the RGB value for its colour. Then, the image contains 16-bit palette indices (not the colour values themselves; to find the colour value you must look it up in the palette - this can be done automatically by the graphics card.)

The other is to use the 16-bits directly, taking some bits for red, some for green, and some for blue. Obviously 16/3 doesn't go too well, but you can use 5-bits per colour component and waste the extra bit. Or, since the human eye is most sensitive to green, you can say it's the more important component and use 6 bits for green and 5 for red & blue, so you get a better range in green and don't waste the extra bit.
No snowflake in an avalanche feels responsible.

MichaelW

At a hardware level the 16-color modes use a total of 4 bits to define the color. The details vary depending on the display adapter or emulation mode, and on the display mode. AFAIK the only 16-color mode in common use today under Windows is for console applications, where the colors are handled as they were for the 16-color VGA alphanumeric modes. Basically, for each character cell you have an attribute byte that specifies the color of the character, with the background color specified by the upper 4 bits and the foreground color specified by the lower 4 bits. The color specification is referred to as RGBI, although the actual layout of the bits is IRGBIRGB.
eschew obfuscation