在MFC的View类中:
1
void
CMyView
:
:
ShowIplImage(IplImage
*
img)
2 {
3 CDC * pDC = GetDC();
4 HDC hDC = pDC - > GetSafeHdc(); CRect rect; rect . SetRect( 0 , 0 , img - > width , img - > height); CvvImage cimg; cimg . CopyOf(img); cimg . DrawToHDC(hDC, & rect); ReleaseDC(pDC);
5 }
2 {
3 CDC * pDC = GetDC();
4 HDC hDC = pDC - > GetSafeHdc(); CRect rect; rect . SetRect( 0 , 0 , img - > width , img - > height); CvvImage cimg; cimg . CopyOf(img); cimg . DrawToHDC(hDC, & rect); ReleaseDC(pDC);
5 }
在Dialog中:
1
void
Cdialog_iplImageDlg
:
:
DrawPicToHDC(IplImage
*
iplimg
,
UINT
ID)
2 {
3 CDC * pDC = GetDlgItem(ID) - > GetDC();
4 HDC hDC = pDC - > GetSafeHdc();
5 CRect rect;
6 GetDlgItem(ID) - > GetClientRect( & rect);
7 CvvImage cimg;
8 cimg . CopyOf(iplimg);
9 cimg . DrawToHDC(hDC, & rect);
10 ReleaseDC(pDC);
11 }
2 {
3 CDC * pDC = GetDlgItem(ID) - > GetDC();
4 HDC hDC = pDC - > GetSafeHdc();
5 CRect rect;
6 GetDlgItem(ID) - > GetClientRect( & rect);
7 CvvImage cimg;
8 cimg . CopyOf(iplimg);
9 cimg . DrawToHDC(hDC, & rect);
10 ReleaseDC(pDC);
11 }