diff --git a/main.cpp b/main.cpp index a8c909d..8c602f5 100644 --- a/main.cpp +++ b/main.cpp @@ -17,6 +17,8 @@ int main() { int width = 0; int height = 0; + Pixel colorsMat [125][125]; + ifstream in; in.open("in.data", ios::in); @@ -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 @@ -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();