-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (41 loc) · 1.14 KB
/
main.cpp
File metadata and controls
59 lines (41 loc) · 1.14 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
#include <iostream>
#include <sstream> // oh stringstream that's neat maybe that's convenient
#include <fstream>
#include <vector> //hmmm what's this maybe this is useful
using namespace std;
struct Pixel {
//hmm this could be useful but who knows
int r;
int g;
int b;
};
int main() {
int width = 0;
int height = 0;
ifstream in;
in.open("in.data", ios::in);
if(in.is_open()) { //if the file is open
string line;
getline(in, line); //stores a line in line
width = stoi(line);
getline(in, line);
height = stoi(line);
//TODO set up data structures
// maybe a 2d vector would be useful?
while(getline(in, line)){ //reads a line at a time
//TODO read in pixel data
}
cout << "Width = " << width << endl; //Print to console
cout << "Height = " << height << endl;
ofstream out;
out.open("out.ppm", ios::out);
if(out.is_open()) { //if the file is open
out << "P3" << endl; //write to file
out << width << " " << height << endl;
out << 255 << endl;
//TODO writing your pixel data in ppm form
out.close();
}
in.close();
}
}