diff --git a/ppm.c b/ppm.c index ef7193a..25044be 100644 --- a/ppm.c +++ b/ppm.c @@ -3,21 +3,21 @@ #include #include -void write_p6_ppm(const char *filepath, u64 width, u64 height, Pixel *data) { +void write_p6_ppm(const char *filepath, Image *img) { 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); + sprintf(header, "P6\n%llu %llu\n255\n", (unsigned long long)img->width, + (unsigned long long)img->height); u64 length = strlen(header); fwrite(&header, length, 1, fp); - u64 pixel_count = width * height; - fwrite(data, sizeof(Pixel), pixel_count, fp); + u64 pixel_count = img->width * img->height; + fwrite(img->data, sizeof(Pixel), pixel_count, fp); fclose(fp); } diff --git a/ppm.h b/ppm.h index d8ac00b..a51a939 100644 --- a/ppm.h +++ b/ppm.h @@ -6,4 +6,10 @@ typedef struct { u8 b; } Pixel; -void write_p6_ppm(const char *filepath, u64 width, u64 height, Pixel *data); +typedef struct { + u64 width; + u64 height; + Pixel *data; +} Image; + +void write_p6_ppm(const char *filepath, Image *img);