-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtils.h
34 lines (30 loc) · 810 Bytes
/
Utils.h
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
#pragma once
inline BOOL AlphaBlend(HDC hDC, int x, int y, int cx, int cy, HBITMAP hBitmap, BLENDFUNCTION bf)
{
CDC hMemDC;
hMemDC.CreateCompatibleDC(hDC);
HBITMAP hOrgBMP = hMemDC.SelectBitmap(hBitmap);
BOOL ret = ::AlphaBlend(hDC, x, y, cx, cy, hMemDC, 0, 0, cx, cy, bf);
hMemDC.SelectBitmap(hOrgBMP);
return ret;
}
class CBitmapDC : public CDC
{
public:
// Data members
CBitmap m_bmp;
HBITMAP m_hBmpOld;
// Constructor/destructor
CBitmapDC(HDC hDC, int w, int h) : m_hBmpOld(NULL)
{
CreateCompatibleDC(hDC);
ATLASSERT(m_hDC != NULL);
m_bmp.CreateCompatibleBitmap(hDC, w, h);
ATLASSERT(m_bmp.m_hBitmap != NULL);
m_hBmpOld = SelectBitmap(m_bmp);
}
~CBitmapDC()
{
SelectBitmap(m_hBmpOld);
}
};