forked from mpc-hc/mpc-hc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCDBitmap.cpp
More file actions
179 lines (146 loc) · 5.25 KB
/
LCDBitmap.cpp
File metadata and controls
179 lines (146 loc) · 5.25 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//************************************************************************
// The Logitech LCD SDK, including all acompanying documentation,
// is protected by intellectual property laws. All use of the Logitech
// LCD SDK is subject to the License Agreement found in the
// "Logitech LCD SDK License Agreement" file and in the Reference Manual.
// All rights not expressly granted by Logitech are reserved.
//************************************************************************
//************************************************************************
//
// LCDBitmap.cpp
//
// The CLCDBitmap class draws bitmaps onto the LCD.
//
// Logitech LCD SDK
//
// Copyright 2010 Logitech Inc.
//************************************************************************
#include "LCDUI.h"
//************************************************************************
//
// CLCDBitmap::CLCDBitmap
//
//************************************************************************
CLCDBitmap::CLCDBitmap(void)
{
m_hBitmap = NULL;
m_dwROP = SRCCOPY;
m_fZoom = 1.0f;
m_bAlpha = TRUE;
}
//************************************************************************
//
// CLCDBitmap::CLCDBitmap
//
//************************************************************************
CLCDBitmap::~CLCDBitmap(void)
{
}
//************************************************************************
//
// CLCDBitmap::SetBitmap
//
//************************************************************************
void CLCDBitmap::SetBitmap(HBITMAP hBitmap)
{
m_hBitmap = hBitmap;
}
//************************************************************************
//
// CLCDBitmap::GetBitmap
//
//************************************************************************
HBITMAP CLCDBitmap::GetBitmap(void)
{
return m_hBitmap;
}
//************************************************************************
//
// CLCDBitmap::SetBitmap
//
//************************************************************************
void CLCDBitmap::SetROP(DWORD dwROP)
{
m_dwROP = dwROP;
}
//************************************************************************
//
// CLCDBitmap::SetZoomLevel
//
//************************************************************************
void CLCDBitmap::SetZoomLevel(float fzoom)
{
m_fZoom = fzoom;
}
//************************************************************************
//
// CLCDBitmap::GetZoomLevel
//
//************************************************************************
float CLCDBitmap::GetZoomLevel(void)
{
return m_fZoom;
}
//************************************************************************
//
// CLCDBitmap::SetAlpha
//
//************************************************************************
void CLCDBitmap::SetAlpha(BOOL bAlpha)
{
m_bAlpha = bAlpha;
}
//************************************************************************
//
// CLCDBitmap::OnDraw
//
// The logical size is our 'canvas'.
// The control size is our 'window'. The window size can be smaller than the canvas.
// The assumption is that the bitmap size is the size of the canvas.
//************************************************************************
void CLCDBitmap::OnDraw(CLCDGfxBase &rGfx)
{
if(m_hBitmap)
{
HDC hCompatibleDC = CreateCompatibleDC(rGfx.GetHDC());
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, m_hBitmap);
// If monochrome output, don't even bother with alpha blend
if (LGLCD_BMP_FORMAT_160x43x1 == rGfx.GetLCDScreen()->hdr.Format)
{
BitBlt(rGfx.GetHDC(), 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, hCompatibleDC, 0, 0, m_dwROP);
}
else
{
if(0.001f > fabs(1.0f - m_fZoom))
{
BOOL b = FALSE;
if(m_bAlpha)
{
BLENDFUNCTION opblender = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
b = AlphaBlend(rGfx.GetHDC(), 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, hCompatibleDC, 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, opblender);
}
else
{
BitBlt(rGfx.GetHDC(), 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, hCompatibleDC, 0, 0, m_dwROP);
}
}
else
{
if(m_bAlpha)
{
BLENDFUNCTION opblender = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
AlphaBlend(rGfx.GetHDC(), 0, 0, (int)(m_fZoom* m_sizeLogical.cx), (int)(m_fZoom*m_sizeLogical.cy), hCompatibleDC, 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, opblender);
}
else
{
BLENDFUNCTION opblender = {AC_SRC_OVER, 0, 255, 0};
AlphaBlend(rGfx.GetHDC(), 0, 0, (int)(m_fZoom* m_sizeLogical.cx), (int)(m_fZoom*m_sizeLogical.cy), hCompatibleDC, 0, 0, m_sizeLogical.cx, m_sizeLogical.cy, opblender);
}
}
}
// restores
SelectObject(hCompatibleDC, hOldBitmap);
DeleteDC(hCompatibleDC);
}
}
//** end of LCDBitmap.cpp ************************************************