Void CzqtestopenfileDlg: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code
CFileDialog OpenFile (TRUE, _T (" *. BMP "), NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, _T (" image files (*. BMP. | * *.jpg). BMP; *.jpg | All Files (*. *) | *. * | | "), NULL);
Char title []={" open image "};//set the title of the dialog
OpenFile. M_ofn. LpstrTitle=title;
The UpdateData (FALSE);
If (OpenFile DoModal ()==IDOK)
{
FilePath.=OpenFile GetPathName ();
The string filename=CT2A (filePath. GetBuffer ());
Imageleft=imread (filename);
IplImage * iplimg;
* iplimg=IplImage (imageleft);
ShowPicture (IDC_STATIC, iplimg);
}
The else
{
MessageBox (" did not load the picture ", "title");
}
}
Void CzqtestopenfileDlg: : ShowPicture (int nID, IplImage * Image)
{
The CDC * pDC=GetDlgItem (nID) - & gt; GetDC ();//according to the ID window to acquire the associated with the window context pointer
HDC HDC=pDC - & gt; GetSafeHdc ();//access device context handle
CRect the rect.//rectangle class
GetDlgItem (nID) - & gt; GetClientRect (& amp; The rect);//get box1 client area
CvvImage cimg;
Cimg. CopyOf (Image, 3);
Cimg. DrawToHDC (HDC, & amp; The rect);
//output image
The ReleaseDC (pDC);
Cimg. Destroy ();
//destruction
}
CodePudding user response:
CImage or GDI++?CodePudding user response:
I use opencv, but in ShowPicture (int nID, IplImage * Image) in the second parameter display error C2061CodePudding user response:
Didn't include OPENCV header filesCodePudding user response:
The corresponding class header files to include in the projectCodePudding user response:
Include links to the corresponding header file, the corresponding lib fileCodePudding user response:
Header files are includedCodePudding user response:
IplImage * iplimg;* iplimg=IplImage (imageleft);
Pointer to the function name with the same name?
CodePudding user response:
Opencv several? CvvImage already cancelled?https://blog.csdn.net/youyingbo/article/details/80688202