Table of Contents

Method CreateDIBSection

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

CreateDIBSection(nint, ref BITMAPINFO, uint, out nint, nint, uint)

Creates a device-independent bitmap (DIB) and returns a handle to the newly created DIB.

public static extern nint CreateDIBSection(nint hdc, ref MswUtils.NativeMethods.BITMAPINFO pbmi, uint iUsage, out nint ppvBits, nint hSection, uint dwOffset)

Parameters

hdc nint

A handle to a device context. This parameter can be null if the DIB is not associated with a specific device context.

pbmi MswUtils.NativeMethods.BITMAPINFO

A reference to a MswUtils.NativeMethods.BITMAPINFO structure that specifies the dimensions and color format of the DIB.

iUsage uint

Specifies whether the pbmi structure contains RGB values or palette indices. Use DIB_RGB_COLORS for RGB values or DIB_PAL_COLORS for palette indices.

ppvBits nint

When the function returns, this parameter receives a pointer to the location of the DIB's bit values.

hSection nint

A handle to a file mapping object that the DIB will use to store the bitmap. If this parameter is null, the DIB is created in memory.

dwOffset uint

The offset from the beginning of the file mapping object referenced by hSection. This value is ignored if hSection is null.

Returns

nint

A handle to the newly created DIB, or Zero if the function fails. Call GetLastWin32Error() to retrieve extended error information.

Remarks

The CreateDIBSection(nint, ref BITMAPINFO, uint, out nint, nint, uint) function allows applications to directly access the bits of the bitmap, which can improve performance for certain operations. The caller is responsible for releasing the DIB handle using the DeleteObject function when it is no longer needed.