-
Notifications
You must be signed in to change notification settings - Fork 0
/
Image.cpp
98 lines (76 loc) · 1.99 KB
/
Image.cpp
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
#include "Include\Image.hpp"
Image::~Image()
{
if (count != 0) for (auto& gh : this->gh) DeleteGraph(gh);
}
int Image::Load(const TCHAR * FNAME, std::string key)
{
try
{
this->key.push_back(key);
const int& handle = LoadGraph(FNAME);
/* exception check */
if (handle == -1) {
std::string msg(FNAME);
msg += " is not found.";
throw msg;
}
gh.emplace_back(handle);
count++;
}
catch(std::string e)
{
MessageBox(NULL, e.c_str(), "error : Image::Load()", MB_OK);
return -1;
}
return 0;
}
void Image::List()
{
if (count == 0) return;
int c = 0;
printfDx("Imageキーリスト:\n");
for (auto key : this->key)
{
std::string list = key + "\n";
printfDx(list.c_str());
c++;
}
printfDx("合計%dファイル", c);
}
int Image::Draw(const int& X, const int& Y, std::string key, int TransFlag)
{
if (count == 0) return -1;
const int& Hdl = GetHandle(key);
return DrawGraph(X, Y, Hdl, TransFlag);
}
int Image::DrawRota(const int& X, const int& Y, const double& ExRate, const double& Angle, std::string key, int TransFlag, int TurnFlag)
{
if (count == 0) return -1;
const int& Hdl = GetHandle(key);
return DrawRotaGraph(X, Y, ExRate, Angle, Hdl, TransFlag, TurnFlag);
}
int Image::DrawRect(const int & DestX, const int & DestY, const int & SrcX, const int & SrcY, const int & Width, const int & Height, std::string key, const int & TransFlag, const int & TurnFlag)
{
if (count == 0) return -1;
const int& Hdl = GetHandle(key);
return DrawRectGraph(DestX, DestY, SrcX, SrcY, Width, Height, Hdl, TransFlag, TurnFlag);
}
int Image::GetSize(std::string key, int * width, int * height)
{
if (count == 0) return -1;
const int& Hdl = GetHandle(key);
return GetGraphSize(Hdl, width, height);;
}
int Image::GetHandle(std::string key)
{
for (int i = 0; i != this->key.size(); ++i)
{
if (this->key[i] != key) continue;
return this->gh[i];
}
std::string warning = key + "というキーが見当たりません。";
MessageBox(NULL, warning.c_str(), "NOT FOUND", MB_OK);
return -1;
}
// EOF