下面是在MFC的CView窗口中显示IplImage图像的函数代码
void CMyView::ShowIplImage(IplImage* img) {
CDC* pDC = GetDC();
HDC hDC = pDC->GetSafeHdc();
CRect rect;
rect.SetRect(0 , 0 , img->width , img->height);
CvvImage cimg;
cimg.CopyOf(img);
cimg.DrawToHDC(hDC,&rect);
ReleaseDC(pDC);
}
void Cdialog_iplImageDlg::DrawPicToHDC(IplImage* iplimg , UINT ID)
{
CDC *pDC = GetDlgItem(ID)->GetDC();
HDC hDC= pDC->GetSafeHdc();
CRect rect;
GetDlgItem(ID)->GetClientRect(&rect);
CvvImage cimg;
cimg.CopyOf(iplimg);
cimg.DrawToHDC(hDC,&rect);
ReleaseDC(pDC);
}