How to display a bitmap file using CBitmap class?
-
I have one BMP file. i want to load that bmp file into a form. Please tell me the procedure. Thanks JP ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
-
I have one BMP file. i want to load that bmp file into a form. Please tell me the procedure. Thanks JP ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
In the OnDraw function write codes as follow CBitmap img; img.LoadBitmap(IDB_IMG);//IDB_IMG is ID of the resource. CDC * pMemDC=new CDC; pMemDC->CreateCompatibleDC(pDC);//pDC pointer to DC of current window pMemDC->SelectObject(&startImg); pDC->StretchBlt(0,0,cr.right,cr.bottom,pMemDC,0,0,1024,768,SRCCOPY); delete pMemDC; I am a Chinese and my English is very poor,so I wish you correct my mistake. YangXiaowei(China)
-
I have one BMP file. i want to load that bmp file into a form. Please tell me the procedure. Thanks JP ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
CString szFilename("path to ur bmp file"); HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename, IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp; bmp.Attach(hBmp); CClientDC dc(this); CDC bmDC; bmDC.CreateCompatibleDC(&dc); CBitmap *pOldbmp = bmDC.SelectObject(&bmp); BITMAP bi; bmp.GetBitmap(&bi); dc.StretchBlt (0,0,500,500,&bmDC,0,0,bi.bmWidth ,bi.bmHeight,SRCCOPY); // please see the parameters for StretchBlt() and pass them accordingly bmDC.SelectObject(pOldbmp);