-
July 5th, 2011, 11:30 AM
#1
Loadin bitmap image from file not resources
Hi guys,
I need to load a bitmap image from the file and show it in the screen in MFC. The following code load the image from a resource but I want to load it from a file.
void CScViewView::OnDraw(CDC* pDC)
{
CScViewDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CBitmap bmpCar;
CDC mdcCar;
CSize szeBitmap;
bmpCar.LoadBitmapW(IDB_BITMAP1);
szeBitmap.cx = 1276;
szeBitmap.cy = 1024;
mdcCar.CreateCompatibleDC(pDC);
CBitmap *bmpOld = mdcCar.SelectObject(&bmpCar);
pDC->BitBlt(0, 0, 1276, 1024, &mdcCar, 0, 0, SRCCOPY);
pDC->SelectObject(bmpOld);
SetScrollSizes(MM_TEXT, szeBitmap);
}
I replaced the LoadBitmapW with this bmpCar.LoadBitmap((LPCTSTR) "mybitmap.bmp"), but it does not work.
Thanks for you help in advance.
Hossein
-
July 5th, 2011, 11:41 AM
#2
Re: Loadin bitmap image from file not resources
LoadBitmap Function
The LoadBitmap function loads the specified bitmap resource from a module's executable file. This function has been superseded by the LoadImage function.
And LoadImage() can load from file.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Tags for this Thread
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
|