-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (56 loc) · 1.76 KB
/
main.cpp
File metadata and controls
67 lines (56 loc) · 1.76 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
#include<iostream>
#include<vector>
#include<stdlib.h>
#include <string>
#include"FreeImage.h"
#include"IO.h"
#include"GetPixelData.h"
#include"ImageProcess.h"
int main(void)
{
FreeImage_Initialise();
char input[100];
char output[100];
std::string finish;
while (true)
{
std::cout << "縁をとる画像のディレクトリを入力してください" << std::endl;
std::cin >> input;
std::cout << "加工後の画像の保存先のディレクトリを入力してください" << std::endl;
std::cin >> output;
std::cin.clear();
std::cin.ignore(1024, '\n');
try
{
IO io;
std::shared_ptr<FIBITMAP> image = std::shared_ptr<FIBITMAP>(io.GenericLoader(input, 0), FreeImage_Unload);
if (!image)
{
throw std::runtime_error("Load failed");
}
GetPixelData pixels(FreeImage_GetWidth(image.get()), FreeImage_GetHeight(image.get()));
std::vector<int> edgeLoc(pixels.getWidth() * pixels.getHeight(),-1);
pixels.copyAlpha(image.get(), edgeLoc);
ImageProcess ip;
ip.Huchidori(image.get(), edgeLoc, pixels.getWidth(), pixels.getHeight());
if (!io.GenericWriter(image.get(), output, 0))
{
throw std::runtime_error("Huchidori failed");
}
}
catch (std::exception& e)
{
std::cout << "exception!\n" << e.what() << std::endl;
}
std::cout << "続けて加工する場合は、'y'と入力してください\nやめる場合はそれ以外の文字を入力してください" << std::endl;
getline(std::cin, finish);
if (finish.length() != 1)
{
break;
}
else if (finish != "y")
{
break;
}
}
}