X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/13c3b8d1e2ecf7f1dbd02f9d4bfeb813b36fd40a..556bb9d82b766ce68c56844492536525dc2d19d7:/Image.cxx?ds=sidebyside diff --git a/Image.cxx b/Image.cxx index 899ac6f..b45cac9 100644 --- a/Image.cxx +++ b/Image.cxx @@ -39,39 +39,31 @@ Image::operator()(int x, int y) { assert(x >= 0 && x < m_resX); assert(y >= 0 && y < m_resY); - - return m_pixel[y*m_resX+x]; + + return m_pixel[y*m_resX+x]; } void Image::WritePPM(const std::string& fileName) { std::cerr << "(Image): Writing to file " << fileName << std::endl; std::ofstream file(fileName.c_str()); - + if(!file.is_open()) { std::cerr << "(Image): Could not open file " << fileName << std::endl; return; } - + file << "P3" << std::endl; file << m_resX << " " << m_resY << " " << 255 << std::endl; - for (int y=m_resY-1;y>=0;y--) + for (int y=m_resY-1;y>=0;y--) { for (int x=0;x 255) cur[0] = 255; - if(cur[1] > 255) cur[1] = 255; - if(cur[2] > 255) cur[2] = 255; - - file - << (int)(255.99999999 * cur[0]) << " " - << (int)(255.99999999 * cur[1]) << " " - << (int)(255.99999999 * cur[2]) << " " + file + << (int)(255.99999999 * (*this)(x,y)[0]) << " " + << (int)(255.99999999 * (*this)(x,y)[1]) << " " + << (int)(255.99999999 * (*this)(x,y)[2]) << " " << "\t"; } file << std::endl;