2012-01-10 16 views
3

ピクチャーボックスにIplImageを表示する方法はありますか?ピクチャーボックスにIplimageを置く方法は?

私はプログラムを速くする必要があるので、イメージを保存せずにピクチャボックスにリロードします。

私はopencv 2.1をC++で使用しています。 Visual Studio 2008で作業しています。ありがとうございます。

答えて

3

これはすでに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); 
+0

私はグーグルを愛する方法! – karlphillip

+0

申し訳ありませんが動作しません.. HDC hdc = picturebox.GetDC() - > m_hDC;私はC++でこれを行うことはできません、私はこのようにハンドルハンドル=(ハンドル)this-> PbBoxImg-> Handle.ToPointer(); // ToInt32(); \t \t HWND hWnd =(HWND)&handle;今はエラーは表示されませんが、画像ボックスには何も表示されません。 \t \t HDC hdc1 = GetDC(hWnd); – andrea

+0

私は週末に見ていきます。私は今Windowsを持っていません。 – karlphillip

関連する問題