-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (33 loc) · 1.44 KB
/
main.cpp
File metadata and controls
37 lines (33 loc) · 1.44 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
#include "bitmap.hpp"
#include <iostream>
#include <cstring>
int main(int argc, char *argv[])
{
if (argc < 3){
std::cout << "Usage: " << argv[0] << "<file> <effect> <output>\n";
std::cout << "effects: gausianblur, grayscale, sepia, negative, threshold, edge";
return 1;
}
const char *filters[] = {"gausianblur", "grayscale", "sepia", "negative", "threshold", "edge"};
const char *imagePath = argv[1];
BMP originalImage(imagePath);
BMP newImage = originalImage;
char *effectOption = argv[2];
const char *outputFileName = argv[3];
if (strcmp(effectOption, filters[0]) == 0){
for(int i = 0; i < 15; i++){
newImage.applyGausianBlur();
}
newImage.write(outputFileName);
}
else if (strcmp(effectOption, filters[1]) == 0) { newImage.toGrayScale(); newImage.write(outputFileName); }
else if (strcmp(effectOption, filters[2]) == 0) { newImage.toSepia(); newImage.write(outputFileName); }
else if (strcmp(effectOption, filters[3]) == 0) { newImage.toNegative(); newImage.write(outputFileName); }
else if (strcmp(effectOption, filters[4]) == 0) { newImage.toThreshold(); newImage.write(outputFileName); }
else if (strcmp(effectOption, filters[5]) == 0) { newImage.sobelEdgeDetector(); newImage.write(outputFileName); }
else {
std::cout << "Incorret usage, effects are case-sensitive!" << std::endl;
return 1;
}
return 0;
}