Game Development Reference
In-Depth Information
// Everything went OK.
if (m_BMI != NULL) delete m_BMI;
m_BMI = bmi;
if (m_bits != NULL) delete [] m_bits;
m_bits = bits;
return TRUE;
abortBmpLoad: // Something went wrong.
if (bmi) delete bmi;
if (bits) delete [] bits;
return FALSE;
}
That is all that is necessary to load a 24-bit uncompressed Windows
bitmap. To test the result of the load, use StretchDIBits:
int StretchDIBits(
HDC hdc , // handle to device context
int XDest , // x-coordinate of dest
int YDest , // y-coordinate of dest
int DWidth , // width of destination rectangle
int DHeight , // height of destination rectangle
int XSrc , // x-coordinate of source
int YSrc , // y-coordinate of source
int SWidth , // width of source rectangle
int SHeight , // height of source rectangle
CONST VOID *bits , // address of bitmap bits
CONST BITMAPINFO *bmi , // address of bitmap data
UINT usage ,
// usage flags
DWORD op
// raster operation code
);
To display your bitmap, use the device context from the paint event for
your view and call StretchDIBits with destination and source parameters
set.
StretchDIBits(pDC->GetSafeHdc(), // Device context handle
0, 0, m_width, m_height,
// Destination x, y, width,
// height
0, 0, m_width, m_height,
// Source x, y, width, height
Search Nedrilad ::




Custom Search