From: Michel on
Hi,
I'm trying to add a color table (2 RGBQUAD structure) to a BITMAPINFO
structure, but I can't understand the way I'm supposed to do that.
Below is the BITMAPINFO documentation :

"BITMAPINFO
The BITMAPINFO structure defines the dimensions and color information
for a DIB.

typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;

Members
bmiHeader
Specifies a BITMAPINFOHEADER structure that contains information about
the dimensions of color format.

bmiColors
The bmiColors member contains one of the following:
-An array of RGBQUAD. The elements of the array that make up the color
table.
-[...]

The number of entries in the array depends on the values of the
biBitCount and biClrUsed members of the BITMAPINFOHEADER structure. "

Thank you for your attention
From: Michel on
Answer found on fr.comp.os.ms-windows.programmation :
"Il faut allouer dynamiquement un BITMAPINFO avec la bonne taille.

Dans ton cas :

BITMAPINFO* Info = (BITMAPINFO*)malloc(sizeof (BITMAPINFO)
+ sizeof (RGBQUAD));

Info->bmiColors[0] = RGB(0,0,0);
Info->bmiColors[1] = RGB(255,255,255);

Pour une image 8 bits et 256 couleurs dans la palette, il faudrait
sizeof (BITMAPINFO) + 255 * sizeof (RGBQUAD) "