3
有沒有辦法在picturebox中顯示IplImage?如何把一個Iplimage放在一個picturebox上?
我想不保存圖像並將其重新加載到圖片框中,因爲我需要我的程序快速。
我在C++中使用opencv 2.1。我正在使用Visual Studio 2008.謝謝。
有沒有辦法在picturebox中顯示IplImage?如何把一個Iplimage放在一個picturebox上?
我想不保存圖像並將其重新加載到圖片框中,因爲我需要我的程序快速。
我在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);
我如何愛谷歌! – karlphillip 2012-01-10 15:40:56
抱歉,它不起作用。HDC hdc = picturebox.GetDC() - > m_hDC;我不能這樣做在C++中,我試過這種方式HANDLE句柄=(HANDLE)this-> PbBoxImg-> Handle.ToPointer(); //。ToInt32(); \t \t HWND hWnd =(HWND)&handle;現在我沒有任何錯誤,但沒有顯示在圖片框中 \t \t HDC hdc1 = GetDC(hWnd); – andrea 2012-01-13 16:45:41
我會在週末看看。我現在沒有Windows。 – karlphillip 2012-01-13 16:52:19