-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBindCore.h
More file actions
156 lines (151 loc) · 3.11 KB
/
BindCore.h
File metadata and controls
156 lines (151 loc) · 3.11 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
#pragma once
#include <atlimage.h>
#include <CString>
#include <vector>
#include <Windows.h>
using namespace std;
struct CfRect
{
int x;
int y;
int cx;
int cy;
public:
CfRect()
{
}
CfRect(int x,int y,int cx,int cy)
{
this->x=x;
this->y=y;
this->cx=cx;
this->cy=cy;
}
void operator()(int x,int y,int cx,int cy)
{
this->x=x;
this->y=y;
this->cx=cx;
this->cy=cy;
}
inline bool InCollide(CfRect& rect)
{
/*if(x==rect.x&&y==rect.y&&cx==rect.cx&&cy==rect.cy)
return false;
if(x==rect.x)
{
x=x;
}*/
if(x+cx>rect.x&&x<rect.x+rect.cx&&y+cy>rect.y&&y<rect.y+rect.cy)
return true;
return false;
}
inline bool InCollide(float x,float y)
{
if(x>=this->x&&x<=this->x+this->cx&&y>=this->y&&y<=this->y+this->cy)
return true;
return false;
}
inline bool InRect(CfRect& rect)
{
if(x>=rect.x&&y>=rect.y&&x+cx<=rect.x+rect.cx&&y+cy<=rect.y+rect.cy)
return true;
return false;
}
};
struct CNgePoint
{
int x;
int y;
public:
CNgePoint()
{
x=0;
y=0;
}
CNgePoint(int x,int y)
{
this->x=x;
this->y=y;
}
void operator()(int x,int y)
{
this->x=x;
this->y=y;
}
};
struct CfSize
{
int cx;
int cy;
public:
CfSize()
{
cx=0;
cy=0;
}
CfSize(int cx,int cy)
{
this->cx=cx;
this->cy=cy;
}
void operator()(int cx,int cy)
{
this->cx=cx;
this->cy=cy;
}
};
struct BImageInfo
{
CImage image;
CfRect crect;
CfRect srect;
CNgePoint position;
CString name;
bool bUser;
};
typedef vector<BImageInfo*> InfoList;
typedef vector<CfRect> RectList;
class CBindCore
{
public:
CBindCore(void);
~CBindCore(void);
bool AnalyseImage(CImage& img,CfRect& crect,CfRect& srect,bool bFixed = true);
bool CheckImageMatter(BImageInfo* _pInfo1,BImageInfo* _pInfo2);
bool ChangeImageBPP(CImage& src);
void Init(int _Width,int _Height,int _iSpace);
void setFilePath(CString _strPath);
void Reset();
bool AutoBind(CString& filename,bool _bOptimize,bool _b2m);
bool SingleCount();
bool CheckClipRect(CfRect& rect,CfRect& crect);
BImageInfo* QueryOne();
CImage* GetImgBuffer(){return &m_ImgBuffer;};
bool AddImage(CString& str,CString& name);
void QuickSort(InfoList& list, int first, int end);
void QuickRect(RectList& list, int first, int end);
bool CheckMin(CfRect& rect,bool _bFirst);
void enableUsedSame(bool _bUsed);
inline InfoList& GetImageList(){return m_ImgList;}
inline CfSize GetImageSize(){return m_sizeImage;}
bool CheckSameImage(BImageInfo* _pTempinfo);
private:
InfoList m_ImgList;
RectList m_RemainList;
CImage m_ImgBuffer;
CfRect m_rcBuffer;
CfSize m_sizeImage;
CfSize m_sizeMax;
int m_iWBase;
int m_iHBase;
CString m_strPath;
int m_iSpace;
bool m_bBegin;
CPoint m_ptSize;
CPoint m_ptCurrentV;
DWORD m_dwLeftY;
DWORD m_dwRightY;
bool m_bFirst;
bool m_bUsedSame;
};