solution for 4.1b,c
[MicroTrace.git] / Image.cxx
index 899ac6f..b45cac9 100644 (file)
--- 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<m_resX;x++)
        {
-    Vec3f cur = (*this)(x,y);
-    if(cur[0] < 0) cur[0] = 0;
-    if(cur[1] < 0) cur[1] = 0;
-    if(cur[2] < 0) cur[2] = 0;
-    if(cur[0] > 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;
This page took 0.02825 seconds and 4 git commands to generate.