MFC中加载位图
(1)使用BitBlt
void CBRUSHTESTDlg::OnPaint() { CPaintDC dc(this); CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP1); BITMAP bitmap; int size = bmp.GetBitmap(&bitmap); CDC memDC; memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&bmp); dc.BitBlt(10, 10, bitmap.bmWidth, bitmap.bmHeight, &memDC, 0, 0, SRCCOPY); //向窗口中绘制位图 }
(2)使用StretchBlt
void CBRUSHTESTDlg::OnPaint() { CPaintDC dc(this); CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP1); BITMAP bitmap; int size = bmp.GetBitmap(&bitmap); CDC memDC; memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&bmp); dc.SetStretchBltMode(STRETCH_HALFTONE); dc.StretchBlt(0, 0, bitmap.bmWidth, bitmap.bmHeight, &memDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY); //向窗口中绘制位图 }
Posted By veis