40 #define BM_col_to_byte(x) ((x) >> 3)
41 #define BM_col_to_bit(x) ((x) & 7)
71 (map->
data = (
unsigned char *)calloc(map->
bytes * y,
sizeof(
char)))) {
157 fprintf(stderr,
"BM_set_mode: Unknown mode: %d\n", mode);
162 fprintf(stderr,
"BM_set_mode: Bad size: %d\n", size);
189 if (x < 0 || x >= map->
cols || y < 0 || y >= map->
rows)
221 if (x < 0 || x >= map->
cols || y < 0 || y >= map->
rows)
273 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
278 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
280 fwrite(&(map->
rows),
sizeof(map->
rows),
sizeof(
char), fp);
282 fwrite(&(map->
cols),
sizeof(map->
cols),
sizeof(
char), fp);
284 for (i = 0; i < map->
rows; i++)
286 fwrite(&(map->
data[i * map->
bytes]),
sizeof(
char), map->
bytes, fp))
318 if (fread(&c,
sizeof(
char),
sizeof(
char), fp) !=
sizeof(
char)) {
328 if (fread(buf,
BM_TEXT_LEN,
sizeof(
char), fp) !=
sizeof(
char)) {
333 if (fread(&c,
sizeof(
char),
sizeof(
char), fp) !=
sizeof(
char)) {
339 if (fread(&(map->
rows),
sizeof(map->
rows),
sizeof(
char), fp) !=
345 if (fread(&(map->
cols),
sizeof(map->
cols),
sizeof(
char), fp) !=
361 for (i = 0; i < map->
rows; i++)
363 fread(&(map->
data[i * map->
bytes]),
sizeof(
char), map->
bytes, fp)) {
382 for (y = 0; y < map->
rows; y++) {
384 if (fread(&i,
sizeof(i),
sizeof(
char), fp) !=
sizeof(
char)) {
392 for (i = 0; i < cnt; i++) {
404 if (fread(&n,
sizeof(n),
sizeof(char), fp) !=
sizeof(char)) {
411 if (fread(&n,
sizeof(n),
sizeof(
char), fp) !=
sizeof(
char)) {
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.
int BM_set_mode(int mode, int size)
Specify the type of data structure to use for bitmap. 'mode' can be either BM_FLAT or BM_SPARSE:
#define BM_col_to_byte(x)
struct BM * BM_create_sparse(int, int)
Create a sparse bitmap of dimension 'x'/'y'.
int BM_set_sparse(struct BM *, int, int, int)
Set sparse bitmap value to 'val' at location 'x'/'y'.
size_t BM_get_map_size_sparse(struct BM *)
Returns size of sparse bitmap in bytes.
int BM_file_write_sparse(FILE *, struct BM *)
Write sparse bitmap matrix out to disk file 'fp'. NOTE: 'fp' must already be opened and later closed ...
int BM_get_sparse(struct BM *, int, int)
Returns sparse bitmap value at location 'x'/'y'.
int BM_destroy_sparse(struct BM *)
Destroy sparse bitmap and free all associated memory.
struct link_head * link_init(int)
void link_set_chunk_size(int)
VOID_T * link_new(struct link_head *)