将Mat图片加载到PictureControl控件中
来源:互联网 发布:淘宝模特快拍视频 编辑:程序博客网 时间:2024/04/30 04:22
//将Mat图片加载到PictureControl控件中,CWnd* pWnd为PictureControl的句柄
void CModelViewControllerDlg::showMatImgToWnd(CWnd* pWnd, const cv::Mat& img)
{
if(img.empty())
return;
static BITMAPINFO *bitMapinfo = NULL;
static bool First=TRUE;
if(First)
{
BYTE *bitBuffer = new BYTE[40+4*256];//开辟一个内存区域
if(bitBuffer == NULL)
{
return;
}
First=FALSE;
memset(bitBuffer, 0, 40+4*256);
bitMapinfo = (BITMAPINFO *)bitBuffer;
bitMapinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitMapinfo->bmiHeader.biPlanes = 1;
for(int i=0; i<256; i++)
{ //颜色的取值范围 (0-255)
bitMapinfo->bmiColors[i].rgbBlue =bitMapinfo->bmiColors[i].rgbGreen =bitMapinfo->bmiColors[i].rgbRed =(BYTE) i;
}
}
bitMapinfo->bmiHeader.biHeight = -img.rows;
bitMapinfo->bmiHeader.biWidth = img.cols;
bitMapinfo->bmiHeader.biBitCount= img.channels() *8;
CRect drect;
pWnd->GetClientRect(drect); //pWnd指向CWnd类的一个指针
CClientDC dc(pWnd);
HDC hDC =dc.GetSafeHdc(); //HDC是Windows的一种数据类型,是设备描述句柄;
SetStretchBltMode(hDC, COLORONCOLOR);
StretchDIBits(hDC,
0,
0,
drect.right, //显示窗口宽度
drect.bottom, //显示窗口高度
0,
0,
img.cols, //图像宽度
img.rows, //图像高度
img.data,
bitMapinfo,
DIB_RGB_COLORS,
SRCCOPY);
}
void CModelViewControllerDlg::showMatImgToWnd(CWnd* pWnd, const cv::Mat& img)
{
if(img.empty())
return;
static BITMAPINFO *bitMapinfo = NULL;
static bool First=TRUE;
if(First)
{
BYTE *bitBuffer = new BYTE[40+4*256];//开辟一个内存区域
if(bitBuffer == NULL)
{
return;
}
First=FALSE;
memset(bitBuffer, 0, 40+4*256);
bitMapinfo = (BITMAPINFO *)bitBuffer;
bitMapinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitMapinfo->bmiHeader.biPlanes = 1;
for(int i=0; i<256; i++)
{ //颜色的取值范围 (0-255)
bitMapinfo->bmiColors[i].rgbBlue =bitMapinfo->bmiColors[i].rgbGreen =bitMapinfo->bmiColors[i].rgbRed =(BYTE) i;
}
}
bitMapinfo->bmiHeader.biHeight = -img.rows;
bitMapinfo->bmiHeader.biWidth = img.cols;
bitMapinfo->bmiHeader.biBitCount= img.channels() *8;
CRect drect;
pWnd->GetClientRect(drect); //pWnd指向CWnd类的一个指针
CClientDC dc(pWnd);
HDC hDC =dc.GetSafeHdc(); //HDC是Windows的一种数据类型,是设备描述句柄;
SetStretchBltMode(hDC, COLORONCOLOR);
StretchDIBits(hDC,
0,
0,
drect.right, //显示窗口宽度
drect.bottom, //显示窗口高度
0,
0,
img.cols, //图像宽度
img.rows, //图像高度
img.data,
bitMapinfo,
DIB_RGB_COLORS,
SRCCOPY);
}
0 0
- 将Mat图片加载到PictureControl控件中
- PictureControl控件加载图片
- 将Mat图像显示到MFC PictureControl控件上
- opencv 将内存中图片读入到mat矩阵
- VC2008 PictureControl(图片控件)添加注意问题
- 在 MFC 框架中,有什么方法能直接将 OpenCV 2.0 库中 Mat 格式的图片传递到 Picture Control(图片控件)显示?
- 将图片上传到PictureBox控件中
- 将Opencv,Mat类型图片贴图到windows显示设备中
- OpenCV中Mat、IplImage格式的图片,显示到MFC中的picture控件上
- Android下将图片加载到内存中
- VS2013 MFC 直接将 OpenCV2.0/3.0 库中的 Mat 结构的图像传递到 Picture Control(图片控件)
- 在mfc中picture控件中显示Mat图片
- VS2010-MFC:用OpenGL在对话框中的PictureControl(图片控件)中绘制三维模型,可旋转、平移、缩放,可用于三维模型的预览
- 将matlab 生成的mat矩阵存储到txt中。
- opencv将Mat数据输出到xls中
- OPENCV Mat图像在MFC PictureControl显示
- 动态加载图片到控件显示
- 使用PictureControl显示BMP图片
- vi跳刀最后一行
- POJ 1611 The Suspects
- OC中的容器类及其功能方法:数组,字典,集合
- linux设置服务开机启动
- C&&C++ 经典书籍
- 将Mat图片加载到PictureControl控件中
- 到底是学Java还是.net
- 「能写代码」是愚公移山,「会写代码」是女娲补天
- 使用easyui-textbox, 点回车键,执行某个按钮的方法
- U盘问题,插入时只有声音,没有显示,在”计算机管理”的“磁盘管理”中,上面看不到盘符”H:”,下面可以看到”磁盘1 可移动无媒
- bzoj 1588 营业额统计
- Caffe Layer代码阅读
- synchronized关键字详解
- coursera特征缩放