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

📄 bmpdoc.cpp

📁 c++写的一个 数字图像处理的程序
💻 CPP
字号:
// BmpDoc.cpp : implementation of the CBmpDoc class
//

#include "stdafx.h"
#include "Bmp.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBmpDoc

IMPLEMENT_DYNCREATE(CBmpDoc, CDocument)

BEGIN_MESSAGE_MAP(CBmpDoc, CDocument)
	//{{AFX_MSG_MAP(CBmpDoc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_FILE_SAVE, OnFileSave)
	ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
	ON_COMMAND(ID_ANTICOLOR, OnAnticolor)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBmpDoc construction/destruction

CBmpDoc::CBmpDoc()
{
	// TODO: add one-time construction code here
    dib=new CDib;
}

CBmpDoc::~CBmpDoc()
{
}

BOOL CBmpDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CBmpDoc serialization

void CBmpDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CBmpDoc diagnostics

#ifdef _DEBUG
void CBmpDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CBmpDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBmpDoc commands

void CBmpDoc::OnFileOpen() 
{
	// TODO: Add your command handler code here
	LPCTSTR lpszFilter="BMP Files(*.bmp)|*.bmp";
	CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,lpszFilter);
	CFile file;
	if(dlg.DoModal()==IDOK)
	{
		filename=dlg.GetPathName();
		dib->readfile(filename);
	} 
	UpdateAllViews(NULL,0,NULL);
}

void CBmpDoc::OnFileSave() 
{
	// TODO: Add your command handler code here
	dib->writefile(filename);
	UpdateAllViews(false);
}

void CBmpDoc::OnFileSaveAs() 
{
	// TODO: Add your command handler code here
	LPCTSTR lpszFilter="BMP Files(*.bmp)|*.bmp|所有文件(*.*)";
	LPCTSTR lpszDefExt="BMP";
    CFileDialog dlg(FALSE,lpszDefExt,NULL,OFN_CREATEPROMPT|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,lpszFilter);
	CString filename1;
	if(dlg.DoModal()==IDCANCEL)
		return;
	filename1=dlg.GetPathName();
	dib->writefile(filename1);
    UpdateAllViews(false);
}

void CBmpDoc::OnAnticolor() 
{
	// TODO: Add your command handler code here
	dib->AtoColor();
    UpdateAllViews(false);
}

⌨️ 快捷键说明

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