You can use the GetDeviceCaps function, which specifies the NUMCOLORS value, to discover the number of colors a device supports. Usually, this count corresponds to a physical property of the output device, such as the number of inks in the printer or the number of distinct color signals the display adapter can transmit to the monitor.
Windows and applications use parameters and variables having the COLORREF type to pass and store color values. You can extract the individual values of the red, green, and blue components of a color value by using the GetRValue, GetGValue, and GetBValue macros, respectively. Use the RGB macro to create a color value from individual red, green, and blue component values.
If you request a color that the display device cannot generate, Windows CE will approximate it with a color that the device can generate. For example, if you attempt to create a red pen for a black and white printer, you will receive a black pen instead — Windows CE uses black as the approximation for red.
You can discover how Windows CE will approximate a specified color by using the GetNearestColor function. The function takes a color value and returns the color value of the closest matching color the device can generate.
Note Windows CE does not support dithering.
Windows handles colors in bitmaps differently than colors in pens, brushes, and text. Compatible bitmaps, created by using the CreateBitmap or CreateCompatibleBitmap function, retain color information in a device-dependent format. No color values are used, and the colors are not approximated.
Device-independent bitmaps (DIBs) retain color information either as color values or color palette indexes. If color values are used, the colors may be approximated as necessary. Color palette indexes can only be used with devices that support color palettes. Although Windows does not approximate colors identified by indexes, the colors in the bitmap could change if the palette changes.
Note An offscreen DIB section should have the same color table as the screen, otherwise GDI will have to perform a time-consuming color translating bit block transfer (BLT) when the DIB section is transferred to the screen. For gray scale devices, the color table should be 0x000000, 0x808080, 0xc0c0c0, and 0xffffff. For color devices, the application should first query the stock palette to determine its color display capabilities, and then build a matching color table.