📄 testview.cpp
字号:
// TestView.cpp : implementation of the CTestView class
//
#include "stdafx.h"
#include "Test.h"
#include "TestDoc.h"
#include "TestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestView
IMPLEMENT_DYNCREATE(CTestView, CScrollView)
BEGIN_MESSAGE_MAP(CTestView, CScrollView)
//{{AFX_MSG_MAP(CTestView)
ON_COMMAND(ID_SumConstant, OnSumConstant)
ON_COMMAND(ID_OnSubstractConstant, OnOnSubstractConstant)
ON_COMMAND(ID_OnMultipleConstant, OnOnMultipleConstant)
ON_COMMAND(ID_DivideConstant, OnDivideConstant)
ON_COMMAND(ID_SUMIMAGE, OnSumimage)
ON_COMMAND(ID_SUBSTRACTIMAGE, OnSubstractimage)
ON_COMMAND(ID_MUTIPLEIMAGE, OnMutipleimage)
ON_COMMAND(ID_DIVIDEIMAGE, OnDivideimage)
ON_COMMAND(ID_REVERSEIMAGE, OnReverseimage)
ON_COMMAND(ID_COMPLEMENTIMAGE, OnComplementimage)
ON_COMMAND(ID_ZOOMIN, OnZoomin)
ON_COMMAND(ID_ZOOMOUT, OnZoomout)
ON_COMMAND(ID_ROTATE, OnRotate)
ON_COMMAND(ID_FLIP, OnFlip)
ON_COMMAND(ID_MIRR, OnMirr)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestView construction/destruction
CTestView::CTestView()
{
// TODO: add construction code here
}
CTestView::~CTestView()
{
}
BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTestView drawing
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x=0;
int y =0;
for( y = 0; y<256; y++)
{
for( x =0; x<256; x++)
{
pDC->SetPixel(x+300,y+300,RGB(pDoc->m_BufferImage1[y][x],
pDoc->m_BufferImage1[y][x],
pDoc->m_BufferImage1[y][x]));
}
}
for(y = 0; y<256; y++)
{
for( x=0; x<256; x++)
{
pDC->SetPixel(x,y+300,RGB(pDoc->m_BufferImage2[y][x],
pDoc->m_BufferImage2[y][x],
pDoc->m_BufferImage2[y][x])); // 滴锅掳 磊丰 弊覆.
}
}
for( y = 0; y<256; y++)
{
for( x=0; x<256; x++)
{
pDC->SetPixel(x,y,RGB(pDoc->m_OpenImg[y][x],
pDoc->m_OpenImg[y][x],
pDoc->m_OpenImg[y][x]));
/*
pDC->SetPixel(x,y,RGB(pDoc->m_BufferImage1[y][x],
pDoc->m_BufferImage1[y][x],
pDoc->m_BufferImage1[y][x])); // 夸锅波 且锭 m_BufferImage1静绰芭.*/
}
}
if(zoom != 1 && zoom !=2)
{
for(y = 0; y<256; y++)
{
for(x=0; x<256; x++)
{
pDC->SetPixel(x+300,y,RGB(pDoc->m_ResultImg[y][x],
pDoc->m_ResultImg[y][x],
pDoc->m_ResultImg[y][x]));
/*
pDC->SetPixel(x+300,y,RGB(pDoc->m_BufferImage2[y][x],
pDoc->m_BufferImage2[y][x],
pDoc->m_BufferImage2[y][x])); // 滴锅掳 磊丰 弊覆.
*/
}
}
}
if(zoom ==1)
{
for(y = 0; y<scale_y*256; y++)
{
for( x=0; x<scale_x*256; x++)
{
pDC->SetPixel(x+300,y,RGB(pDoc->m_scaleImg[y][x],
pDoc->m_scaleImg[y][x],
pDoc->m_scaleImg[y][x])); //Saturation operating
}
}
zoom=0;
}
if(zoom==2)
{
for(y=0; y<scale_y2*256; y++)
{
for(x = 0; x<scale_x2*256;x++)
{
pDC->SetPixel(x+300,y,RGB(pDoc->m_scaleImg2[y][x],
pDoc->m_scaleImg2[y][x],
pDoc->m_scaleImg2[y][x])); //Saturation operating
}
}
zoom = 0;
}
}
void CTestView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
/* CTestDoc* pDoc=GetDocument();
for(int x=0; x<512; x++)
{
for(int y=0; y<512; y++)
{
m_ViewImg[x][y]=pDoc->m_OpenImg[x][y];
}
} */
}
/////////////////////////////////////////////////////////////////////////////
// CTestView printing
BOOL CTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTestView diagnostics
#ifdef _DEBUG
void CTestView::AssertValid() const
{
CScrollView::AssertValid();
}
void CTestView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CTestDoc* CTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)));
return (CTestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTestView message handlers
void CTestView::OnSumConstant()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->OnSumConstant();
Invalidate(FALSE);
}
void CTestView::OnOnSubstractConstant()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->OnOnSubstractConstant();
Invalidate(FALSE);
}
void CTestView::OnOnMultipleConstant()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->OnOnMultipleConstant();
Invalidate(FALSE);
}
void CTestView::OnDivideConstant()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->OnDivideConstant();
Invalidate(FALSE);
}
void CTestView::OnSumimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->SumImage();
Invalidate(FALSE);
}
void CTestView::OnSubstractimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->SubstractImage();
Invalidate(FALSE);
}
void CTestView::OnMutipleimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->MutipleImage();
Invalidate(FALSE);
}
void CTestView::OnDivideimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->DivideImage();
Invalidate(FALSE);
}
void CTestView::OnReverseimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->ReverseImage();
Invalidate(FALSE);
}
void CTestView::OnComplementimage()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->ComplementImage();
Invalidate(FALSE);
}
void CTestView::OnZoomin()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Zoomin();
//康惑 犬措矫 胶农费官 裹困 函版
CSize sizeTotal;
sizeTotal .cx = 300+256*scale_x;
sizeTotal .cy = 256*scale_y;
SetScrollSizes(MM_TEXT, sizeTotal);
zoom = 1;
Invalidate(FALSE);
}
void CTestView::OnZoomout()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Zoomout();
zoom = 2;
Invalidate(TRUE);
}
void CTestView::OnRotate()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Rotate();
Invalidate(TRUE);
}
void CTestView::OnFlip()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Flip();
Invalidate(TRUE);
}
void CTestView::OnMirr()
{
// TODO: Add your command handler code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Mirr();
Invalidate(TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -