CPixelRGB8.cpp
上传用户:hhs829
上传日期:2022-06-17
资源大小:586k
文件大小:1k
- //
- // CPixelRGB8.cpp
- //
- #include <streams.h>
- #include <olectl.h>
- #include "CBasePixel.h"
- #include "CPixelRGB8.h"
- //////////////////////////////////////////////////////////////////////
- CPixelRGB8::CPixelRGB8() :
- m_nPaletteEntry(10)
- {
- }
- CPixelRGB8::~CPixelRGB8()
- {
- }
- void CPixelRGB8::ConvertByCover(unsigned char * inPixel)
- {
- if (inPixel)
- {
- *inPixel = m_nPaletteEntry;
- }
- }
- void CPixelRGB8::SideEffectColorChanged(void)
- {
- CBasePixel::SideEffectColorChanged();
- SetPaletteEntries();
- }
- //
- // SetPaletteEntries
- //
- // If we set our palette to the current system palette + the colours we want
- // the system has the least amount of work to do whilst plotting our images,
- // if this stream is rendered to the current display. The first non reserved
- // palette slot is at m_Palette[10], so put our first colour there. Also
- // guarantees that black is always represented by zero in the frame buffer
- //
- bool CPixelRGB8::SetPaletteEntries(void)
- {
- PALETTEENTRY m_Palette[256];
- HDC hdc = GetDC(NULL); // hdc for the current display.
- UINT res = GetSystemPaletteEntries(hdc, 0, iPALETTE_COLORS, (LPPALETTEENTRY) &m_Palette);
- ReleaseDC(NULL, hdc);
- if (res != 0)
- {
- m_Palette[m_nPaletteEntry].peBlue = m_TargetB;
- m_Palette[m_nPaletteEntry].peGreen = m_TargetG;
- m_Palette[m_nPaletteEntry].peRed = m_TargetR;
- m_Palette[m_nPaletteEntry].peFlags = 0;
- return true;
- }
- return false;
- } // SetPaletteEntries