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

📄 showimg.cpp

📁 车牌识别(改定位)武汉理工大学
💻 CPP
字号:
// ShowImg.cpp : implementation file
//

#include "stdafx.h"
#include "ShowImg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CShowImg dialog


CShowImg::CShowImg(void * pImg,CWnd* pParent /*=NULL*/)
	: CDialog(CShowImg::IDD, pParent)
{
	ASSERT(pImg);
	m_pImg = pImg;
	//{{AFX_DATA_INIT(CShowImg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CShowImg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShowImg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShowImg, CDialog)
	//{{AFX_MSG_MAP(CShowImg)
	ON_WM_SIZE()
	ON_WM_PAINT()
	ON_COMMAND(ID_MENU_SAVE, OnMenuSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowImg message handlers

void CShowImg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	InvalidateRect(NULL);
}

void CShowImg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rcClient;
	GetClientRect(rcClient);
	((CImage*)m_pImg)->Draw(&dc,CPoint(0,0),CSize(rcClient.Width(),rcClient.Height()),FALSE,TRUE);
}

BOOL CShowImg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CRect rcWin;
	GetWindowRect(rcWin);
	int nWidth = ((CImage*)m_pImg)->GetWidth();
	nWidth = nWidth<100?100:nWidth;
	nWidth = nWidth>1024?1024:nWidth;
	int nHeight = ((CImage*)m_pImg)->GetHeight();
	nHeight = nHeight<100?100:nHeight;
	nHeight = nHeight>768?768:nHeight;
	MoveWindow(rcWin.left,rcWin.top,nWidth+2,nHeight+20);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CShowImg::OnMenuSave() 
{	
	char szFilter[] = "BMP Files (*.bmp)|*.bmp||";
	CFileDialog     fd(FALSE,"*.bmp",NULL,0,szFilter,this);
	if (!m_pImg) 
	{
		return;		
	}
	if (fd.DoModal()==IDOK) 
	{
		((CImage*)m_pImg)->SaveBMP(fd.GetPathName());
	}
}

⌨️ 快捷键说明

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