I've been trying to use CreateDIBSection to create a 2bpp bitmap, which
fails (4bpp works).
2) Does CreateDIBSection accept a 2 bits per color (CGA) setting ?
- - - - - - - - - - - - - - - - - - - -
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 ?
BMP format can store 2bpp,
but it doesn't officially support 2bpp.
I think you misunderstood the documentation.
It specifically states:
[quote]
If the function succeeds, the return value is a handle to the newly
created DIB, and *ppvBits points to the bitmap bit values.
[/quote]
As for GetLastError, there is indeed a bug where the last error code is
not updated when the function fails. At least when the given biBitCount
value is unsupported.
Who's "it" ? the BMP guys or just MS ? :-)
Who/what is returning that "invalid parameter" result ?
Ah. So it boils down to that the documentation forgot to mention that GetLastError is involved.
By the way: I found GdiSetLastError, but no complementing getter ... It also doesn't help that a google shows that MS doesn't know anything about that function (anymore).
Who's "it" ? the BMP guys or just MS ? :-)
Uh, those BMP guys *is* MS, because MS is the one who created BMP.
Ah. So it boils down to that the documentation forgot to mention that
GetLastError is involved.
I knew it... Turns out that we're both reading different versions of the documentation.
Windows NT/2000/XP: To get extended error information, call GetLastError. This can be the following value.
I've debugged CreateDIBSection. GdiSetLastError does the same thing
as SetLastError, which is to set the last error field in the process' TEB structure.
And FYI, it only supports 1, 4, 8, 16, 24, and 32 bits; as expected.
No support for 15 bits either,
I cannot help but wonder : What would you need to do on Vista, 7, 8 and 10 ? And why didn't they mention it ? <whistle>
but I imagined it could just have been a
"hardlink" to Kernel32's SetLastError.
Not supporting 2bpp is unexpected to me. For the rest ? Yup, either
values that cleanly divide 8 bits (no remainder) or multiples of it.
Actually ... Although the 16bpp mode uses 16 bits to /store/ the pixel, by default CreateDIBSection uses just 5 bits for each of the red, green and
blue colors - adding up to a total of just 15 bits. :-)
That stuff makes my brain hurt - just by trying to imagine why such choices where made.
While it might be due to incompetence of the one who filter
the documentation,
the filtering itself exist because MS hate their
bad-for-bussiness old Windows versions.
4-bit display wasn't possible and officially supported until 1
year later after EGA was born.
BMP's lack of support for 2-bit graphics is simply because
there's no code for handling 2-bit image.
Actually ... Although the 16bpp mode uses 16 bits to /store/ the pixel,
by
default CreateDIBSection uses just 5 bits for each of the red, green and
blue colors - adding up to a total of just 15 bits. :-)
Oh, right. I forgot about that.
But it depends on the compression type. If it's RGB, it uses R5G5B5.
If it's Bitfields, it uses R5G6B5.
That stuff makes my brain hurt - just by trying to imagine why such
choices
where made.
Likely due to new innovasions and adaptations. If we have VGA as the first display technology, we might not have 1-bit and 4-bit pixel formats.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:55:15 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,851 |