When I want to create an 8-bit DIB using SetDIBits(), how would I go about setting the 256-color RGBQUAD array in the BITMAPINFO structure? Its size appears to be fixed, since the member is declared as:
RGBQUAD rgbColors[1];
Or do I have to use SetDIBColorTable() after the call to SetDIBits(), or something similar?
You will find some structures like this in windows - sometimes you will see them with an array declaration of
size [0] sometimes you will see them with and array declared as size[1] like in the BITMAPINFO structure.
The idea is idea is as follows:
1. The BITMAPINFO header looks like this:
2. You create a buffer of the required number of RGBQUAD elements PLUS the size of the BITMAPINFOHEADER
Example:
for 256 quad elements
1 2 3 4 5
PBITMAPINFO pInfo = (PBITMAPINFO)newchar [sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD) ]
//The head of the buffer is treated as a BITMAPINFOHEADER
pInfo->bmiHeader.memberofbmiHeader = ?????
//The 256 RGBQUAD array
pInfo->bmiColors[200] = ????
Thank you - I will try that, since I am having zero success whatsoever using SetDIBColorTable (as noted in another post that's floating around on this board...).
But why doesn't the structure just instead define its members in the following manner?
...because the proper way, as you describe it, seems completely convoluted and counter-intuitive. I'm looking at the MSDN documentation for it right now, and in no way does the doc even imply the need to create a separate buffer and cast it to a BITMAPINFO pointer. I shouldn't be surprised, since MSDN's documentation has for whatever reason always been next-to-useless on certain topics.