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

📄 viewdibdoc.cpp

📁 vc++实现简单图像编辑器。。。。。。。。。
💻 CPP
字号:
// ViewDIBDoc.cpp : implementation of the CViewDIBDoc class
//

#include "stdafx.h"
#include "ViewDIB.h"
#include "DibAPI.h"
#include "ViewDIBDoc.h"

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

#include <fstream.h>
#include "SeleCutRectDlg.h"

/////////////////////////////////////////////////////////////////////////////
// CViewDIBDoc

IMPLEMENT_DYNCREATE(CViewDIBDoc, CDocument)

BEGIN_MESSAGE_MAP(CViewDIBDoc, CDocument)
	//{{AFX_MSG_MAP(CViewDIBDoc)
	ON_COMMAND(ID_VIEW_PALETTE, OnViewPalette)
	ON_COMMAND(ID_VIEW_IMAGE, OnViewImage)
	ON_COMMAND(ID_MATRIX_CUT, OnMatrixCut)
	ON_COMMAND(ID_MATRIX_ROTATE, OnMatrixRotate)
	ON_COMMAND(ID_MATRIX_ROTATELEFT, OnMatrixRotateleft)
	ON_COMMAND(ID_EFFECT_CHANGEPALETTE, OnEffectChangepalette)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CViewDIBDoc construction/destruction

CViewDIBDoc::CViewDIBDoc()
{
//ffffffffffffffffffffffffffffffffffff
	m_pDib=new CDib;
	m_nEffect=0;
	m_pResultDib=new CDib;
//jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

}

CViewDIBDoc::~CViewDIBDoc()
{
}

BOOL CViewDIBDoc::OnNewDocument()
{

	if (!CDocument::OnNewDocument())
		return FALSE;

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CViewDIBDoc serialization

void CViewDIBDoc::Serialize(CArchive& ar)
{
	m_pDib->Serialize (ar);
	m_pResultDib->Serialize (ar);
}

/////////////////////////////////////////////////////////////////////////////
// CViewDIBDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CViewDIBDoc commands

BOOL CViewDIBDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	blPal=FALSE;
	
	return TRUE;
}

BOOL CViewDIBDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDocument::OnSaveDocument(lpszPathName);
}

void CViewDIBDoc::OnViewPalette() 
{
	if(m_pResultDib->IsEmpty ())
		return;//must be new document
	if(!m_pResultDib->m_pPalette)
	{
	   AfxMessageBox("There is no palette for this kind of bitmap");
	   return;
	 }
	blPal=TRUE;
	UpdateAllViews(NULL);
}

void CViewDIBDoc::OnViewImage() 
{
   blPal=FALSE;
   UpdateAllViews(NULL);
}

void CViewDIBDoc::OnMatrixCut() 
{
CString strWidth,strHeight;

	strWidth.Format ("%d",m_pResultDib ->GetWidth ());
	strHeight.Format ("%d",m_pResultDib ->GetHeight ());

	CSeleCutRectDlg dlg;
	dlg.m_width =strWidth;
	dlg.m_height=strHeight;
	dlg.m_left =0;
	dlg.m_right =atoi(strWidth);
	dlg.m_top=0;
	dlg.m_bottom =atoi(strHeight);

	if(dlg.DoModal ()==IDOK)
	{
	
	IMGMATRIX*  img,*img1=NULL;
	img=m_pResultDib->ChangeToMatrix();
	img1=LayoutMatrix(img,dlg.m_left ,dlg.m_top,
		              dlg.m_right,dlg.m_bottom);
	m_pResultDib->ChangeFromMatrix(img1);
	UpdateAllViews(NULL);
	delete img;
	delete img1;
	}	
}

void CViewDIBDoc::OnMatrixRotate() 
{
    IMGMATRIX*  img,*img1=NULL;
	img=m_pResultDib->ChangeToMatrix();
	img1=RotateMatrix(img,-3.1415926/20);
	m_pResultDib->ChangeFromMatrix(img1);
	UpdateAllViews(NULL);
	delete img;
	delete img1;	
}

void CViewDIBDoc::OnMatrixRotateleft() 
{
    IMGMATRIX*  img,*img1=NULL;
	img=m_pResultDib->ChangeToMatrix();
	img1=RotateMatrix(img,3.1415926/20);
	m_pResultDib->ChangeFromMatrix(img1);
	UpdateAllViews(NULL);
	delete img;
	delete img1;		
}

void CViewDIBDoc::OnEffectChangepalette() 
{
	// TODO: Add your command handler code here
	m_pResultDib->ModifyColorMap();
	UpdateAllViews(NULL);
   
	
}

⌨️ 快捷键说明

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