Game Development Reference
In-Depth Information
if (bytesRead != sizeof(BITMAPINFOHEADER)) {
TRACE(”CBmp::Load>> Failed to read BITMAPINFOHEADER”);
goto abortBmpLoad;
}
// Check that we got a real Windows DIB file.
if (bmpInfoHdr.biSize != sizeof(BITMAPINFOHEADER)) {
TRACE(”CBmp::Load>> File is not Windows bitmap”);
goto abortBmpLoad;
}
}
// Check that the colour depth is 24 bit
if (bmpInfoHdr.biBitCount != 24) {
TRACE(”CBmp::Load>> Only 24 bit files are supported.”);
goto abortBmpLoad;
}
}
int bitsSize = bmpFileHdr.bfSize - bmpFileHdr.bfOffBits;
//Create a new BITMAPINFO and copy the file header to it
bmi = new BITMAPINFO;
memcpy(bmi, &bmpFileHdr, sizeof(BITMAPINFOHEADER));
//Set the one colour in the palette to black
memset(bmi.bmiColors, 0, sizeof(RGBQUAD));
// Allocate the memory for the bits
bits = new BYTE[bitsSize];
if (!bits) {
TRACE(”CBmp::Load>> Out of memory for DIB bits”);
goto abortBmpLoad;
}
// Seek to the bits in the file.
bmpFile.Seek(fileStart + bmpFileHdr.bfOffBits, CFile::begin);
// Read the bits.
bytesRead = bmpFile.Read(bits, bitsSize);
if (bytesRead != bitsSize) {
TRACE(”CBmp::Load>> Failed to read bits”);
goto abortBmpLoad;
}
Search Nedrilad ::




Custom Search