diff options
Diffstat (limited to 'src/ppm.c')
-rw-r--r-- | src/ppm.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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); |