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