diff options
Diffstat (limited to 'src/ppm.c')
-rw-r--r-- | src/ppm.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -3,7 +3,7 @@ #include <string.h> #include "ppm.h" -void save_as_ppm(char* file_path, int *t, size_t width, size_t height) +void save_as_ppm(char* file_path, int *t, size_t width, size_t height, size_t scaler) { FILE *fp = fopen(file_path, "wb"); if(!fp) { @@ -11,17 +11,10 @@ void save_as_ppm(char* file_path, int *t, size_t width, size_t height) exit(EXIT_FAILURE); } - // fprintf(fp, "P6\n%ld %ld 255\n", width, height); - - // for(size_t i = 0; i < height; i++) - // for(size_t j = 0; j < width; j++) - // { - // char c = (t[i * width + j] == 0) ? 255 : 0; - // for(int j = 0; j < 3; j++) - // fwrite(&c, 1, 1, fp); - // } - - int scaler = 5; + if(scaler == 0) { + fprintf(stderr, "ERROR: Invalid value for scaler %d\n", scaler); + exit(EXIT_FAILURE); + } fprintf(fp, "P6\n%d %d 255\n", width*scaler, height*scaler); @@ -34,7 +27,6 @@ void save_as_ppm(char* file_path, int *t, size_t width, size_t height) } - fclose(fp); } |