Pixel Format Functions

The following Win32 functions manage pixel formats.

Win32 Function Description
ChoosePixelFormat Obtains the device context's pixel format that is the closest match to a specified pixel format.
SetPixelFormat Sets a device context's current pixel format to the pixel format specified by a pixel format index.
GetPixelFormat Obtains the pixel format index of a device context's current pixel format.
DescribePixelFormat Given a device context and a pixel format index, fills in a PIXELFORMATDESCRIPTOR data structure with the pixel format's properties.
GetEnhMetaFilePixelFormat Retrieves pixel format information for an enhanced metafile.

The ChoosePixelFormat function returns a one-based pixel format index that identifies the best match from the device context's supported pixel formats.

The SetPixelFormat function identifies the desired format using a one-based pixel format index. Typically, you call ChoosePixelFormat to find a best-match pixel format, and then call SetPixelFormat with the result of ChoosePixelFormat.

If you call SetPixelFormat for a device context that references a window, SetPixelFormat also changes the pixel format of the window. Setting the pixel format of a window more than once can lead to significant complications for the Window Manager and for multithread applications, so it is not allowed. You can set the pixel format of a window only one time; after that, the window's pixel format cannot be changed.

The GetPixelFormat function returns a one-based pixel format index.

The DescribePixelFormat function takes the following as parameters:

The DescribePixelFormat function returns with the members of PIXELFORMATDESCRIPTOR appropriately set.

The GetEnhMetaFilePixelFormat function returns the size of a metafile's pixel format and retrieves the pixel format information of the metafile.