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

📄 ddbitmap.cpp

📁 API经典入门
💻 CPP
字号:
// Filename: DDBitmap.cpp

#include "stdafx.h"
#include "DDBitmap.h"

// Constructors & Destructors
CDDBitmap::CDDBitmap()
{
	// Place any one-time construction code here.
}

CDDBitmap::~CDDBitmap()
{
	// Place any destruction code here (i.e. clean-up).
}

// Operations
BOOL CDDBitmap::DrawOnDC (CDC* pDC, int x, int y)
{
	// Note: this function should really call
	// the StretchOnDC() function so as to minimize
	// code duplication.  However, implementing this
	// second method demonstrates the BitBlt()
	// function of the CDC class.

	// make sure the CDC pointer is usable
	ASSERT_VALID(pDC);
	
	// get bitmap info
	BITMAP bm;
	GetObject(sizeof(bm), &bm);
	
	// create bitmap memory context
	CDC dcBM;
	dcBM.CreateCompatibleDC(pDC);
	
	// select the bitmap into the DC
	CBitmap* pOldBM = dcBM.SelectObject(this);
	
	// block transfer the bitmap onto the screen
	BOOL Result = pDC->BitBlt(x, y, bm.bmWidth,
			bm.bmHeight, &dcBM, 0, 0, SRCCOPY);
			
	// return the DC to its original state
	dcBM.SelectObject(pOldBM);
	
	return Result;
}

BOOL CDDBitmap::StretchOnDC (CDC* pDC, 
	int x, int y, int newWidth, int newHeight)
{
	// make sure the CDC pointer is usable
	ASSERT_VALID(pDC);
	
	// get bitmap info
	BITMAP bm;
	GetObject(sizeof(bm), &bm);
	
	// create bitmap memory context
	CDC dcBM;
	dcBM.CreateCompatibleDC(pDC);
	
	// select the bitmap into the DC
	CBitmap* pOldBM = dcBM.SelectObject(this);
	
	// stretch the bitmap onto the screen
	BOOL Result = pDC->StretchBlt(x, y, 
			newWidth, newHeight, &dcBM, 0, 0, 
			bm.bmWidth, bm.bmHeight, SRCCOPY);
			
	// return the DC to its original state
	dcBM.SelectObject(pOldBM);
	
	return Result;
}
		

⌨️ 快捷键说明

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