Game Development Reference
In-Depth Information
// Allocate memory for the new header.
m_pBMI = new BITMAPINFO;
if (!m_pBMI) {
TRACE(”Out of memory for header”);
return FALSE;
}
// Fill in the header info.
BITMAPINFOHEADER *bmi=(BITMAPINFOHEADER*)m_pBMI;
bmi->biSize = sizeof(BITMAPINFOHEADER);
bmi->biWidth = m_width;
bmi->biHeight = -m_height;
bmi->biPlanes = 1;
bmi->biBitCount = m_bitdepth;
bmi->biCompression = BI_RGB;
bmi->biSizeImage = 0;
bmi->biXPelsPerMeter = 0;
bmi->biYPelsPerMeter = 0;
bmi->biClrUsed = 0;
bmi->biClrImportant = 0;
Return TRUE;
}
Blitting the display to the screen
My rule about not using Windows code falls down again here, since at
some stage we need to display the result of our labours. Windows uses
device contexts in such operations. This topic does not go into any detail
in this regard. There are many other topics that explain graphics operation
for Windows; the Appendix lists some of the author's favourites. We use
a simple blit to get our memory-based bitmap onto the screen. Now you
will realize why the BITMAPINFO structure was needed.
// Draw the DIB to a given DC.
void CCanvas::Draw(CDC *pdc)
{
::StretchDIBits(pdc->GetSafeHdc(),
0,
// Destination x
0,
// Destination y
m_width,
// Destination width
m_height,
// Destination height
0,
// Source x
Search Nedrilad ::




Custom Search