diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-08-11 16:41:00 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-08-11 16:41:00 +0300 |
commit | 57315da56fa3b036f8e3e2d32a5f90a11ae7c3de (patch) | |
tree | 0edd722ce020de9e33fcc107e9adfa02b314344d /src/ppm.c | |
parent | 50122472d9c3150bf8f998df2ee4f5d5fc06f5aa (diff) |
works with images
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); |