21#include <grass/bitmap.h>
23static int dump_map(
struct BM *map);
25int main(
int argc,
char *argv[])
28 struct BM *map, *map2;
38 if (
NULL != getenv(
"NODUMP"))
46 for (i = 0; i < SIZE; i++) {
48 BM_set(map, (SIZE - 1) - i, i, 1);
55 fprintf(stdout,
"\n\n");
58 for (y = 0; y < SIZE; y++)
59 for (
x = 0;
x < SIZE;
x++)
68 fp = fopen(
"dumpfile",
"w");
72 fp = fopen(
"dumpfile",
"r");
84static int dump_map(
struct BM *map)
88 for (y = 0; y < map->rows; y++) {
89 for (x = 0;
x < map->cols;
x++) {
90 fprintf(stdout,
"%c",
BM_get(map, x, y) ?
'#' :
'.');
92 fprintf(stdout,
"\n");
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_file_write(FILE *fp, struct BM *map)
Write bitmap out to file.
size_t BM_get_map_size(struct BM *map)
Returns size in bytes that bitmap is taking up.
int BM_get(struct BM *map, int x, int y)
Gets 'val' from the bitmap.
int BM_destroy(struct BM *map)
Destroy bitmap and free all associated memory.
struct BM * BM_file_read(FILE *fp)
Create map structure and load it from file.