Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ int main() {
int width = 0;
int height = 0;

Pixel colorsMat [125][125];

ifstream in;
in.open("in.data", ios::in);

Expand All @@ -34,7 +36,31 @@ int main() {
while(getline(in, line)){ //reads a line at a time

//TODO read in pixel data
//cout << "Line = " << line << endl;

stringstream stream (line);

int x;
int y;
int r;
int g;
int b;

stream >> x;
stream >> y;
stream >> r;
stream >> g;
stream >> b;

Pixel tempPixel = {r,g,b};

colorsMat[x][y] = tempPixel;

//cout << "R = " << tempPixel.r << endl;
//cout << "G = " << tempPixel.g << endl;
//cout << "B = " << tempPixel.b << endl;


}

cout << "Width = " << width << endl; //Print to console
Expand All @@ -43,12 +69,21 @@ int main() {
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;
cout << "P3" << endl; //write to file
cout << width << " " << height << endl;
cout << 255 << endl;

//TODO writing your pixel data in ppm form

//cout << "test" << endl;
for( int x = 0; x < 125; x = x + 1 ) {
for( int y = 0; y < 125; y = y + 1 ) {
cout << colorsMat[x][y].r << " " << colorsMat[x][y].g << " " << colorsMat[x][y].b << " ";
}
cout << endl;
}


out.close();
}
in.close();
Expand Down