X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/3396a44710415bde9509afeb02f3ec10a22c6661..HEAD:/Image.cxx?ds=sidebyside diff --git a/Image.cxx b/Image.cxx index bc8134b..b45cac9 100644 --- a/Image.cxx +++ b/Image.cxx @@ -39,34 +39,28 @@ 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) (*this)(x,y)[0] = 255; - if ((*this)(x,y)[1] > 255) (*this)(x,y)[1] = 255; - if ((*this)(x,y)[2] > 255) (*this)(x,y)[2] = 255; - file + file << (int)(255.99999999 * (*this)(x,y)[0]) << " " << (int)(255.99999999 * (*this)(x,y)[1]) << " " << (int)(255.99999999 * (*this)(x,y)[2]) << " "