Repository navigation
Expand file tree
/
Copy pathMain.cpp
More file actions
70 lines (59 loc) · 1.38 KB
/
Copy pathMain.cpp
File metadata and controls
70 lines (59 loc) · 1.38 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
#include <iostream>
#include <sstream>
#include "ADLWrapper.hpp"
#include "GammaRamp.hpp"
namespace {
double parseGamma(const char *str) {
std::stringstream ss(str);
double gamma;
ss >> gamma;
if (ss.fail()) {
return 0;
}
return gamma;
}
void printUsage() {
std::cout << "Usage:\n"
<< "GammaChanger load <filename>" << std::endl
<< "GammaChanger save <filename>" << std::endl
<< "GammaChanger set <gamma>" << std::endl;
exit(0);
}
}
int main(int argc, char **argv) {
if (argc != 3) {
printUsage();
}
std::string mode(argv[1]);
try {
ADLWrapper adl;
GammaRamp ramp;
if (mode == "load") {
std::cout << "Loading the saved gamma ramp." << std::endl;
ramp.loadGammaRamp(std::string(argv[2]));
adl.setSaturation(100);
}
else if (mode == "save") {
std::cout << "Saving the current gamma ramp." << std::endl;
ramp.saveGammaRamp(std::string(argv[2]));
}
else if (mode == "set") {
double gamma = parseGamma(argv[2]);
if (gamma > 3.0 || gamma < 0.1) {
std::cerr << "The gamma value must be between 0.1 and 3.0." << std::endl;
return 1;
}
std::cout << "Setting a new gamma ramp." << std::endl;
ramp.setGammaRamp(gamma);
adl.setSaturation(200);
}
else {
std::cerr << "Invalid mode specified!" << std::endl;
return 1;
}
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}