Whenever I go to run the program the image that is created gives a bitmap with 4 repeated columns of red black green blue. Could someone explain to me why this is the case, if I have set the values of the RGBQUAD to have all the values apart from rgbRed to be 0? I understand there is a reserved bit for each RGBQUAD, so how do I also stop this from being displayed?
Thanks for the reply! How would I use a byte array to populate the bitmap? Just have an array of hex values that represent the colour red, and write them to the image?
Also, our of curiosity, here is the RGBQUAD
1 2 3 4 5 6 7
typedefstruct /**** Colormap entry structure ****/
{
unsignedchar rgbBlue; /* Blue value */
unsignedchar rgbGreen; /* Green value */
unsignedchar rgbRed; /* Red value */
unsignedchar rgbReserved; /* Reserved */
} RGBQUAD;
How come when I comment out "unsigned char rgbReserved;" the image still draws 4 colours, after I've surely made the size of RGBQUAD 3?
Thanks for the reply! How would I use a byte array to populate the bitmap? Just have an array of hex values that represent the colour red, and write them to the image?
Basically, yes.
1 2 3 4 5 6 7 8 9 10 11
BYTE image[size * 3]; // where 'size' is size in pixels
for(int i = 0; i < size; ++i)
{
image[ (i*3) + 0 ] = 0; // blue
image[ (i*3) + 1 ] = 0; // green
image[ (i*3) + 2 ] = 0xFF; // red
}
file.write((char*)(image), size * 3 );