aboutsummaryrefslogtreecommitdiff
path: root/src/ppm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ppm.c')
-rw-r--r--src/ppm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ppm.c b/src/ppm.c
index 7bc8bb7..7952305 100644
--- a/src/ppm.c
+++ b/src/ppm.c
@@ -17,7 +17,7 @@ void save_as_ppm(char* file_path, small_t *t, size_t width, size_t height, size_
exit(EXIT_FAILURE);
}
- fprintf(fp, "P6\n%ld %ld 255\n", width*scaler, height*scaler);
+ fprintf(fp, "P6\n%ld %ld\n255\n", width*scaler, height*scaler);
for(size_t i = 0; i < height * scaler; i++)
for(size_t j = 0; j < width * scaler; j++)
@@ -48,7 +48,12 @@ small_t *load_from_ppm(char *file_path, size_t *width, size_t *height)
fgets(line, sizeof(line), fp);
*width = atoi(strtok(line, " "));
*height = atoi(strtok(NULL, " "));
- (void)strtok(NULL, " ");
+
+ fgets(line, sizeof(line), fp);
+ if(atoi(line) != 255) {
+ printf("Maximum color value must be 255");
+ exit(1);
+ }
small_t *t = malloc((*width) * (*height ) * 3);