BOOL DrawMat(CDC *pDC, cv::Mat &img, CRect &rect)
{
if(img.empty() || img.depth() != CV_8U || img.channels() != 3)
return FALSE;
BITMAPINFO bmInfo;
memset(&bmInfo, 0, sizeof(bmInfo));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = img.cols;
bmInfo.bmiHeader.biHeight = -img.rows;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
bmInfo.bmiHeader.biCompression = BI_RGB;
int width = cv::min(rect.Width(), img.cols);
int height = cv::min(rect.Height(), img.rows);
StretchDIBits(
pDC->GetSafeHdc(),
0, 0, width, height, //rect.Width(), rect.Height(),
0, 0, width, height, //img.cols, img.rows,
img.data,
&bmInfo,
DIB_RGB_COLORS,
SRCCOPY);
return TRUE;
}
---------------------
原文:https://blog.csdn.net/CaroTong/article/details/48497495
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)