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