please dont rip this site Prev Next

CreateDIBSection info  Overview  Group

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.

HBITMAP CreateDIBSection(

    HDC hdc,

// handle to device context

    CONST BITMAPINFO *pbmi,

// pointer to structure containing bitmap size, format, and color data

    UINT iUsage,

// color data type indicator: RGB values or palette indices

    VOID *ppvBits,

// pointer to variable to receive a pointer to the bitmapís bit values

    HANDLE hSection,

// optional handle to a file mapping object

    DWORD dwOffset

// offset to the bitmap bit values within the file mapping object

   );

Parameters

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:

Value

Meaning

DIB_PAL_COLORS

The bmiColors member is an array of 16-bit indices into the logical palette of the device context specified by hdc.

DIB_RGB_COLORS

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.

Remarks

As noted above, if hSection is NULL, the operating system allocates memory for the device-independent bitmap. The operating system closes the handle to that memory when you later delete the device-independent bitmap by calling the DeleteObject function. If hSection is not NULL, you must close the hSection memory handle yourself after calling DeleteObject to delete the bitmap.

Windows NT: You need to guarantee that the GDI subsystem has completed any drawing to a bitmap created by CreateDIBSection before you draw to the bitmap yourself. Access to the bitmap must be synchronized. Do this by calling the GdiFlush function. This applies to any use of the pointer to the bitmapís bit values, including passing the pointer in calls to functions such as SetDIBits.

See Also

BITMAPINFO, CreateFileMapping, DeleteObject, DIBSECTION, GetDIBColorTable, GetObject, GdiFlush, HBITMAP, SetDIBits, SetDIBColorTable

See:

Comments:

See also:


file: /Techref/os/win/api/win32/func/src/f09_1.htm, 7KB, , updated: 2019/7/19 09:34, local time: 2022/5/21 15:36,
TOP NEW HELP FIND: 
3.239.129.91:LOG IN

 ©2022 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.piclist.com/techref/os/win/api/win32/func/src/f09_1.htm"> CreateDIBSection</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2022 contributors:
o List host: MIT, Site host massmind.org, Top posters @20220521
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .