CPixelRGB565.cpp
上传用户:hhs829
上传日期:2022-06-17
资源大小:586k
文件大小:1k
- //
- // CPixelRGB565.cpp
- //
- #include "CBasePixel.h"
- #include "CPixelRGB565.h"
- //////////////////////////////////////////////////////////////////////
- CPixelRGB565::CPixelRGB565()
- {
- }
- CPixelRGB565::~CPixelRGB565()
- {
- }
- void CPixelRGB565::ConvertByCover(unsigned char * inPixel)
- {
- if (inPixel)
- {
- *inPixel = m_Mask[0];
- inPixel++;
- *inPixel = m_Mask[1];
- }
- }
- void CPixelRGB565::SideEffectColorChanged(void)
- {
- CBasePixel::SideEffectColorChanged();
- const unsigned int bits565[] = {0xF800, 0x07E0, 0x001F}; // RGB
- // Caculate the mask bits
- unsigned int wMask, wTemp;
- wTemp = unsigned int (m_TargetB / 256. * 32);
- wMask = wTemp & bits565[2];
- wTemp = unsigned int (m_TargetG / 256. * 64);
- wTemp = wTemp << 5;
- wMask += wTemp & bits565[1];
- wTemp = unsigned int (m_TargetR / 256. * 32);
- wTemp = wTemp << 11;
- wMask += wTemp & bits565[0];
- // Store the high byte and low byte seperately
- m_Mask[0] = wMask & 0xff;
- wMask = wMask >> 8;
- m_Mask[1] = wMask & 0xff;
- }