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:
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.
| 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 (0x15, 0x33, 0x1D) Note that only the green channel changes. The 5-bit channel value of the source is 1 1001, in binary, which is converted to a 6-bit value, 11 0011. |
| 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 (0xAD, 0xCE, 0xEF) In the red channel, 1 0101 becomes 1010 1101. Similar changes occur in the green and blue channels. |
| 5:6:5 | 5:5:5 | Discard the least-significant bit (LSB) of the source's green channel. | (0x15, 0x33, 0x1D) becomes (0x15, 0x19, 0x1D) Note that only the green channel changes. Discard the lowest bit of 11 0011 to get 1 1001. |
| 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 (0xAD, 0xCF, 0xEF) In the red channel, 1 0101 becomes 1010 1101. In the green channel,11 0011 becomes 1100 1111. The transformation in the blue channel is similar to that of the red channel. |
| 8:8:8 | 5:5:5 | Discard the three LSBs from each channel of the source. | (0xAB, 0xCD, 0xEF) becomes (0x15, 0x19, 0x1D) In the red channel, 1010 1011 becomes 1 0101. Similar transformations occur in the other two channels. |
| 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 (0x15, 0x33, 0x1D) In the green channel, 1100 1101 becomes 11 0011. The changes in the red and blue channels are identical to those of the previously-listed transformation. |