Last active
August 29, 2015 14:04
-
-
Save edwardtoday/33584402d217395e54c9 to your computer and use it in GitHub Desktop.
MFC button handler to open and show an image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open image | |
CString FilePathName; | |
CFileDialog dlg(TRUE);///TRUE为OPEN对话框,FALSE为SAVE AS对话框 | |
if (dlg.DoModal() == IDOK) { | |
FilePathName = dlg.GetPathName(); | |
GetDlgItem(IMAGE_FILENAME)->SetWindowText(FilePathName); | |
CT2CA pszConvertedAnsiString(FilePathName); | |
cv::Mat img = cv::imread(std::string(pszConvertedAnsiString), | |
CV_LOAD_IMAGE_UNCHANGED); | |
//if (!img.empty()) { | |
// cv::namedWindow("Preview", | |
// CV_WINDOW_AUTOSIZE); //create a window with the name "Preview" | |
// cv::imshow("Preview", | |
// img); //display the image which is stored in the 'img' in the "Preview" window | |
// cv::waitKey(0); //wait infinite time for a keypress | |
// cv::destroyWindow("Preview"); //destroy the window with the name, "Preview" | |
//} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment