-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
168 lines (141 loc) · 4.25 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/******************************
** main.cpp **
** Created by Charles Davis **
** CPSC 246-01 **
******************************
******************************************************************************
** The main file of the ImageManipulator.exe. This program prints out the **
** initial information and then creates an ImageManipulator object to **
** manipulate my SRU ID picture, Davis.ppm. I chose to have it run the **
** fiesta filter I created. **
*****************************************************************************/
#include "ImageManipulator.h"
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
void init();
void getFilter(int& filter);
int main()
{
init();
string inFileName, outFileName;
int userFilter = 0;
getFilter(userFilter);
cout << "\nEnter image file name to be manipulated: ";
cin >> inFileName;
cout << "Enter output file name: ";
cin >> outFileName;
ImageManipulator myImage = ImageManipulator(inFileName);
myImage.filterImage(outFileName , userFilter);
return 0;
}
/*********************************** Init ************************************/
void init()
{
cout << "\n\n====================================================" << endl;
cout << " Charles Davis - CPSC 246.01 - ImageManipulator " << endl;
cout << "====================================================\n\n" << endl;
}
void getFilter(int &filter)
{
int userInput;
do
{
cout << "\n 1) Zero Red 7) Average RGB" << endl;
cout << " 2) Zero Green 8) Swap Red Green" << endl;
cout << " 3) Zero Blue 9) Swap Green Blue" << endl;
cout << " 4) Invert Red 10) Swap Blue Red" << endl;
cout << " 5) Invert Green 11) Fiesta Filter" << endl;
cout << " 6) Invert Blue\n" << endl;
cout << "Which filters would you like to apply?" << endl;
cout << "Choose one at a time. Enter -1 to stop" << endl;
cin >> userInput;
if(userInput >= 1 && userInput <= 11)
{
switch(userInput)
{
case 1:
filter = filter | ImageManipulator::ZERO_RED;
break;
case 2:
filter = filter | ImageManipulator::ZERO_GREEN;
break;
case 3:
filter = filter | ImageManipulator::ZERO_BLUE;
break;
case 4:
filter = filter | ImageManipulator::INVERT_RED;
break;
case 5:
filter = filter | ImageManipulator::INVERT_GREEN;
break;
case 6:
filter = filter | ImageManipulator::INVERT_BLUE;
break;
case 7:
filter = filter | ImageManipulator::AVERAGE_RGB;
break;
case 8:
filter = filter | ImageManipulator::SWAP_RED_GREEN;
break;
case 9:
filter = filter | ImageManipulator::SWAP_GREEN_BLUE;
break;
case 10:
filter = filter | ImageManipulator::SWAP_BLUE_RED;
break;
case 11:
filter = filter | ImageManipulator::FIESTA_FILTER;
break;
default: break;
}
}
}while(userInput != -1);
cout << "\n\n\nYou chose: \n" << endl;
for(int i = 0; i < ImageManipulator::NUM_FILTERS; i++)
{
int bitMask = 1 << i;
if(filter & bitMask)
{
switch(bitMask)
{
case ImageManipulator::ZERO_RED:
cout << " Zero Red";
break;
case ImageManipulator::ZERO_GREEN:
cout << " Zero Green";
break;
case ImageManipulator::ZERO_BLUE:
cout << " Zero Blue";
break;
case ImageManipulator::INVERT_RED:
cout << " Invert Red";
break;
case ImageManipulator::INVERT_GREEN:
cout << " Invert Green" ;
break;
case ImageManipulator::INVERT_BLUE:
cout << " Invert Blue";
break;
case ImageManipulator::AVERAGE_RGB:
cout << " Average RGB";
break;
case ImageManipulator::SWAP_RED_GREEN:
cout << " Swap Red Green";
break;
case ImageManipulator::SWAP_GREEN_BLUE:
cout << " Swap Green Blue";
break;
case ImageManipulator::SWAP_BLUE_RED:
cout << " Swap Blue Red";
break;
case ImageManipulator::FIESTA_FILTER:
cout << " Fiesta Filter";
break;
default: break;
}
cout << endl;
}
}
}