3#include <grass/bitmap.h>
5static int dump_map(
struct BM *map);
7int main(
int argc,
char *argv[])
10 struct BM *map, *map2;
20 if (
NULL == getenv(
"NODUMP"))
28 for (i = 0; i < SIZE; i++) {
30 BM_set(map, (SIZE - 1) - i, i, 1);
42 fprintf(stdout,
"\n\n");
44 for (y = 0; y < SIZE; y++)
45 for (
x = 0;
x < SIZE;
x++) {
62 fp = fopen(
"dumpfile",
"w");
64 fprintf(stderr,
"File_write failed\n");
69 fp = fopen(
"dumpfile",
"r");
83static int dump_map(
struct BM *map)
87 for (y = 0; y < map->rows; y++) {
88 for (
x = 0;
x < map->cols;
x++) {
89 fprintf(stdout,
"%c",
BM_get(map,
x, y) ?
'#' :
'.');
91 fprintf(stdout,
"\n");
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.
struct BM * BM_create_sparse(int x, int y)
Create a sparse bitmap of dimension 'x'/'y'.
int BM_dump_map_row_sparse(struct BM *map, int y)
Debugging code to dump out structure of links for single row.