您的位置:首页 > 运维架构

opencv-IplImage结构图像画到HDC上

2010-12-28 23:14 1071 查看
Code:

// draw image(IplImage) to hdc

void DrawPicToHDC(IplImage *img, UINT ID, HWND hwnd)

{

// mfc 方法

// HWND *pDC = GetDlgItem(ID)->GetDC();

// HDC hDC= pDC->GetSafeHdc();

// GetDlgItem(ID)->GetClientRect(&rect);

// CvvImage cimg;

// cimg.CopyOf(img);

// cimg.DrawToHDC(hDC,&rect);

// ReleaseDC(hDC);



// win32方法

// get the handle of static control id

HWND hID= GetDlgItem(hwnd, ID);



// get the hdc of the handle

HDC hDC = GetDC(hID);



// the rect struct

RECT rect;



// get the client of the handle set it in the rect

GetClientRect(hID,&rect);



// a class of image

CvvImage cimg;



// IplImage copy to CvvImage

cimg.CopyOf(img);



// show the IplImage to the hdc

cimg.DrawToHDC(hDC,&rect);



// release dc

ReleaseDC(hID, hDC);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: