From b91c09a43b3191d719781fe717fc6d28fec58029 Mon Sep 17 00:00:00 2001 From: kartofen Date: Tue, 9 Aug 2022 11:19:23 +0300 Subject: works --- src/ppm.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/ppm.c') diff --git a/src/ppm.c b/src/ppm.c index a39b9cb..caeff9b 100644 --- a/src/ppm.c +++ b/src/ppm.c @@ -3,7 +3,7 @@ #include #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); } -- cgit v1.2.3