-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstagram.cpp
More file actions
31 lines (26 loc) · 795 Bytes
/
instagram.cpp
File metadata and controls
31 lines (26 loc) · 795 Bytes
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
#include "picture.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "Usage: instagram infile.bmp [outfile.bmp]" << endl;
return 1;
}
// open the file and construct a Picture object
Picture pic(argv[1]);
// shift the color components
for (int row=0; row<pic.height(); row++)
for (int col=0; col<pic.width(); col++) {
Color color = pic.get(row, col);
Color newcolor;
newcolor.red = color.green;
newcolor.green = color.blue;
newcolor.blue = color.red;
pic.set(row, col, newcolor);
}
// show the new picture
pic.show();
// save it, if the optional command-line argument was provided
if (argc > 2)
pic.save(argv[2]);
}