OpenCV和MFC的完美结合
2013-03-21 23:48
489 查看
Mat depthImage;
IplImage ipl_img = depthImage;
//将OpenCV格式的图像直接显示在MFC对话框上
void CXXXDlg::OnShowImage(IplImage* img, UINT ID)
{
CDC* pDC = GetDlgItem(ID)->GetDC(); // 获得显示控件的DC
HDC hdc = pDC->GetSafeHdc(); // 获取 HDC(设备句柄) 来进行绘图操作
CRect rect;
GetDlgItem(ID)->GetClientRect( &rect );
int rw = rect.right - rect.left; // 求出图片控件的宽和高
int rh = rect.bottom - rect.top;
int iw = img->width; // 读取图片的宽和高
int ih = img->height;
int tx = (int)(rw - iw)/2; // 使图片的显示位置正好在控件的正中
int ty = (int)(rh - ih)/2;
SetRect( rect, tx, ty, tx+iw, ty+ih );
CvvImage cimg;
cimg.CopyOf( img ); // 复制图片
cimg.DrawToHDC( hdc, &rect ); // 将图片绘制到显示控件的指定区域内
ReleaseDC( pDC );
}
需要在工程中使用CvvImage类!
IplImage ipl_img = depthImage;
//将OpenCV格式的图像直接显示在MFC对话框上
void CXXXDlg::OnShowImage(IplImage* img, UINT ID)
{
CDC* pDC = GetDlgItem(ID)->GetDC(); // 获得显示控件的DC
HDC hdc = pDC->GetSafeHdc(); // 获取 HDC(设备句柄) 来进行绘图操作
CRect rect;
GetDlgItem(ID)->GetClientRect( &rect );
int rw = rect.right - rect.left; // 求出图片控件的宽和高
int rh = rect.bottom - rect.top;
int iw = img->width; // 读取图片的宽和高
int ih = img->height;
int tx = (int)(rw - iw)/2; // 使图片的显示位置正好在控件的正中
int ty = (int)(rh - ih)/2;
SetRect( rect, tx, ty, tx+iw, ty+ih );
CvvImage cimg;
cimg.CopyOf( img ); // 复制图片
cimg.DrawToHDC( hdc, &rect ); // 将图片绘制到显示控件的指定区域内
ReleaseDC( pDC );
}
需要在工程中使用CvvImage类!
相关文章推荐
- 在VC++6.0中调通官网上opencv和MFC完美结合的经典例程需要注意到几点问题
- 在VC++6.0中调通官网上opencv和MFC完美结合的经典例程需要注意到几点问题
- 在VC++6.0中调通官网上opencv和MFC完美结合的经典例程需要注意到几点问题
- 【转载】MFC与ARX结合开发完美的AutoCAD应用程序
- mfc结合OpenCV-2.4.7 初次尝试纯属好奇(OpenCV安装并在vs2010中配置)
- Opencv (Opencv2)结合MFC学习数字图像处理【0】---开篇
- Opencv (Opencv2)结合MFC学习数字图像处理【1】---建立工程
- Opencv (Opencv2)结合MFC学习数字图像处理---图片解码(3)
- Win7 64bit下MexOpenCV的安装,Matlab和C++&OpenCV的完美结合
- Opencv (Opencv2)结合MFC学习数字图像处理【2】---图片解码
- Opencv (Opencv2)结合MFC学习数字图像处理---图片解码(1)
- mfc结合opencv显示图片
- PyQt5完美结合OpenCV
- MFC对话框和opencv的结合 读入视频
- Opencv (Opencv2)结合MFC学习数字图像处理---图片解码(2)
- MFC对话框和opencv的结合 读入视频
- (转)Opencv (Opencv2)结合MFC学习数字图像处理【3】---显示图片
- Win7 64bit下MexOpenCV的安装,Matlab和C++ & OpenCV的完美结合
- opencv结合MFC打开图片
- opencv2.3结合MFC显示图像