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

📄 wzdbtmap.cpp

📁 《vc++扩展编程实例》源码。运用Visual C++ 5.0或6.0的高级编程技巧
💻 CPP
字号:
// WzdBtmap.cpp : implementation of the CWzdBitmap class
//

#include "stdafx.h"
#include "WzdBtmap.h"
#include "resource.h"

/////////////////////////////////////////////////////////////////////////////
// CWzdBitmap

IMPLEMENT_DYNAMIC(CWzdBitmap, CBitmap)


CWzdBitmap::CWzdBitmap()
{
}

CWzdBitmap::~CWzdBitmap()
{
}

CBitmap *CWzdBitmap::Stretch(int nWidth, int nHeight, int nMode)
{
	CDC dcTo,dcFrom,dcScreen;
	dcScreen.Attach(::GetDC(NULL));

	// create "from" device context and select the loaded bitmap into it
	dcFrom.CreateCompatibleDC(&dcScreen);
	dcFrom.SelectObject(this);

	// create a "to" device context select a memory bitmap into it
	dcTo.CreateCompatibleDC(&dcScreen);
	CBitmap *pBitmap=new CBitmap;
	pBitmap->CreateCompatibleBitmap(&dcScreen, nWidth, nHeight);
	dcTo.SelectObject(pBitmap);

	// get original bitmap size
	BITMAP bmInfo;
	GetObject(sizeof(bmInfo),&bmInfo);

	// set the stretching mode
	dcTo.SetStretchBltMode(nMode);
	
	// stretch loaded bitmap into memory bitmap
	dcTo.StretchBlt( 0, 0, nWidth, nHeight, 
				 &dcFrom, 0, 0, bmInfo.bmWidth, bmInfo.bmHeight, SRCCOPY );

	// delete and release device contexts
	dcTo.DeleteDC();
	dcFrom.DeleteDC();
	::ReleaseDC(NULL, dcScreen.Detach());

	// it's up to the caller to delete this new bitmap
	return pBitmap;
	
}

⌨️ 快捷键说明

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