7 Image::Image(int resX
, int resY
)
12 assert (resX
> 0 && resY
> 0);
13 std::cerr
<< "(Image): ResX = " << m_resX
<< ", resY = " << m_resY
<< std::endl
;
14 m_pixel
= new Vec3f
[m_resX
*m_resY
];
26 Image::Image(const Image
& o
)
32 Image::operator=(const Image
& o
)
38 Image::operator()(int x
, int y
)
40 assert(x
>= 0 && x
< m_resX
);
41 assert(y
>= 0 && y
< m_resY
);
43 return m_pixel
[y
*m_resX
+x
];
46 void Image::WritePPM(const std::string
& fileName
)
48 std::cerr
<< "(Image): Writing to file " << fileName
<< std::endl
;
49 std::ofstream
file(fileName
.c_str());
53 std::cerr
<< "(Image): Could not open file " << fileName
<< std::endl
;
57 file
<< "P3" << std::endl
;
58 file
<< m_resX
<< " " << m_resY
<< " " << 255 << std::endl
;
59 for (int y
=m_resY
-1;y
>=0;y
--)
61 for (int x
=0;x
<m_resX
;x
++)
64 << (int)(255.99999999 * (*this)(x
,y
)[0]) << " "
65 << (int)(255.99999999 * (*this)(x
,y
)[1]) << " "
66 << (int)(255.99999999 * (*this)(x
,y
)[2]) << " "
This page took 0.05279 seconds and 5 git commands to generate.