CRect rect;//定義矩形類
CWnd *pWnd = GetDlgItem(ID_ShowPi2);//獲取控制元件句柄
pWnd->GetClientRect(&rect); //獲取句柄指向控制元件區域的大小
CDC *pDc = pWnd->GetDC();//獲取picture的DC
//int win_w = rect.Width(), win_h = rect.Height();//獲取視窗寬高
CImage imgae;
Mat temp;
resize(img, temp, Size(rect.Width(), rect.Height()));
MatToCImage(temp, imgae);
pDc->SetStretchBltMode(COLORONCOLOR);
imgae.Draw(pDc->m_hDC, 0, 0, rect.Width(), rect.Height(), 0, 0, rect.Width(), rect.Height());//畫出圖片
ReleaseDC(pDc);
這個代碼只能顯示彩色影像,顯示不了單通道影像。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/15236.html
標籤:圖形處理/算法
上一篇:怎么獲取一個控制元件的邏輯坐標
