www.pudn.com > FINAL.rar > ImageProcessingView.cpp, change:2007-04-29,size:3867b


// ImageProcessingView.cpp : implementation of the CImageProcessingView class 
// 
 
#include "stdafx.h" 
#include "ImageProcessing.h" 
 
#include "ImageProcessingDoc.h" 
#include "ImageProcessingView.h" 
#include  "GlobalApi.h" 
#include <complex> 
 
#include "DlgMosaics.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView 
 
IMPLEMENT_DYNCREATE(CImageProcessingView, CScrollView) 
 
BEGIN_MESSAGE_MAP(CImageProcessingView, CScrollView) 
	//{{AFX_MSG_MAP(CImageProcessingView) 
	ON_COMMAND(ID_MOSAIC, OnMosaic) 
	//}}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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView construction/destruction 
 
CImageProcessingView::CImageProcessingView() 
{ 
 
} 
 
CImageProcessingView::~CImageProcessingView() 
{ 
 
} 
 
BOOL CImageProcessingView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CScrollView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView drawing 
 
void CImageProcessingView::OnDraw(CDC* pDC) 
{ 
	CImageProcessingDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	 
	CSize sizeDibDisplay;		 
	 
 
	 
	if(!pDoc->m_pDibInit->IsEmpty()){	 
		sizeDibDisplay = pDoc->m_pDibInit->GetDimensions(); 
		pDoc->m_pDibInit->Draw(pDC,CPoint(0,0),sizeDibDisplay);	 
	}	 
 
} 
 
 
 
void CImageProcessingView::OnInitialUpdate() 
{ 
	CScrollView::OnInitialUpdate(); 
 
	CImageProcessingDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	 
	CSize sizeTotal = pDoc->m_pDibInit->GetDimensions(); 
	SetScrollSizes(MM_TEXT, sizeTotal); 
 
	GetParentFrame()->RecalcLayout(); 
	ResizeParentToFit(); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView printing 
 
BOOL CImageProcessingView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CImageProcessingView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CImageProcessingView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView diagnostics 
 
#ifdef _DEBUG 
void CImageProcessingView::AssertValid() const 
{ 
	CScrollView::AssertValid(); 
} 
 
void CImageProcessingView::Dump(CDumpContext& dc) const 
{ 
	CScrollView::Dump(dc); 
} 
 
CImageProcessingDoc* CImageProcessingView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CImageProcessingDoc))); 
	return (CImageProcessingDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CImageProcessingView message handlers 
 
 
void CImageProcessingView::OnMosaic()  
{ 
	// TODO: Add your command handler code here 
	// 获得文档类句柄 
	CImageProcessingDoc* pDoc; 
	pDoc = GetDocument(); 
 
	// 判断是否是8-bpp位图(这里为了方便,只处理8-bpp位图的水平镜像,其它的可以类推) 
	if(pDoc->m_pDibInit->m_nColorTableEntries != 256) 
	{ 
		// 提示用户 
		MessageBox("目前只支持256色位图的图象配准!", "系统提示" ,  
			MB_ICONINFORMATION | MB_OK); 
		 
		// 返回 
		return; 
	} 
	 
	// 打开图象配准对话框 
	CDlgMosaics* pDlg=new CDlgMosaics(NULL,pDoc); 
 
	pDlg->DoModal(); 
 
	delete pDlg; 
 
	 
}