#include "ppm.h" #include "aliases.h" #include #include void write_p6_ppm(const char *filepath, u64 width, u64 height, Pixel *data) { FILE *fp = fopen(filepath, "wb"); if (!fp) { return; } char header[1024] = {0}; sprintf(header, "P6\n%llu %llu\n255\n", (unsigned long long)width, (unsigned long long)height); u64 length = strlen(header); fwrite(&header, length, 1, fp); u64 pixel_count = width * height; fwrite(data, sizeof(Pixel), pixel_count, fp); fclose(fp); }