AllAPI Network - The KPD-Team

Allapi Network

 API List

API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
This Site
 Search Engine
 Contact Form

Donate to


The CreateDIBSection function creates a device-independent bitmap (DIB) that applications can write to directly. The function gives you a pointer to the location of the bitmapís bit values. You can supply a handle to a file mapping object that the function will use to create the bitmap, or you can let the operating system allocate the memory for the bitmap.

Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long


Operating Systems Supported
Requires Windows NT 3.1 or later; Requires Windows 95 or later


Parameter Information
∑ hdc
Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this device contextís logical palette to initialize the device-independent bitmapís colors.

∑ pbmi
Points to a BITMAPINFO structure that specifies various attributes of the device-independent bitmap, including the bitmapís dimensions and colors.

∑ iUsage
Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure pointed to by pbmi: logical palette indices or literal RGB values. The following values are defined:
The bmiColors member is an array of 16-bit indices into the logical palette of the device context specified by hdc.
The BITMAPINFO structure contains an array of literal RGB values.

∑ ppvBits
Points to a variable that receives a pointer to the location of the device-independent bitmapís bit values.

∑ hSection
Handle to a file mapping object that the function will use to create the device-independent bitmap. This parameter can be NULL.
If hSection is not NULL, it must be a handle to a file mapping object created by calling the CreateFileMapping function. Handles created by other means will cause CreateDIBSection to fail.
If hSection is not NULL, the CreateDIBSection function locates the bitmapís bit values at offset dwOffset in the file mapping object referred to by hSection. An application can later retrieve the hSection handle by calling the GetObject function with the HBITMAP returned by CreateDIBSection.
If hSection is NULL, the operating system allocates memory for the device-independent bitmap. In this case, the CreateDIBSection function ignores the dwOffset parameter. An application cannot later obtain a handle to this memory: the dshSection member of the DIBSECTION structure filled in by calling the GetObject function will be NULL.

∑ dwOffset
Specifies the offset from the beginning of the file mapping object referenced by hSection where storage for the bitmapís bit values is to begin. This value is ignored if hSection is NULL. The bitmapís bit values are aligned on doubleword boundaries, so dwOffset must be a multiple of the size of a DWORD.

Return Values
If the function succeeds, the return value is a handle to the newly created device-independent bitmap, and *ppvBits points to the bitmapís bit values.

If the function fails, the return value is NULL, and *ppvBits is NULL. To get extended error information, call GetLastError.


Related Functions

No VB.NET Example Found



Copyright © 1998-2007, The Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at