Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
GDI uses three RGB color spaces for its bitmap representations. In each of these color spaces, three bitfields, or color channels, are used to specify the number of bits used for red, green, and blue, respectively, in a given color. To be able to match GDI's capabilities with bitmaps, video drivers must be able to convert from one RGB color space to another.
GDI recognizes the following RGB color spaces:
5:5:5 RGB: five-bit color channels for red, green, and blue
5:6:5 RGB: a five-bit color channel for red, a six-bit color channel for green, and a five-bit color channel for blue
8:8:8 RGB: eight-bit color channels for red, green, and blue
In general, when converting from a color channel with more bits to one with fewer bits, GDI discards the lower-order bits. When the conversion goes from a color channel with fewer bits to one with more bits, all of the bits of the smaller channel are copied to the larger channel. To fill out the remaining bits of the larger channel, some of the bits of the smaller channel are copied again to the larger channel. The following table summarizes the rules that GDI uses to convert from one RGB color space to another. In this table, color channels whose values change in the conversion are shown in bold font style.
GDI Color Space Conversion Rules
| From | To | Rule | Example |
|---|---|---|---|
5:5:5 |
5:6:5 |
The most-significant bit (MSB) of the source's green channel is appended to the low-order end of the target's green channel. |
(0x15, 0x19, 0x1D) becomes |
5:5:5 |
8:8:8 |
For each channel, the three MSBs of the source channel are appended to the lower-order end of the target channel. |
(0x15, 0x19, 0x1D) becomes |
5:6:5 |
5:5:5 |
Discard the least-significant bit (LSB) of the source's green channel. |
(0x15, 0x33, 0x1D) becomes |
5:6:5 |
8:8:8 |
For the 5-bit (red and blue) channels of the source, copy the three MSBs from the source and append them to the lower-order end of the target. For the 6-bit green channel, copy the two MSBs from the source and append them to the lower-order end of the target. |
(0x15, 0x33, 0x1D) becomes |
8:8:8 |
5:5:5 |
Discard the three LSBs from each channel of the source. |
(0xAB, 0xCD, 0xEF) becomes |
8:8:8 |
5:6:5 |
Discard the three LSBs from the red and blue channels. Discard the two LSBs from the green channel. |
(0xAB, 0xCD, 0xEF) becomes |