本文介绍了如何在图片框上放置一个Iplimage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在图片框中显示IplImage?
Is there a way to show an IplImage in a picturebox?
我不想保存图像并将其重新加载到图片框中,因为我需要我的程序要快.
I'd like to not save the image and reload it into the picturebox since I need my program to be fast.
我在C ++中使用opencv 2.1.我正在使用Visual Studio2008.谢谢.
I'm using opencv 2.1 in C++. I'm working with Visual Studio 2008. Thank you.
推荐答案
已经对此进行了讨论这里:
IplImage* img=cvLoadImage("sample.jpg",3); // for example
HDC hdc = picturebox.GetDC()->m_hDC;
char m_chBmpBuf[2048];
BITMAPINFO *m_pBmpInfo =0;
m_pBmpInfo = (BITMAPINFO *)m_chBmpBuf;
m_pBmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_pBmpInfo->bmiHeader.biWidth = img->width;
m_pBmpInfo->bmiHeader.biHeight = -img->height;
m_pBmpInfo->bmiHeader.biBitCount= 24;
m_pBmpInfo->bmiHeader.biPlanes = 1;
m_pBmpInfo->bmiHeader.biCompression = BI_RGB;
m_pBmpInfo->bmiHeader.biSizeImage = 0;
m_pBmpInfo->bmiHeader.biXPelsPerMeter = 0;
m_pBmpInfo->bmiHeader.biYPelsPerMeter = 0;
m_pBmpInfo->bmiHeader.biClrUsed = 0;
m_pBmpInfo->bmiHeader.biClrImportant = 0;
StretchDIBits(hdc, 0, 0, img->width, img->height,
0, 0, img->width, img->height,
img->imageData, m_pBmpInfo,
DIB_RGB_COLORS, SRCCOPY);
这篇关于如何在图片框上放置一个Iplimage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!