mycolor.cpp

来自「在代码中演示使用C++开发的BREW端方便的程序 非常值得初学者学习.」· C++ 代码 · 共 64 行

CPP
64
字号
// Color.cpp: implementation of the CColor class.
//
//////////////////////////////////////////////////////////////////////

#include "myColor.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CColor::CColor()
{
	m_nCol = BLACK;
}

CColor::CColor(RGBVAL clr)
{
	m_nCol = clr;
}

CColor::~CColor()
{

}

/* an RGBVAL is layed out within a single word (4 bytes) as follows:
--------------------------------
3322222222221111111111
10987654321098765432109876543210
--------------------------------
bbbbbbbbggggggggrrrrrrrr********
--------------------------------
*/

uint8 CColor::getr() const
{
	uint32 c = m_nCol;
	c <<= 16;
	c >>= 24;
	return (uint8) c;
}

uint8 CColor::getg() const
{
	uint32 c = m_nCol;
	c <<= 8;
	c >>= 24;
	return (uint8) c;
}

uint8 CColor::getb() const
{
	uint32 c = m_nCol;
	c >>= 24;
	return (uint8) c;

}

void CColor::setColor(RGBVAL clr)
{
	m_nCol = clr;
}

⌨️ 快捷键说明

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