|
-
September 21st, 2001, 04:21 AM
#1
How to Load Bitmap
HI!
i have a problem i want to loadd a bitmap from .bmp file to the views of MDI how to do this.
Thanks
-
September 21st, 2001, 04:30 AM
#2
Re: How to Load Bitmap
Hi
i am giving u the sample code to load a bitmap from .bmp file and display it in a CView derived view class.u can put this code in OnDraw() function for test.
//load the bitmap directly from file
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
"C:\\winnt\\winnt.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
//attach it to a CBitmap object
CBitmap bmp;
if(hBitmap)
{
bmp.Attach(hBitmap);
}
//get the bitmap header info
BITMAP bm;
bmp.GetBitmap(&bm);
//create a temporary memory DC
CDC mdc;
mdc.CreateCompatibleDC(pDC);
mdc.SelectObject(&bmp);
//Use CDC::BitBlt() or StretchBlt(); here i have used BitBlt() here
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&mdc,0,0,SRCCOPY);
//delete the temp DC when finished
mdc.DeleteDC();
Regards
S.K.Pradhan
Be sure to rate answers if it helped, to encourage them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|