Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

You can set the source or destination color key for a surface either when creating it or afterwards.

To set a color key or keys when creating a surface, you assign the appropriate color values to one or both of the ddckCKSrcBltand ddckCKDestBltmembers of the DDSURFACEDESCstructure that is passed to IDirectDraw::CreateSurface. To enable the color key for blitting, you must also include one or both of DDSD_CKSRCBLT or DDSD_CKDESTBLT in the dwFlagsmember.

To set a color key for an existing surface you use the IDirectDrawSurface::SetColorKeymethod.

You specify a key in the lpDDColorKeyparameter and set either DDCKEY_SRCBLT or DDCKEY_DESTBLT in the dwFlagsparameter to indicated whether you are setting a source or destination key. Destination color keying is not supported in the DirectDraw HEL.

If the DDCOLORKEYstructure contains a range of colors, you must also set the DDCKEY_COLORSPACE flag.

If this flag is not set, only the dwColorSpaceLowValuemember of the structure is used.

See Also