突然接触mfc,以前没用过,不知道该如何改现有的程序。picture control中的图被遮挡或者最小化就消失。下面是打开文件后显示的程序。该如何重绘,请详解。
void CImageProcessDlg::OnImgFileOpen()
{
// TODO: 在此添加控件通知处理程序代码
pwnd1 = GetDlgItem(IDC_IMG_STATIC1);
pDC1 = pwnd1->GetDC();
hDC1 = pDC1->GetSafeHdc();
pwnd2 = GetDlgItem(IDC_IMG_STATIC2);
pDC2 =pwnd2->GetDC();
hDC2= pDC2->GetSafeHdc();
GetDlgItem(IDC_IMG_STATIC2)->GetClientRect(&rect2);
GetDlgItem(IDC_IMG_STATIC1)->GetClientRect(rect1);
CString strFilter = _T("Files(*.bmp;*.jpg;*.png)|*.bmp;*.jpg;*.png|All files(*.*)|*.*||");
CFileDialog dlg( TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, strFilter, NULL);
if (dlg.DoModal() == IDOK)
{
SrcPath = dlg.GetPathName();
m_ImgFileName = dlg.GetFileTitle();
m_ImgExtName = dlg.GetFileExt();
}
else
{
return;
}
if(SrcPath=="") //判断文件路径是否为空
{
MessageBox(_T("请重新选择你要处理的图像!"));
return;
}
m_InImage = cvLoadImage(CT2CA(SrcPath));
m_OutImage = cvCreateImage( cvGetSize(m_InImage), IPL_DEPTH_8U, 3 );
cimg.CopyOf(m_InImage);
cimg.DrawToHDC(hDC1, &rect1);
//处理图像
process(m_InImage, m_OutImage);
oimg.CopyOf(m_OutImage_show);
oimg.DrawToHDC(hDC2, &rect2);
}