WinGDI: CreateDIBSection

clickynext

Platinum Member
Dec 24, 2004
2,583
0
0
Hi all,

I had a question about a specific function in the winGDI api, CreateDIBsection()

It looks to me like you pass this function a BITMAPINFO and a void**, and it points that pointer to direct memory access to the bits it allocates. However, it doesn't pass you back anything specifying how much memory it allocated, and so the buffer returned appears to be unbounded. I can't figure out how to check whether I'm going out of bounds when I'm using the allocated memory other than to just trust that it was done correctly.

Is there a way to do this that I've overlooked?

Thanks!
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,674
146
106
www.neftastic.com
It either succeeds (returning a HBITMAP) or fails returning NULL. The size of the memory area returned by *ppvBits is bounded by the dimensions YOU specify in BITMAPINFO.BITMAPINFOHEADER (pbmi.bmiHeader). You can check your bounding by using biWidth * biHeight * (biBitCount / 8).

If there is not enough memory available to allocate for the function call, CreateDIBSection will return NULL, and GetLastError will in turn return "Insufficient Memory".
 

clickynext

Platinum Member
Dec 24, 2004
2,583
0
0
Hmm, thanks for the reply. That makes sense, but doesn't change the fact that there's no guarantee that CreateDIBSection did its job correctly. But I suppose the API can be considered trustable so there's no real need to worry.

Thanks
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
but doesn't change the fact that there's no guarantee that CreateDIBSection did its job correctly.

"Requirements:
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later."

I think we'd know by now if the function behaved erratically
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |