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

📄 dibview.cpp

📁 本程序为图象处理,可将八位图转换为二十四位图
💻 CPP
字号:
// DIBView.cpp : implementation of the CDIBView class
//

#include "stdafx.h"
#include "DIB.h"

#include "DIBDoc.h"
#include "DIBView.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDIBView

IMPLEMENT_DYNCREATE(CDIBView, CView)

BEGIN_MESSAGE_MAP(CDIBView, CView)
	//{{AFX_MSG_MAP(CDIBView)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDIBView construction/destruction

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

}

CDIBView::~CDIBView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDIBView drawing

void CDIBView::OnDraw(CDC* pDC)
{
	CDIBDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	if(pDoc->Flag)
	{
	LPSTR lpDIB=pDoc->pdib;
	LPBITMAPINFO bitinfo=(LPBITMAPINFO)pDoc->BitInfo;
	
	int XDIB=(int)pDoc->Width;//DIBWidth();
	int YDIB=(int)pDoc->Height;//DIBHeight();

	CString str;
	str.Format("这是视图");
//	AfxMessageBox(str);
	
	HDC hDC=pDC->m_hDC;
				 
	SetDIBitsToDevice(hDC,
	0,
	0,
	XDIB,
	YDIB,
	0,
	0,
	0,
	pDoc->Height,//DIBHeight(),
	pDoc->BitData,
	bitinfo,
	DIB_RGB_COLORS);
	return;
	}
	return;
}

/////////////////////////////////////////////////////////////////////////////
// CDIBView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDIBView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDIBView message handlers


⌨️ 快捷键说明

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