myColor.cpp
资源名称:Shapes.zip [点击查看]
上传用户:wenshuihe
上传日期:2007-01-14
资源大小:10k
文件大小:1k
源码类别:
BREW编程
开发平台:
Visual C++
- // 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;
- }