⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displaydlg.cpp

📁 基于IEEE 1394总线的图像采集及处理系统软件技术研究
💻 CPP
字号:
// DisplayDlg.cpp : implementation file
//

#include "stdafx.h"
#include "test1394show.h"
#include "DisplayDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDisplayDlg dialog


CDisplayDlg::CDisplayDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDisplayDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDisplayDlg)
	char cTemp[200];
	::GetCurrentDirectory(200,cTemp);
	m_strDisplayPos = cTemp;
	m_strDisplayPos += "\\";
	m_strImagePath = m_strDisplayPos;
	m_strImageName = "image";
	m_strImageExt = "raw";
	m_nDisplayOrSave = 0;
	//}}AFX_DATA_INIT
}


void CDisplayDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDisplayDlg)
	DDX_Text(pDX, IDC_EDIT_DISPLAY_POSITION, m_strDisplayPos);
	DDX_Radio(pDX, IDC_RADIO_SAVE, m_nDisplayOrSave);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDisplayDlg, CDialog)
	//{{AFX_MSG_MAP(CDisplayDlg)
	ON_BN_CLICKED(IDC_BUTTON_DIAPLAY, OnButtonDiaplay)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDisplayDlg message handlers

void CDisplayDlg::OnButtonDiaplay() 
{
	UpdateData();
	if( m_nDisplayOrSave == 1 )
	{
		CFileDialog dlg(TRUE,".bmp",NULL,OFN_HIDEREADONLY,
			"BMP Files(*.bmp)|*.bmp|raw Files(*.raw)|*.raw|All Files(*.*)|*.*||");
		if(IDOK!=dlg.DoModal())
			return;
		//得到BMP文件的路径与名称
		m_strDisplayPos = dlg.GetPathName();
		m_strImageName = dlg.GetFileTitle();
		m_strImageExt = dlg.GetFileExt();
	}
	if( m_nDisplayOrSave == 0 )
	{
		CFileDialog dlg(FALSE,".bmp",NULL,OFN_HIDEREADONLY,
			"BMP Files(*.bmp)|*.bmp|raw Files(*.raw)|*.raw|All Files(*.*)|*.*||");
		if(IDOK!=dlg.DoModal())
			return;
		//得到BMP文件的路径与名称
		m_strDisplayPos = dlg.GetPathName();
		m_strImageName = dlg.GetFileTitle();
		m_strImageExt = dlg.GetFileExt();

	}
	if( 0 != m_strImageExt.CompareNoCase("bmp") &&
		0 != m_strImageExt.CompareNoCase("raw") )
	{
		MessageBox("请选择位图或者裸图!");
		return;
	}
	//得到要显示的BMP文件的路径
	int iPos;
	iPos = m_strDisplayPos.ReverseFind('\\');
	if( iPos == -1 )
		return;
	m_strImagePath = m_strDisplayPos.Left( iPos+1 );
	UpdateData(FALSE);
}

void CDisplayDlg::OnOK() 
{
	UpdateData();
	
	if( m_nDisplayOrSave == 1 )//显示已经存在的图像序列
	{		
		//获得图像序列中每个图像的名称,并按顺序保存	
		CFileFind finder;

		m_FileNameExtList.RemoveAll();
		CList<CString,CString> TwoList,ThreeList;//分别存储序号为两位,三位的图像的名称
		int nFirstLen;//存储第一个文件的文件名的长度
		int nTemp;
	//	OneList.RemoveAll();
		TwoList.RemoveAll();
		ThreeList.RemoveAll();
		// build a string with wildcards
		CString strWildcard(m_strImagePath);
		strWildcard += _T("*.*");

		// start working for files
		BOOL bWorking = finder.FindFile(strWildcard);
		CString strName,strNameExt,strAll;strAll.Empty();
		while (bWorking)
		{
		  bWorking = finder.FindNextFile();

		  // skip . and .. files; otherwise, we'd
		  // recur infinitely!
		  if (finder.IsDots())
			continue;

		  // if it's a directory, recursively search it
		  if (finder.IsDirectory())
			  continue;
	/*	  {
			 CString str = finder.GetFilePath();
			 cout << (LPCTSTR) str << endl;
			 Recurse(str);
		  }*/
		  strNameExt = finder.GetFileName();//得到文件名字,带扩展名
		  strName = strNameExt.Right( 3 );//得到扩展名
		  if( 0 != strName.CompareNoCase(m_strImageExt) )//如果扩展名不匹配
			  continue;	  
		  nTemp = strNameExt.GetLength();
		  if( 0 == m_FileNameExtList.GetCount() )//第一个图像文件
			  nFirstLen = nTemp;
		  if( nTemp == nFirstLen )
			m_FileNameExtList.AddTail(strNameExt);
		  if( nTemp-nFirstLen == 1 )
			TwoList.AddTail(strNameExt);
		  if( nTemp-nFirstLen == 2 )
			  ThreeList.AddTail(strNameExt);
		}

		finder.Close();
	//	MessageBox(strAll);
		m_FileNameExtList.AddTail(&TwoList);
		m_FileNameExtList.AddTail(&ThreeList);
	}
	if( m_nDisplayOrSave == 0 )//设定要保存的图像序列的路径
	{
		m_FileNameExtList.RemoveAll();		
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -