VC加载显示bmp图片的函数

void ShowBitmap(HDC hdc,const char *srcpath)
{
	HBITMAP hBitmap = (HBITMAP)::LoadImage(0, srcpath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);  
	BITMAP  Bitmap ;
	GetObject (hBitmap, sizeof (BITMAP), &Bitmap) ;
	int nWidth  = Bitmap.bmWidth;
	int nHeight = Bitmap.bmHeight;
	HDC hMemDc  = CreateCompatibleDC(hdc);
	HGDIOBJ hOB = SelectObject(hMemDc, hBitmap);
	BitBlt(hdc,0,0,nWidth,nHeight,hMemDc,0,0,SRCCOPY);
	SelectObject(hMemDc, hOB);
	DeleteObject(hBitmap);
	DeleteDC(hMemDc);
}

  

posted @ 2014-04-23 22:29  feiren127  阅读(268)  评论(0编辑  收藏  举报