c++可视化窗口中如何实现图片的输入
1个回答
展开全部
void CfreetypeView::OnShowBitmap()
{
CString Name;
CBitmap bmp;
HBITMAP hbmp;//位图句柄
// Name.Format(_T("C:\\%d.bmp"),123);
char FilePath[] ="c:\\000000.bmp";
Name = FilePath;
hbmp= (HBITMAP)::LoadImage( AfxGetInstanceHandle(),Name,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);//从文件bitmap1.bmp打开位图资源
bmp.Attach(hbmp);//绑定
// CMainFrame* pMainFrm =(CMainFrame*)AfxGetApp()->GetMainWnd();
CBitmap *pOldBitmap;
CDC MemDC;
CRect rect;
/* GetWindowRect(&rect);*/
CWnd* pMainWnd = AfxGetMainWnd();
pMainWnd->GetClientRect(&rect);
CClientDC dc(this);
MemDC.CreateCompatibleDC(&dc);
pOldBitmap=(CBitmap*)MemDC.SelectObject(bmp);
dc.BitBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&MemDC,0,0,SRCCOPY);
}
{
CString Name;
CBitmap bmp;
HBITMAP hbmp;//位图句柄
// Name.Format(_T("C:\\%d.bmp"),123);
char FilePath[] ="c:\\000000.bmp";
Name = FilePath;
hbmp= (HBITMAP)::LoadImage( AfxGetInstanceHandle(),Name,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);//从文件bitmap1.bmp打开位图资源
bmp.Attach(hbmp);//绑定
// CMainFrame* pMainFrm =(CMainFrame*)AfxGetApp()->GetMainWnd();
CBitmap *pOldBitmap;
CDC MemDC;
CRect rect;
/* GetWindowRect(&rect);*/
CWnd* pMainWnd = AfxGetMainWnd();
pMainWnd->GetClientRect(&rect);
CClientDC dc(this);
MemDC.CreateCompatibleDC(&dc);
pOldBitmap=(CBitmap*)MemDC.SelectObject(bmp);
dc.BitBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&MemDC,0,0,SRCCOPY);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询