DescribePixelFormat

The DescribePixelFormat function obtains information about the pixel format identified by iPixelFormat of the device associated with hdc. The function sets the members of the PIXELFORMATDESCRIPTOR structure pointed to by ppfd with that pixel format data.

int DescribePixelFormat(
  HDC  hdc,           // device context of interest
  int  iPixelFormat,  // pixel format selector
  UINT  nBytes,       // size of buffer pointed to by ppfd  LPPIXELFORMATDESCRIPTOR  ppfd 
                      // pointer to structure to receive pixel 
                      // format data
);

Parameters

  • hdc
    Specifies the device context.
  • iPixelFormat
    Index that specifies the pixel format. The pixel formats that a device context supports are identified by positive one-based integer indexes.
  • nBytes
    The size, in bytes, of the structure pointed to by ppfd. The DescribePixelFormat function stores no more than nBytes bytes of data to that structure. Set this value to sizeof(PIXELFORMATDESCRIPTOR).
  • ppfd
    Pointer to a PIXELFORMATDESCRIPTOR structure whose members the function sets with pixel format data. The function stores the number of bytes copied to the structure in the structure's nSize member. If, upon entry, ppfd is NULL, the function writes no data to the structure. This is useful when you only want to obtain the maximum pixel format index of a device context.

Return Values

If the function succeeds, the return value is the maximum pixel format index of the device context. In addition, the function sets the members of the PIXELFORMATDESCRIPTOR structure pointed to by ppfd according to the specified pixel format.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The following code sample shows DescribePixelFormat usage:

PIXELFORMATDESCRIPTOR  pfd; 
HDC  hdc; 
int  iPixelFormat; 
 
iPixelFormat = 1; 
 
// obtain detailed information about 
// the device context's first pixel format 
DescribePixelFormat(hdc, iPixelFormat,  
        sizeof(PIXELFORMATDESCRIPTOR), &pfd); 

Requirements

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

See Also

OpenGL on Windows NT, Windows 2000, and Windows 95/98, Win32 Functions, ChoosePixelFormat, GetPixelFormat, SetPixelFormat