MS docs CreateDIBSection shennigans ? (2bpp bitmap)

Giganews Newsgroups
Subject: MS docs CreateDIBSection shennigans ? (2bpp bitmap)
Posted by:  R.Wieser (addre…@not.available)
Date: Wed, 3 Feb 2021

I've been trying to use CreateDIBSection to create a 2bpp bitmap, which
fails (4bpp works).  While looking thru the docs.microsoft.com webpage
regarding the function in search of /why/ it fails I stumbled over the
following :

https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection
- - - - - - - - - - - - - - - - - - - -
If the function fails, the return value is NULL, and *ppvBits is NULL.

This function can return the following value.
Return code  Description
ERROR_INVALID_PARAMETER One or more of the input parameters is invalid.
- - - - - - - - - - - - - - - - - - - -

And yes, that is as close together as I've posted it.

So, an error exits is indicated by a NULL *AND* a (possible) 0x57 value ?
That doesn't make any sense ...

And no, CreateDIBSection doesn't set the 'GetLastError' value (just tested
it). :-)

So, two questions:

1) How can I check /what/ went wrong ?

2) Does CreateDIBSection accept a 2 bits per color (CGA) setting ?

Regards,
Rudy Wieser

Replies