您现在的位置是:主页 > news > 开发直播平台网站/聊城疫情最新消息
开发直播平台网站/聊城疫情最新消息
admin2025/5/8 18:51:23【news】
简介开发直播平台网站,聊城疫情最新消息,食品包装设计ppt,互助平台网站建设操作说明: 在窗口上点击右键,在打开的窗口上选择图片.就可以显示出你的图片.是因为我不能打开pgm的图片文件,我就写了这个程序 // ReadImage.cpp : 定义控制台应用程序的入口点。// #include "stdafx.h"#…
操作说明:
在窗口上点击右键,在打开的窗口上选择图片.就可以显示出你的图片.是因为我不能打开pgm的图片文件,我就写了这个程序
// ReadImage.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "windows.h"
#include <cv.h>
#include <highgui.h>
#include <string>
using namespace std;
void Foo(int event, int x, int y, int flags, void* param);
TCHAR szFile[MAX_PATH]=_T(""); // 保存获取文件名称的缓冲区。
IplImage* image = 0;
void TestGetOpenFileName(void)
{
//
OPENFILENAME ofn; // 公共对话框结构。
ZeroMemory(szFile,MAX_PATH*sizeof(TCHAR));
// 初始化选择文件对话框。
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
//
//
ofn.lpstrFile[0] = _T('/0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("All/0*.*/0图片/0*.bmp/0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// 显示打开选择文件对话框。
if ( GetOpenFileName(&ofn) )
{
//显示选择的文件。
//OutputDebugString(szFile);
//OutputDebugString(_T("/r/n"));
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cvNamedWindow("Process window",1);
cvSetMouseCallback("Process window", Foo, NULL);
cvWaitKey(0);
if(image!=0)
{
cvReleaseImage(&image);
image=0;
}
cvDestroyAllWindows();
return 0;
}
void Foo(int event, int x, int y, int flags, void* param)
{
if(CV_EVENT_RBUTTONUP==event)
{
TestGetOpenFileName();
if(lstrlen(szFile)!=0)
{
string str=szFile;
if(image!=0)
{
cvReleaseImage(&image);
image=0;
}
image = cvLoadImage(str.c_str(),1);
cvShowImage("Process window",image);
//cvReleaseImage(&image);
}
//CFileDialog LoadBox(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER);
//if (LoadBox.DoModal() == IDOK)
//{
//string str=LoadBox.GetOFN().lpstrFile;
//CString str=LoadBox.GetPathName();
//}
}
}