45 int width, height, depth;
49 file = fopen(filename,
"r");
52 fprintf(stderr,
"%s: %s\n", strerror(errno), filename);
58 if ((fscanf(file,
"%2s \n", magic) != 1) || (strcmp(magic,
"P5") != 0))
60 fprintf(stderr,
"incorrect image format; must be PGM/binary");
66 while ((ch = fgetc(file)) ==
'#')
67 while (fgetc(file) !=
'\n');
71 if(fscanf(file,
" %d %d \n %d \n", &width, &height, &depth) != 3)
73 fprintf(stderr,
"Failed ot read image dimensions");
78 if (map->
cells == NULL)
83 map->
cells = calloc(width * height,
sizeof(map->
cells[0]));
95 for (j = height - 1; j >= 0; j--)
97 for (i = 0; i < width; i++)
106 else if (ch > 3 * depth / 4)
117 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)