- file
- << (int)(255.99999999 * (*this)(x,y)[0]) << " "
- << (int)(255.99999999 * (*this)(x,y)[1]) << " "
- << (int)(255.99999999 * (*this)(x,y)[2]) << " "
+ 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]) << " "