Color keys are specified in the pixel format of a surface. If a surface is in a palettized format, the color key is specified as an index or a range of indices. If the surface's pixel format is specified by a FourCC code that describes a YUV format, the YUV color key is specified by the three low-order bytes in both the dwColorSpaceLowValue and dwColorSpaceHighValue members of the DDCOLORKEY structure. The lowest order byte has the V data, the second lowest order byte has the U data, and the highest order byte has the Y data. The IDirectDrawSurface::SetColorKey method has a flags parameter that specifies whether the color key is to be used for overlay operations or blit operations, and whether it is a source or a destination key. Some examples of valid color keys follow:
8-bit palettized mode
// palette entry 26 is the color key
dwColorSpaceLowValue = 26;
dwColorSpaceHighValue = 26;
24-bit true color mode
// color 255,128,128 is the color key
dwColorSpaceLowValue = RGBQUAD(255,128,128);
dwColorSpaceHighValue = RGBQUAD(255,128,128);
FourCC YUV mode
// any YUV color where Y is between 100 and 110 and U
//or V is between 50 and 55 is transparent
dwColorSpaceLowValue = YUVQUAD(100,50,50);
dwColorSpaceHighValue = YUVQUAD(110,55,55);