-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
108 lines (85 loc) · 3.32 KB
/
main.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
99
100
101
102
103
104
105
106
107
108
#include <exception>
#include <iostream>
#include <regex>
#include <argparse/argparse.hpp>
#include "image.h"
#include "render.h"
#include "video.h"
std::string menu = "┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"
"┃ ┃\n"
"┃ 0.Image ┃\n"
"┃ 1.Video ┃\n"
"┃ 2.3D ┃\n"
"┃ ┃\n"
"┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"
"Input?: ";
std::string encoding = "┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"
"┃ ┃\n"
"┃ 0. GRAY SCALE ┃\n"
"┃ 1. RGB ┃\n"
"┃ 2. SHORT GRAY ┃\n"
"┃ 3. REVERSE GRAY ┃\n"
"┃ ┃\n"
"┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"
"Input?: ";
std::regex RE_IMAGE("(.*\\.(jpe?g|png|bmp)$)");
int main(int argc, char *argv[]) {
argparse::ArgumentParser program("Texto");
program.add_argument("-E", "--encode-type").default_value("gscale");
program.add_argument("-G", "--Text-ui-mode").implicit_value(true).default_value(false);
auto &media = program.add_mutually_exclusive_group(true);
media.add_argument("-V").flag();
media.add_argument("-I").flag();
media.add_argument("-D").flag();
program.add_argument("path");
try {
program.parse_args(argc, argv);
} catch (const std::exception &err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
}
if (!program.get<bool>("-G")) {
EncodeType encoding_type = GSCALE;
auto path = program.get("path");
auto encoding_str = program.get("-E");
if (encoding_str.compare("rgb") == 0) {
encoding_type = EncodeType::RGB;
} else if (encoding_str.compare("rgscale")) {
encoding_type = EncodeType::REVERSE_GSCALE;
} else if (encoding_str.compare("sgscale")) {
encoding_type = EncodeType::SHORT_GSCALE;
} else {
encoding_type = EncodeType::GSCALE;
}
if (program.get<bool>("-I")) {
Image image(path, encoding_type);
image.show();
} else if (program.get<bool>("-V")) {
Video video(path, encoding_type);
video.show();
} else if (program.get<bool>("-D")) {
render3D();
}
return 0;
}
int selection = 0;
int type;
std::string path;
std::cout << menu;
std::cin >> selection;
std::cout << "Path?: \n";
std::cin >> path;
std::cout << encoding;
std::cin >> type;
if (selection == 0) {
Image image(path, static_cast<EncodeType>(type));
image.show();
} else if (selection == 1) {
Video video(path, static_cast<EncodeType>(type));
video.show();
} else if (selection == 2) {
render3D();
}
return 0;
}