-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.h
More file actions
141 lines (120 loc) · 3.71 KB
/
image.h
File metadata and controls
141 lines (120 loc) · 3.71 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
#pragma once
class image
{
public:
//이미지를 불러올수 있는 종류
enum IMAGE_LOAD_KIND
{
LOAD_RESOURCE, //리소스 파일로부터
LOAD_FILE, //이미지 파일로부터
LOAD_EMPTY, //빈 비트맵 이미지를 만들어야겠다
LOAD_END
};
typedef struct tagImageInfo
{
DWORD resID; //리소스를 통해서 이미지 처리할땐 얘를 쓴다
HDC hMemDC;
HBITMAP hBit;
HBITMAP hOBit;
float x; //이미지 x좌표
float y; //이미지 y좌표
float width; //이미지 전체 가로크기
float height; //이미지 전체 세로크기
int currentFrameX; //현재 프레임 번호(가로)
int currentFrameY; //현재 프레임 번호(세로)
int maxFrameX; //최대 프레임 번호(가로)
int maxFrameY; //최대 프레임 번호(세로)
int frameWidth; //1프레임 당 가로크기
int frameHeight; //1프레임 당 세로크기
BYTE loadType;
tagImageInfo()
{
resID = 0;
hMemDC = NULL;
hBit = NULL;
hOBit = NULL;
x = 0;
y = 0;
width = 0;
height = 0;
currentFrameX = 0;
currentFrameY = 0;
maxFrameX = 0;
maxFrameY = 0;
frameWidth = 0;
frameHeight = 0;
loadType = LOAD_RESOURCE;
}
}IMAGE_INFO, *LPIMAGE_INFO;
private:
LPIMAGE_INFO _imageInfo;
CHAR* _fileName; //파일 이름
BOOL _trans; //특정 픽셀값을 제거할지 유무
COLORREF _transColor; //제거할 픽셀값
public:
image();
~image();
HRESULT init(int width, int height);
HRESULT init(const char* fileName, int width, int height,
BOOL trans = FALSE, COLORREF transColor = FALSE);
HRESULT init(const char* fileName, float x, float y,
int width, int height, int frameX, int frameY,
BOOL trans = FALSE, COLORREF transColor = FALSE);
HRESULT init(const char* fileName, int width, int height,
int frameX, int frameY, BOOL trans = FALSE, COLORREF transColor = FALSE);
void ScaleImage(float ratio);
void release();
void render(HDC hdc, int destX, int destY);
void render(HDC hdc, int destX, int destY,
int sourX, int sourY, int sourWidth, int sourHeight);
void frameRender(HDC hdc, int destX, int destY);
void frameRender(HDC hdc, int destX, int destY,
int currentFrameX, int currentFrameY);
//혹시나 런타임 도중에 제거할 픽셀값을 바꿔야한다면
void setTransColor(BOOL trans, COLORREF transColor);
//백버퍼에 대한 접근자
inline HDC getMemDC() { return _imageInfo->hMemDC; }
//getter(), setter()
inline void setX(float x) { _imageInfo->x = x; }
inline float getX() { return _imageInfo->x; }
inline void setY(float y) { _imageInfo->y = y; };
inline float getY() { return _imageInfo->y; }
inline void setCenter(float x, float y)
{
_imageInfo->x = x - (_imageInfo->width / 2);
_imageInfo->y = y - (_imageInfo->height / 2);
}
inline float getCenterX() {
return _imageInfo->maxFrameX <= 0 ?
_imageInfo->x + (_imageInfo->width / 2) :
_imageInfo->x + (_imageInfo->frameWidth / 2);
}
inline float getCenterY()
{
return _imageInfo->maxFrameY <= 0 ?
_imageInfo->y + (_imageInfo->height / 2) :
_imageInfo->y + (_imageInfo->frameHeight / 2);
}
inline int getWidth() { return _imageInfo->width; }
inline int getHeight() { return _imageInfo->height; }
inline void setFrameX(int frameX)
{
_imageInfo->currentFrameX = frameX;
if (frameX > _imageInfo->maxFrameX) {
_imageInfo->currentFrameX = _imageInfo->maxFrameX;
}
}
inline void setFrameY(int frameY)
{
_imageInfo->currentFrameY = frameY;
if (frameY > _imageInfo->maxFrameY) {
_imageInfo->currentFrameY = _imageInfo->maxFrameY;
}
}
inline int getMaxFrameX() { return _imageInfo->maxFrameX; }
inline int getMaxFrameY() { return _imageInfo->maxFrameY; }
inline int getFrameX() { return _imageInfo->currentFrameX; }
inline int getFrameY() { return _imageInfo->currentFrameY; }
inline int getFrameWidth() { return _imageInfo->frameWidth; }
inline int getFrameHeight() { return _imageInfo->frameHeight; }
};