Home > Software engineering >  For help, the MFC with picture control display images appear problem vs2019 opencv
For help, the MFC with picture control display images appear problem vs2019 opencv

Time:11-01

This is the code to display images:
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_STATIC

CodePudding user response:

Reasonable IDC_STATIC=1!

CodePudding user response:

reference 1/f, Simple, Soft reply:
you change my picture id of the control, don't also called IDC_STATIC

Need to how the, change the picture id of the control to any other can do, the code also need not to need to follow change

CodePudding user response:

refer to the second floor schlafenhamster response:
reasonable IDC_STATIC=1!

I just changed the picture control id to IDC_ShowImg useless with change is a result not

CodePudding user response:

Opencv problem?
Can change gdi++?

CodePudding user response:

reference 5 floor schlafenhamster reply:
opencv problem?
Can change gdi++?

Don't understand, how to change,,,, I was a little white,

CodePudding user response:

https://blog.csdn.net/youyingbo/article/details/80688202

CodePudding user response:

Change here try pDc - & gt; SetStretchBltMode (COLORONCOLOR);

CodePudding user response:

Reason: in the dialog box controls no variable associated IDC_PICFORWARD_CAMERA
Solution: in DoDataExchange () function to add IDC_PIC_FORWARD_CAMERA associated variables, m_PictureControl1,,
DODataEXchange () function:

CodePudding user response:

That UpdateWindow (); What//refresh the window?
  • Related