PPM image parser cleanup

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2026-05-11 21:11:37 +0200
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2026-05-11 21:11:37 +0200
Commit de9acf6dab7e772009cb761896f07d2e478db19f (patch)
-rw-r--r-- ppm.c 10
1 files changed, 1 insertions, 9 deletions
diff --git a/ppm.c b/ppm.c
...
6
#include <string.h>
6
#include <string.h>
7
  
7
  
8
Image read_ppm_image(const char *filename) {
8
Image read_ppm_image(const char *filename) {
9
	/* const char *filename = "textures/test.ppm"; */
  
10
  
  
11
	Image img = {0};
9
	Image img = {0};
12
  
10
  
13
	FILE *f = fopen(filename, "rb");
11
	FILE *f = fopen(filename, "rb");
...
15
		perror("fopen");
13
		perror("fopen");
16
		return (Image){};
14
		return (Image){};
17
	}
15
	}
18
  
  
19
  
16
  
20
	int j = 0;
17
	int j = 0;
21
	int in_token = 0;
18
	int in_token = 0;
...
94
  
91
  
95
	fclose(f);
92
	fclose(f);
96
  
93
  
97
	printf("format: %s\n", img.format);
94
	printf("Loading image: [%s] %s (%dx%d) %d (%zu/%zu)\n", filename, img.format, img.width, img.height, img.color_space, pixel_count, pixel_capacity);
98
	printf("width: %d\n", img.width);
  
99
	printf("height: %d\n", img.height);
  
100
	printf("color_space: %d\n", img.color_space);
  
101
	printf("pixel_count: %zu\n", pixel_count);
  
102
	printf("expected: %zu\n", pixel_capacity);
  
103
  
95
  
104
	return img;
96
	return img;
105
}
97
}