aboutsummaryrefslogtreecommitdiff
path: root/src/ppm.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-09 11:19:23 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-09 11:19:23 +0300
commitb91c09a43b3191d719781fe717fc6d28fec58029 (patch)
tree6355cc29f8fb9569e2d407d63b4fcc35cf83d2b8 /src/ppm.c
parenta68cc52b5c5d1c104de8d675b90816aaa39f4ace (diff)
works
Diffstat (limited to 'src/ppm.c')
-rw-r--r--src/ppm.c18
1 files changed, 5 insertions, 13 deletions
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 <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);
}