Skip to content

Instantly share code, notes, and snippets.

@clarkzjw
Created June 16, 2015 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkzjw/e61f0be7b946fae5b450 to your computer and use it in GitHub Desktop.
Save clarkzjw/e61f0be7b946fae5b450 to your computer and use it in GitHub Desktop.
void CHowOldDlg::OnBnClickedButton1()
{
cv::Mat img = cv::imread("res/Test.jpeg");
CDC *pDC = GetDlgItem(IDC_Pic)->GetDC();
HDC hDC = pDC->GetSafeHdc();
CRect rect;
GetDlgItem(IDC_Pic)->GetClientRect(&rect);
int rw = rect.right - rect.left; //the width of your picture control
int rh = rect.bottom - rect.top;
if (!img.data){
MessageBox(_T("read picture fail!"));
cout << GetTime() << " [Error] " << "read picture fail!" << endl;
return;
}
cv::resize(img, img, cv::Size(rw, rh));
IplImage iplimg = img;
m_CVvImageObj.CopyOf(&iplimg);
UpdateData();
if (m_CVvImageObj.GetImage()){
m_CVvImageObj.Show(pDC->GetSafeHdc(), 0, 0, rw, rh);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment