📄 expressview.cpp
字号:
// ExpressView.cpp : implementation of the CExpressView class
//
#include "stdafx.h"
#include "Express.h"
#include "Video.h"
#include "ExpressDoc.h"
#include "ExpressView.h"
#include "MainFrm.h"
#include "ImgCenterDib.h"
#include "GrayTrans.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExpressView
IMPLEMENT_DYNCREATE(CExpressView, CView)
BEGIN_MESSAGE_MAP(CExpressView, CView)
//{{AFX_MSG_MAP(CExpressView)
ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)
ON_COMMAND(ID_MENUITEM32772, OnColorToGray)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CExpressView construction/destruction
CExpressView::CExpressView()
{
// TODO: add construction code here
}
CExpressView::~CExpressView()
{
}
BOOL CExpressView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CExpressView drawing
void CExpressView::OnDraw(CDC* pDC)
{
CExpressDoc* pDoc = GetDocument();
//ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
ImgCenterDib *PDib=pDoc->GetPDib();
CSize sizeFileDib=PDib->GetDimensions();
PDib->Draw(pDC,CPoint(0,0),sizeFileDib);
}
/////////////////////////////////////////////////////////////////////////////
// CExpressView printing
BOOL CExpressView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CExpressView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CExpressView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CExpressView diagnostics
#ifdef _DEBUG
void CExpressView::AssertValid() const
{
CView::AssertValid();
}
void CExpressView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CExpressDoc* CExpressView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExpressDoc)));
return (CExpressDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExpressView message handlers
void CExpressView::OnMenuitem32771()
{
// TODO: Add your command handler code here
CVideo video;
video.DoModal();
}
void CExpressView::OnColorToGray()
{
// TODO: Add your command handler code here
CExpressDoc *pDoc=GetDocument();
ImgCenterDib *pDib=pDoc->GetPDib();
if (pDib->m_nBitCount!=24)
{
::MessageBox(0,"只处理彩色图像",MB_OK,0);
return;
}
GrayTrans graytrans(pDib->GetDimensions(),pDib->m_nBitCount,
pDib->m_lpColorTable,pDib->m_pImgData);
graytrans.ColorToGray();
CMainFrame *pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);
pFrame->SendMessage(WM_COMMAND,ID_FILE_NEW);
CExpressView *pView=(CExpressView*)pFrame->MDIGetActive()->GetActiveView();
CExpressDoc *pDocNew=pView->GetDocument();
ImgCenterDib *dibNew=pDocNew->GetPDib();
dibNew->ReplaceDib(graytrans.GetDimensions(),graytrans.m_nBitCountOut,
graytrans.m_lpColorTableOut,graytrans.m_pImgDataOut);
pView->OnInitialUpdate();
pDocNew->SetModifiedFlag(TRUE);
pDocNew->UpdateAllViews(pView);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -