www.pudn.com > readBmp.rar.rar > fgbmptestView.cpp


// fgbmptestView.cpp : implementation of the CFgbmptestView class 
// 
 
#include "stdafx.h" 
#include "fgbmptest.h" 
 
#include "fgbmptestDoc.h" 
#include "fgbmptestView.h" 
#include "fg_dib.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView 
 
IMPLEMENT_DYNCREATE(CFgbmptestView, CView) 
 
BEGIN_MESSAGE_MAP(CFgbmptestView, CView) 
	//{{AFX_MSG_MAP(CFgbmptestView) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
		//    DO NOT EDIT what you see in these blocks of generated code! 
	//}}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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView construction/destruction 
 
CFgbmptestView::CFgbmptestView() 
{ 
	// TODO: add construction code here 
 
} 
 
CFgbmptestView::~CFgbmptestView() 
{ 
} 
 
BOOL CFgbmptestView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView drawing 
 
void CFgbmptestView::OnDraw(CDC* pDC) 
{ 
	CFgbmptestDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
 
	CFG_DIB m_fgdib; 
	CFile* pf; 
	pf = new CFile; 
	//change the file path!!! 
	pf->Open("clouds.bmp", CFile::modeRead); 
	m_fgdib.ReadFile(pf); 
	pf->Close(); 
	delete pf; 
	//draw BMP 
	m_fgdib.m_Dest.x = 0; 
	m_fgdib.m_Dest.y = 0; 
	m_fgdib.m_DestSize.cx = m_fgdib.GetWidth(); 
	m_fgdib.m_DestSize.cy = m_fgdib.GetHeight(); 
	m_fgdib.m_Src.x = 0; 
	m_fgdib.m_Src.y = 0; 
	m_fgdib.m_SrcSize.cx = m_fgdib.GetWidth(); 
	m_fgdib.m_SrcSize.cy = m_fgdib.GetHeight(); 
	m_fgdib.Display(pDC); 
	//close BMP 
	m_fgdib.CloseFile(); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView printing 
 
BOOL CFgbmptestView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CFgbmptestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CFgbmptestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView diagnostics 
 
#ifdef _DEBUG 
void CFgbmptestView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CFgbmptestView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CFgbmptestDoc* CFgbmptestView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFgbmptestDoc))); 
	return (CFgbmptestDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CFgbmptestView message handlers