Platform SDK: DirectX

Setting Color Keys

[C++]

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 ddckCKSrcBlt and ddckCKDestBlt members of the DDSURFACEDESC2 structure that is passed to IDirectDraw7::CreateSurface. To enable the color key for blitting, you must also include one or both of DDSD_CKSRCBLT or DDSD_CKDESTBLT in the dwFlags member.

To set a color key for an existing surface you use the IDirectDrawSurface7::SetColorKey method. You specify a key in the lpDDColorKey parameter and set either DDCKEY_SRCBLT or DDCKEY_DESTBLT in the dwFlags parameter to indicated whether you are setting a source or destination key. If the DDCOLORKEY structure contains a range of colors, you must also set the DDCKEY_COLORSPACE flag. If this flag is not set, only the dwColorSpaceLowValue member of the structure is used.

[Visual Basic]

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 ddckCKSrcBlt and ddckCKDestBlt members of the DDSURFACEDESC2 type that is passed to DirectDraw7.CreateSurface. To enable the color key for blitting, you must also include one or both of DDSD_CKSRCBLT or DDSD_CKDESTBLT in the lFlags member.

To set a color key for an existing surface you use the DirectDrawSurface7.SetColorKey method. You specify a key in the val parameter and set either DDCKEY_SRCBLT or DDCKEY_DESTBLT in the flags parameter to indicated whether you are setting a source or destination key. If the DDCOLORKEY type contains a range of colors, you must also set the DDCKEY_COLORSPACE flag. If this flag is not set, only the low member of the type is used.