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

📄 dialoggetimg.cpp

📁 本程序主要完成pic到tif图像格式的转换(由图象格式转换菜单实现)并且完成了读写pic,tif图像文件的源代码。File/open菜单完成在原始图中获取任意位置和大小的图像。
💻 CPP
字号:
// DialogGetImg.cpp : implementation file
#include "stdafx.h"
#include "convert.h"
#include "DialogGetImg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialogGetImg dialog


CDialogGetImg::CDialogGetImg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogGetImg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogGetImg)
	m_file = _T("");
	m_height = 0;
	m_xleft = 0;
	m_ytop = 0;
	m_width = 0;
	m_oriHeight = 0;
	m_oriWidth = 0;
	//}}AFX_DATA_INIT
}


void CDialogGetImg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogGetImg)
	DDX_Text(pDX, IDC_EDIT_NAME, m_file);
	DDV_MaxChars(pDX, m_file, 100);
	DDX_Text(pDX, IDC_GET_HEIGHT, m_height);
	DDX_Text(pDX, IDC_GET_LEFT, m_xleft);
	DDX_Text(pDX, IDC_GET_TOP, m_ytop);
	DDX_Text(pDX, IDC_GET_WIDTH, m_width);
	DDX_Text(pDX, IDC_ORI_HEIGHT, m_oriHeight);
	DDX_Text(pDX, IDC_ORI_WIDTH, m_oriWidth);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogGetImg, CDialog)
	//{{AFX_MSG_MAP(CDialogGetImg)
	ON_BN_CLICKED(IDC_BUTTON2, OnButtonDown)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogGetImg message handlers

BOOL CDialogGetImg::OnInitDialog() 
{
	CDialog::OnInitDialog();
   
	// TODO: Add extra initialization here
	m_file="...";
	m_height=0;
	m_width=0;
	m_xleft=0;
	m_ytop=0;
	m_oriHeight=0;
	m_oriWidth=0;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialogGetImg::OnButtonDown() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);                //it must be here

	CFileDialog	selectFile(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"Tif Files (*.tif)|*.tif|Pic Files (*.pic)|*.pic||",NULL);
    if(selectFile.DoModal()==IDOK)
	{
		m_file=selectFile.GetPathName();

		UpdateData(FALSE);           //将EDIT编辑框的值显示在对话框中
	
        if(m_file=="..."||m_height==0||m_width==0||
			(m_xleft+m_width)>m_oriWidth||(m_ytop+m_height)>m_oriHeight)
		{
		   MessageBox("please check whether the filename and the image size is correct or not!",
			   NULL,MB_ICONSTOP);
		          //	exit(1);    //this will cause error!!!
		}
		TRACE("%d,%d",m_height,m_width);
	}
}

⌨️ 快捷键说明

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