13 lines
380 B
C++
13 lines
380 B
C++
#pragma once
|
|
|
|
#include <fstream>
|
|
|
|
|
|
void saveImage(const char* filename, unsigned char* framebuffer, int width, int height) {
|
|
std::ofstream imageFile(filename, std::ios::out | std::ios::binary);
|
|
imageFile << "P6\n" << width << " " << height << "\n255\n";
|
|
for (int i = 0; i < width * height * 3; i++) {
|
|
imageFile << framebuffer[i];
|
|
}
|
|
imageFile.close();
|
|
} |