You can draw a pixel of a particular color with the GDI SetPixel function:
rgbActualColor = SetPixel (hdc, x, y, rgbColor) ;
The rgbColor parameter is an unsigned long integer (32 bits) where the lowest 3 bytes represent the density of red, green, and blue. You can construct this color value using the RGB macro:
rgbColor = RGB (byRed, byGreen, byBlue) ;
(Chapters 5 and 6 contain a more extensive discussion of Windows' use of color.)
Although x and y are logical coordinates, SetPixel colors only a single physical pixel regardless of the mapping mode. Because SetPixel draws only a single pixel, the use of a dithered color (a color that combines pixels of various pure colors) is meaningless. For this reason, Windows translates the rgbColor parameter to a pure nondithered color and returns that color.
SetPixel is almost never used in Windows programs, but that didn't prevent us from using it in the CONNECT program in Chapter 4. You can obtain the color of a particular pixel this way:
rgbColor = GetPixel (hdc, x, y) ;