IDirectDrawSurface4::SetPalette

The IDirectDrawSurface4::SetPalette method attaches a palette object to (or detaches one from) a surface. The surface uses this palette for all subsequent operations. The palette change takes place immediately, without regard to refresh timing.

HRESULT SetPalette(
  LPDIRECTDRAWPALETTE lpDDPalette  
);
 

Parameters

lpDDPalette
Address of the IDirectDrawPalette interface for the palette object to be used with this surface. If this parameter is NULL, the current palette will be detached.

Return Values

If the method succeeds, the return value is DD_OK.

If the method fails, the return value may be one of the following error values:

DDERR_GENERIC
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_INVALIDPIXELFORMAT
DDERR_INVALIDSURFACETYPE
DDERR_NOEXCLUSIVEMODE
DDERR_NOPALETTEATTACHED
DDERR_NOPALETTEHW
DDERR_NOT8BITCOLOR
DDERR_SURFACELOST
DDERR_UNSUPPORTED

Remarks

When setting a palette to a surface for the first time, this method increments the palette's reference count; subsequent calls to do not affect the palette's reference count. If you pass NULL as the lpDDPalette parameter, the palette is removed from the surface, and the palette's reference count is decremented. If you do not delete the palette, the surface will automatically release its reference to the palette when the surface itself is released. According to COM rules, your application is responsible for releasing any references it holds to the palette when the object is no longer needed.

QuickInfo

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in ddraw.h.
  Import Library: Use ddraw.lib.

See Also

IDirectDrawSurface4::GetPalette, IDirectDraw4::CreatePalette