c++ - 如何将 Iplimage 放在图片框上?

标签 c++ visual-studio-2008 opencv picturebox

有没有办法在图片框中显示 IplImage?

我不想保存图像并将其重新加载到图片框中,因为我需要我的程序运行得更快。

我在 C++ 中使用 opencv 2.1。我正在使用 Visual Studio 2008。谢谢。

最佳答案

这已经讨论过here :

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);

关于c++ - 如何将 Iplimage 放在图片框上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8805386/

相关文章:

visual-studio - 为什么 Intellisense 不适用于一个单元测试项目?

python - 从白色背景中提取前景图像

c# - 嵌入式 Outlook View 控件

c++ - SVM 支持 vector 机回归 openCv c++

opencv - 相机姿态估计

c++ - ATL 和来自 scrrun.dll 的类型

c++ - 通过推导实现一个map_keys_iterator : a single compiler error

c++ - 为什么我的程序打印默认构造函数?

c++ - 哪个是将原始指针(由用户提供)保存到 shared_ptr 的更好接口(interface)

.net - AnkhSVN 麻烦 : "please select a valid location in the repository to add to"