Microsoft DirectX 9.0


The GetColorKey method retrieves the color key being used by a video stream.


HRESULT GetColorKey(
  COLORKEY *pColorKey,
  DWORD *pColor



[out] Pointer to a COLORKEY structure that contains the key type and a palette index.


[out] Pointer to a value indicating the 8-bit palette index of the COLORKEY returned if the current display mode is 8-bit palettized. Otherwise it is a value representing the color key in the pixel format of the current display mode.

Return Value

Returns an HRESULT value. Possible values include the following:

Value Description
E_INVALIDARG Invalid arguments, both parameters are NULL.
E_FAIL GetColorKey failed because the color key isn't known.
NOERROR Success.


Getting the value on the primary stream will retrieve the destination color key being used by the overlay surface. Getting this value on the secondary pin returns the color key being used by that particular stream.

Current DirectShow implementation of this interface can return NULL for either the pColorKey or the pColor parameters; however, the method will fail and return E_INVALIDARG if both parameters are NULL.

Note The DWORD value returned by the pColor parameter is the actual color being used. So, if the bit depth of the display is 8, 16, 24, 32 the last 8, 16, 24 or 32 bits of the DWORD specify the actual value of the color key.

See Also