When I switched my game to using my bitmap class (which basically just packaged what I was using before, only I didnt have to re-implement everywhere... yea yea pretty much the idea of OOP), the magenta background of the "transparent" bitmaps shows up on the screen as yellow. Green grass tiles look like blue water tiles, and orange rocks look green on the screen. Something is getting hosed! I''ve been digging through MSDN and have found only one maybe helpful nugget. The (RGBQUAD) bmiColors member of the BITMAPINFO struct has the following members:
rgbBlue
Specifies the intensity of blue in the color.
rgbGreen
Specifies the intensity of green in the color.
rgbRed
Specifies the intensity of red in the color.
rgbReserved
Reserved; must be zero.
When stepping through in the debugger, rgbGreen is 0 and the others are 255 (which shows up as a y with dots over it). I placed the following code in my bitmap class to correct it:
bmp.pbmi->bmiColors[0].rgbGreen = bmp.pbmi->bmiColors[0].rgbRed;
bmp.pbmi->bmiColors[0].rgbRed = bmp.pbmi->bmiColors[0].rgbReserved;
bmp.pbmi->bmiColors[0].rgbReserved = 0;
But that didn''t do anything... Here''s the code from operator>> of my bitmap class:
ifstream& operator>>(ifstream& in, BitmapFile& bmp)
{
in.read((UCHAR*) &bmp.bmfh, sizeof(BITMAPFILEHEADER));
//check to see if the file really is a bitmap
if(bmp.bmfh.bfType != bmp.BitmapID)
{
//set the fail bit if not
in.fail();
return in;
}
in.read((UCHAR*) bmp.pbmi, sizeof(BITMAPINFO));
//INSERT ABOVE CODE HERE, BUT DOESNT WORK
//check bit depth. if 8, allocate and read in the rest of bmi.bmiColors
if(bmp.pbmih->biBitCount == 8)
{
(LPBITMAPINFO)LocalAlloc(LPTR, sizeof(BITMAPINFO) + (255 * sizeof(RGBQUAD)));
in.read((UCHAR*) &bmp.pbmi->bmiColors[1], (255 * sizeof(RGBQUAD)));
}
//get the value for iNumBits, this is the actual size of the image data
bmp.iNumBits = bmp.bmfh.bfSize - bmp.bmfh.bfOffBits;
//allocate space for buffer
if(!(bmp.buffer = new UCHAR[bmp.iNumBits]))
{
in.fail();
return in;
}
in.read(bmp.buffer, bmp.iNumBits);
return in;
}
When this wasn''t part of the bitmap class it worked ok so I''m not quite sure what could be causing it. I''ll keep looking into it, but Im somewhat stumped at the moment. Thanks!!