bitmap.cpp

来自「VIGASOCO (VIdeo GAmes SOurce COde) Windo」· C++ 代码 · 共 50 行

CPP
50 行
字号
// Bitmap.cpp
//
/////////////////////////////////////////////////////////////////////////////

#include "Bitmap.h"
#include <cassert>

/////////////////////////////////////////////////////////////////////////////
// initialization and cleanup
/////////////////////////////////////////////////////////////////////////////

Bitmap::Bitmap(int width, int height, int bpp)
{
	_width = width;
	_height = height;
	_bpp = bpp;

	_data = new UINT8[width*height*bpp/8];
	clear();
}

Bitmap::~Bitmap()
{
	delete[] _data;
}


void Bitmap::clear()
{
	memset(_data, 0, _width*_height*_bpp/8);
}

/////////////////////////////////////////////////////////////////////////////
// bitmap composition methods
/////////////////////////////////////////////////////////////////////////////

// compose 2 similar bitmaps
void Bitmap::copySimilar(Bitmap *source)
{
	assert((_width == source->_width) && (_height == source->_height));
	assert(_bpp == source->_bpp);

	// copy full bitmap
	memcpy(_data, source->_data, _width*_height*_bpp/8);
}

/////////////////////////////////////////////////////////////////////////////
// drawing methods are in bitmaptemplate.cpp
/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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