Void CMFCApplication1Dlg: : OnBnClickedButton1 ()
{
Using the namespace CV;
using namespace std;
Mat Mat=imread (" G: \ \ STUDY \ \ \ \ 2 programming PNG ");//opencv read picture
Imwrite (" G: \ \ STUDY \ \ \ \ 2 _new programming PNG ", mat);//save opencv image
CImage img.
Img. Load (L "G: \ \ STUDY \ \ \ \ 2 _new programming PNG");//MFC read picture
Int img_w=img. GetWidth (), img_h=img. GetHeight ().//get photo wide high
UpdateWindow ();//refresh window
CRect the rect.//define the rectangle class
The CWnd * pWnd=GetDlgItem (IDC_STATIC);//access control handle
PWnd - & gt; GetClientRect (& amp; The rect);//get a handle to the size of the control area
The CDC * pDc=pWnd - & gt; GetDC ();//picture for DC
Int win_w=the rect. Width (), win_h=the rect. Height ();//get window wide high
PDc - & gt; SetStretchBltMode (COLORONCOLOR);
Img. The Draw (pDc - & gt; M_hDC, 0, 0, win_w win_h, 0, 0, win_w, win_h);//draw a picture
The ReleaseDC (pDc);
//TODO: add the control notification handler code
}
Click on the display image can only appear after a horizontal bar, did not show the picture control, can't display all, online solution!!!!!
CodePudding user response:
You don't change my picture id of the control, also called IDC_STATICCodePudding user response:
Reasonable IDC_STATIC=1!CodePudding user response: