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

📄 图象处理diyview.cpp

📁 图像处理(各种基本图像算法的实现)包括各种几何变换
💻 CPP
字号:
// 图象处理DIYView.cpp : implementation of the CDIYView class
//

#include "stdafx.h"
#include "图象处理DIY.h"

#include "图象处理DIYDoc.h"
#include "图象处理DIYView.h"
#include "zft.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDIYView

IMPLEMENT_DYNCREATE(CDIYView, CView)

BEGIN_MESSAGE_MAP(CDIYView, CView)
	//{{AFX_MSG_MAP(CDIYView)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_Color_To_Gray1, OnColor_To_Gray1)
	ON_COMMAND(ID_Color_To_Gray2, OnColor_To_Gray2)
	ON_COMMAND(ID_Color_To_Gray3, OnColor_To_Gray3)
	ON_COMMAND(ID_Roberts, OnRoberts)
	ON_COMMAND(ID_middle, Onmiddle)
	ON_COMMAND(ID_soble, Onsoble)
	ON_COMMAND(ID_chuizhi, Onchuizhi)
	ON_COMMAND(ID_shuiping, Onshuiping)
	ON_COMMAND(ID_FenGe, OnFenGe)
	ON_COMMAND(ID_zft, Onzft)
	ON_COMMAND(ID_Prewitt, OnPrewitt)
	ON_COMMAND(ID_Kirsch, OnKirsch)
	ON_COMMAND(ID_suoxiao, Onsuoxiao)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDIYView construction/destruction

CDIYView::CDIYView()
{
	// TODO: add construction code here

}

CDIYView::~CDIYView()
{
}

BOOL CDIYView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDIYView drawing

void CDIYView::OnDraw(CDC* pDC)
{
	CDIYDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
     m_Bitmap.DrawDIB(pDC,50,50);
}

/////////////////////////////////////////////////////////////////////////////
// CDIYView printing

BOOL CDIYView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDIYView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDIYView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDIYView diagnostics

#ifdef _DEBUG
void CDIYView::AssertValid() const
{
	CView::AssertValid();
}

void CDIYView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CDIYDoc* CDIYView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDIYDoc)));
	return (CDIYDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDIYView message handlers

void CDIYView::OnFileOpen() 
{
	// TODO: Add your command handler code here
  CFileDialog  fileOpenDlg(TRUE,"bmp","*.bmp",NULL,"Bitmap File(*.bmp)",NULL);
  int nRespond=fileOpenDlg.DoModal();
  if(nRespond=IDOK)
  {
	  CString filePath=fileOpenDlg.GetPathName();
	  m_Bitmap.Load(filePath);
  }
    Invalidate();
	
}


void CDIYView::OnColor_To_Gray1() 
{
	// TODO: Add your command handler code here
	m_Bitmap.Color_To_Gray1();
    Invalidate();
}

void CDIYView::OnColor_To_Gray2() 
{
	// TODO: Add your command handler code here
	m_Bitmap.Color_To_Gray2();
    Invalidate();
}

void CDIYView::OnColor_To_Gray3() 
{
	// TODO: Add your command handler code here
		m_Bitmap.Color_To_Gray3();
        Invalidate();
}

void CDIYView::OnRoberts() 
{
	// TODO: Add your command handler code here
	 m_Bitmap.Roberts();
     Invalidate();
}

void CDIYView::Onmiddle() 
{
	// TODO: Add your command handler code here
	 m_Bitmap.middle();
     Invalidate();
}

void CDIYView::Onsoble() 
{
	// TODO: Add your command handler code here
	m_Bitmap.sobel();
    Invalidate();
}

void CDIYView::Onchuizhi() 
{
	// TODO: Add your command handler code here
	m_Bitmap.chuizhi();
    Invalidate();
}

void CDIYView::Onshuiping() 
{
	// TODO: Add your command handler code here
	m_Bitmap.shuiping();
    Invalidate();
}

void CDIYView::OnFenGe() 
{
	// TODO: Add your command handler code here
	m_Bitmap.FenGe();
    Invalidate();
}

void CDIYView::Onzft() 
{
	// TODO: Add your command handler code here
	Czft dlg;
	dlg.m_pBitmap=&m_Bitmap;
	dlg.DoModal();

}

void CDIYView::OnPrewitt() 
{
	// TODO: Add your command handler code here
		m_Bitmap.Prewitt();
        Invalidate();
}

void CDIYView::OnKirsch() 
{
	// TODO: Add your command handler code here
	 m_Bitmap.Kirsch();
        Invalidate();
}

void CDIYView::Onsuoxiao() 
{
	// TODO: Add your command handler code here
	 m_Bitmap.suoxiao();
        Invalidate();
}

⌨️ 快捷键说明

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