1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#ifndef _CLCDGfx_H_
#define _CLCDGfx_H_
enum ETransitionType {TRANSITION_FADE,TRANSITION_VLINES,TRANSITION_HLINES,TRANSITION_MORPH,TRANSITION_RANDOM};
struct SLCDPixel
{
COLORREF cValue;
double dSpeed;
POINT Start;
POINT Destination;
POINT Position;
};
class CLCDGfx
{
public:
CLCDGfx(void);
virtual ~CLCDGfx(void);
bool Initialize(int nWidth, int nHeight, int nBPP, uint8_t *pBitmapBits);
bool IsInitialized();
bool Shutdown(void);
void BeginDraw(void);
void ClearScreen(void);
COLORREF GetPixel(int nX, int nY);
void SetPixel(int nX, int nY, COLORREF color);
void SetPixel(int nX, int nY, uint8_t r, uint8_t g, uint8_t b);
void DrawLine(int nX1, int nY1, int nX2, int nY2);
void DrawFilledRect(int nX, int nY, int nWidth, int nHeight);
void DrawRect(int iX, int iY, int iWidth, int iHeight);
void DrawText(int nX, int nY, LPCTSTR sText);
void DrawText(int nX, int nY, int iWidth, tstring strText);
void DrawBitmap(int nX, int nY, int nWidth, int nHeight, HBITMAP hBitmap);
void EndDraw(void);
void SetClipRegion(int iX, int iY, int iWidth, int iHeight);
RECT GetClipRegion();
inline int GetClipWidth() { return m_rClipRegion.right - m_rClipRegion.left; };
inline int GetClipHeight() { return m_rClipRegion.bottom - m_rClipRegion.top; };
HDC GetHDC(void);
BITMAPINFO *GetBitmapInfo(void);
HBITMAP GetHBITMAP(void);
void StartTransition(ETransitionType eType = TRANSITION_RANDOM, LPRECT rect = nullptr);
protected:
void Cache();
int findNearestMatch(uint8_t *targetArray, int iSourceIndex);
void EndTransition();
RECT m_rClipRegion;
RECT m_rTransitionRegion;
int m_nWidth;
int m_nHeight;
int m_nBPP;
BITMAPINFO *m_pBitmapInfo;
HDC m_hDC;
HBITMAP m_hBitmap;
HBITMAP m_hPrevBitmap;
uint8_t *m_pBitmapBits, *m_pLcdBitmapBits, *m_pSavedBitmapBits;
bool m_bInitialized;
DWORD m_dwTransitionStart;
bool m_bTransition;
ETransitionType m_eTransition;
vector<SLCDPixel*> m_LMovingPixels;
vector<SLCDPixel*> m_LStaticPixels;
double m_dWave;
DWORD m_dwLastDraw;
};
#endif
|