45 int width, height, depth;
49 file = fopen(filename,
"r");
52 fprintf(stderr,
"%s: %s\n", strerror(errno), filename);
58 if ((fscanf(file,
"%10s \n", magic) != 1) || (strcmp(magic,
"P5") != 0))
60 fprintf(stderr,
"incorrect image format; must be PGM/binary");
65 while ((ch = fgetc(file)) ==
'#')
66 while (fgetc(file) !=
'\n');
70 if(fscanf(file,
" %d %d \n %d \n", &width, &height, &depth) != 3)
72 fprintf(stderr,
"Failed ot read image dimensions");
77 if (map->
cells == NULL)
82 map->
cells = calloc(width * height,
sizeof(map->
cells[0]));
94 for (j = height - 1; j >= 0; j--)
96 for (i = 0; i < width; i++)
105 else if (ch > 3 * depth / 4)
116 else if (ch > 3 * depth / 4)
#define MAP_VALID(map, i, j)
#define MAP_INDEX(map, i, j)
int map_load_occ(map_t *map, const char *filename, double scale, int negate)