MFC图像识别的问题,反复在控件里显示硬盘里的图片,但是运行时出错关闭,编译没有问题
利用SDK包进行图像处理,由于只有保存单帧图像的函数,就需要反复读取硬盘上的文件进行显示,编译没有问题,但是启动时就出现错误。求高手解答if(m_boOpen){//CS...
利用SDK包进行图像处理,由于只有保存单帧图像的函数,就需要反复读取硬盘上的文件进行显示,编译没有问题,但是启动时就出现错误。求高手解答
if (m_boOpen)
{
//
CString strFileName;
strFileName = "c:\\capture.bmp";
devwdm_SaveBmpFile(m_nSlot, (char*)(LPCTSTR)strFileName);
/*CFile file;
file.Open(strFileName,CFile::modeRead|CFile::shareDenyWrite);
CImg cimg;
cimg.AttachFromFile(file);*/
CBitmap hbmp;
HBITMAP hbitmap;
//将pStatic指向要显示的地方
CStatic *pStaic;
pStaic=(CStatic*)GetDlgItem(ID_FILE_PRINTnew);
hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),strFileName,
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hbmp.Attach(hbitmap);
//获取图片格式
BITMAP bm;
hbmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(GetDC());
CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);
CRect lRect;
pStaic->GetClientRect(&lRect);
//显示位图
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dcMem.SelectObject(&poldBitmap);
/*HBITMAP hBitmap=(HBITMAP)::LoadImage(NULL,(char*)(LPCTSTR)strFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
HDC hdc=CreateCompatibleDC(hdc);
SelectObject(hdc,&hBitmap);
HDC hdc1=CreateCompatibleDC(hdc1);
BitBlt (hdc1,240,180,352,288,hdc,480,360,SRCCOPY);
DeleteDC(hdc);
DeleteDC(hdc1);*/
m_btnStartPreview.EnableWindow(FALSE);
m_btnSnap.EnableWindow(TRUE);
m_btnCapture.EnableWindow(TRUE);
} 展开
if (m_boOpen)
{
//
CString strFileName;
strFileName = "c:\\capture.bmp";
devwdm_SaveBmpFile(m_nSlot, (char*)(LPCTSTR)strFileName);
/*CFile file;
file.Open(strFileName,CFile::modeRead|CFile::shareDenyWrite);
CImg cimg;
cimg.AttachFromFile(file);*/
CBitmap hbmp;
HBITMAP hbitmap;
//将pStatic指向要显示的地方
CStatic *pStaic;
pStaic=(CStatic*)GetDlgItem(ID_FILE_PRINTnew);
hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),strFileName,
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
hbmp.Attach(hbitmap);
//获取图片格式
BITMAP bm;
hbmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(GetDC());
CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);
CRect lRect;
pStaic->GetClientRect(&lRect);
//显示位图
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dcMem.SelectObject(&poldBitmap);
/*HBITMAP hBitmap=(HBITMAP)::LoadImage(NULL,(char*)(LPCTSTR)strFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
HDC hdc=CreateCompatibleDC(hdc);
SelectObject(hdc,&hBitmap);
HDC hdc1=CreateCompatibleDC(hdc1);
BitBlt (hdc1,240,180,352,288,hdc,480,360,SRCCOPY);
DeleteDC(hdc);
DeleteDC(hdc1);*/
m_btnStartPreview.EnableWindow(FALSE);
m_btnSnap.EnableWindow(TRUE);
m_btnCapture.EnableWindow(TRUE);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询