opencv-IplImage结构图像画到HDC上

Code:
  1. // draw image(IplImage) to hdc   
  2. void DrawPicToHDC(IplImage *img, UINT ID, HWND hwnd)   
  3. {   
  4. // mfc 方法   
  5. // HWND *pDC = GetDlgItem(ID)->GetDC();   
  6. // HDC hDC=  pDC->GetSafeHdc();   
  7. // GetDlgItem(ID)->GetClientRect(&rect);   
  8. // CvvImage cimg;   
  9. // cimg.CopyOf(img);   
  10. //  cimg.DrawToHDC(hDC,&rect);   
  11. // ReleaseDC(hDC);   
  12.   
  13. // win32方法   
  14. // get the  handle of static control id   
  15. HWND  hID= GetDlgItem(hwnd, ID);   
  16.   
  17. // get the hdc of the handle    
  18. HDC hDC = GetDC(hID);   
  19.   
  20. // the rect struct    
  21. RECT rect;   
  22.   
  23. // get the client of the handle set it in the rect   
  24. GetClientRect(hID,&rect);    
  25.   
  26. // a class of image   
  27.  CvvImage cimg;   
  28.   
  29.  // IplImage copy to CvvImage    
  30.  cimg.CopyOf(img);   
  31.   
  32.  // show the IplImage to the hdc   
  33.  cimg.DrawToHDC(hDC,&rect);   
  34.   
  35.  // release dc   
  36.   ReleaseDC(hID, hDC);   
  37. }   
  38.   

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值