Table of Contents

Method SetPixelFormat

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

SetPixelFormat(nint, int, ref PIXELFORMATDESCRIPTOR)

Sets the pixel format for a device context to the specified format.

public static extern bool SetPixelFormat(nint hdc, int format, ref MswUtils.NativeMethods.PIXELFORMATDESCRIPTOR pfd)

Parameters

hdc nint

A handle to the device context for which the pixel format is to be set.

format int

The index of the pixel format to set. This value must correspond to a valid pixel format supported by the device context.

pfd MswUtils.NativeMethods.PIXELFORMATDESCRIPTOR

A reference to a MswUtils.NativeMethods.PIXELFORMATDESCRIPTOR structure that defines the properties of the pixel format.

Returns

bool

true if the pixel format was successfully set; otherwise, false.

Remarks

This method is a P/Invoke wrapper for the GDI SetPixelFormat function. The pixel format must be set before rendering to the device context. Once a pixel format is set, it cannot be changed for the lifetime of the device context.