Help URGENT!!! Need to display an image whose path is decided at run time.
C / C++ / MFC
4
Posts
2
Posters
0
Views
1
Watching
-
Hi all, I am a new VC++ programmer. I need to acess a bmp file and read its pixels but urgently I need to know how to display an image on the screen whose path is chosen by browsing throgh the file system. Please Help Awasthy
Use ::LoadImage() ... look it up in MSDN. Hope this helps. - tareq
-
Use ::LoadImage() ... look it up in MSDN. Hope this helps. - tareq
-
Hi I have the path of the image and its handle using LoadImage() but how do I display it? No picture is being displayed. Awasthy Any work worth doing is worth doing well.
Assuming youre using MFC ... use the following code...
HBITMAP bmp = (HBITMAP)::LoadImage(::GetModuleHandle(0), _T("Coffee.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); CBitmap* pBitmap = CBitmap::FromHandle(bmp); CPaintDC dc(this); CDC memDc; memDc.CreateCompatibleDC(&dc); CBitmap* pMemBmp = memDc.SelectObject(pBitmap); dc.BitBlt(0,0,200,200,&memDc,0,0,SRCCOPY); //put your image width,height for the 3rd and 4th param memDc.SelectObject(pMemBmp); ::DeleteObject(bmp);
- tareq