-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCircleImageUI.cpp
More file actions
74 lines (66 loc) · 1.84 KB
/
CircleImageUI.cpp
File metadata and controls
74 lines (66 loc) · 1.84 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
#include "StdAfx.h"
#include "CircleImageUI.h"
#include <atlconv.h>
#include <Shlwapi.h>
CCircleImageUI::CCircleImageUI()
{
m_pImagePathBitmap = NULL;
}
CCircleImageUI::~CCircleImageUI()
{
if (m_pImagePathBitmap)
{
delete m_pImagePathBitmap;
m_pImagePathBitmap = NULL;
}
}
LPCTSTR CCircleImageUI::GetClass() const
{
return _T("CircleImageUI");
}
LPVOID CCircleImageUI::GetInterface(LPCTSTR pstrName)
{
if (_tcscmp(pstrName, _T("CircleImage")) == 0) return static_cast<CCircleImageUI*>(this);
return CLabelUI::GetInterface(pstrName);
}
void CCircleImageUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
if( _tcsicmp(pstrName, _T("imagepath")) == 0 ) {
TImageInfo * pInfo = CRenderEngine::LoadImage(pstrValue);
if (pInfo)
{
if (m_pImagePathBitmap)
{
delete m_pImagePathBitmap;
m_pImagePathBitmap = NULL;
}
m_pImagePathBitmap = Gdiplus::Bitmap::FromHBITMAP(pInfo->hBitmap,NULL);
if (pInfo->hBitmap)
{
DeleteObject(pInfo->hBitmap);
}
delete pInfo;
}
Invalidate();
}
else
CLabelUI::SetAttribute(pstrName, pstrValue);
}
void CCircleImageUI::PaintBkImage(HDC hDC)
{
CLabelUI::PaintBkImage(hDC);
Gdiplus::Graphics graphics(hDC);
if (m_pImagePathBitmap)
{
Gdiplus::TextureBrush tBrush2(m_pImagePathBitmap);
Gdiplus::REAL cx = (Gdiplus::REAL)(m_rcItem.right - m_rcItem.left);
Gdiplus::REAL cy = (Gdiplus::REAL)(m_rcItem.bottom - m_rcItem.top);
Gdiplus::RectF rc((Gdiplus::REAL)m_rcItem.left, (Gdiplus::REAL)m_rcItem.top, cx, cy);
graphics.SetClip(rc);
tBrush2.SetWrapMode(Gdiplus::WrapModeTile);
graphics.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias);
tBrush2.TranslateTransform(rc.GetLeft(), rc.GetTop());
tBrush2.ScaleTransform(cx / m_pImagePathBitmap->GetWidth(), cy / m_pImagePathBitmap->GetHeight());
graphics.FillEllipse(&tBrush2, rc);
}
}