mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-08-14 09:58:03 +00:00
init
This commit is contained in:
commit
de866d23bf
28 changed files with 46878 additions and 0 deletions
25
external/simpleppm.cpp
vendored
Normal file
25
external/simpleppm.cpp
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "simpleppm.h"
|
||||
|
||||
/*
|
||||
This code was adapted from here:
|
||||
https://rosettacode.org/wiki/Bitmap/Write_a_PPM_file#C.2B.2B
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
int save_ppm(std::string file_name, const std::vector<double>& buffer, int dimx, int dimy) {
|
||||
|
||||
ofstream ofs(file_name, ios_base::out | ios_base::binary);
|
||||
ofs << "P6" << endl << dimx << ' ' << dimy << endl << "255" << endl;
|
||||
|
||||
for (unsigned int j = 0; j < dimy; ++j)
|
||||
for (unsigned int i = 0; i < dimx; ++i)
|
||||
ofs << (char) (255.0 * buffer[3*j*dimx+3*i+0]) << (char) (255.0 * buffer[3*j*dimx+3*i+1]) << (char) (255.0 * buffer[3*j*dimx+3*i+2]);
|
||||
|
||||
ofs.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue