21 #include <grass/bitmap.h>
24 static int dump_map(
struct BM *map);
27 int main(
int argc,
char *argv[])
30 struct BM *map, *map2;
48 for (i = 0; i < SIZE; i++) {
50 BM_set(map, (SIZE - 1) - i, i, 1);
58 fprintf(stdout,
"\n\n");
61 for (y = 0; y < SIZE; y++)
62 for (x = 0; x < SIZE; x++)
71 fp = fopen(
"dumpfile",
"w");
75 fp = fopen(
"dumpfile",
"r");
88 static int dump_map(
struct BM *map)
92 for (y = 0; y < map->rows; y++) {
93 for (x = 0; x < map->cols; x++) {
94 fprintf(stdout,
"%c",
BM_get(map, x, y) ?
'#' :
'.');
97 fprintf(stdout,
"\n");
int BM_get(struct BM *map, int x, int y)
Gets 'val' from the bitmap.
int BM_file_write(FILE *fp, struct BM *map)
Write bitmap out to file.
int BM_destroy(struct BM *map)
Destroy bitmap and free all associated memory.
int main(int argc, char *argv[])
struct BM * BM_file_read(FILE *fp)
Create map structure and load it from file.
struct BM * BM_create(int x, int y)
Create bitmap of dimension x/y and return structure token.
int BM_set(struct BM *map, int x, int y, int val)
Sets bitmap value to 'val' at location 'x' 'y'.
int BM_get_map_size(struct BM *map)
Returns size in bytes that bitmap is taking up.