From a8e72b085e847ed7eb09040d9a89030f4ec37304 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Wed, 8 Apr 2015 13:59:45 +1000 Subject: [PATCH] + bitmap_print() --- src/bitmap.c | 14 ++++++++++++++ src/bitmap.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/bitmap.c b/src/bitmap.c index 46d339a..9c0c12d 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -89,3 +89,17 @@ bitmap_unpack(const unsigned char *map, return buf_size; } + +void +bitmap_print(const unsigned char *map) { + char line[BITMAP_SIDE * 2 + 1]; + + line[BITMAP_SIDE * 2] = '\0'; + for (size_t i = 0; i < BITMAP_SIDE; i++) { + for (size_t j = 0; j < BITMAP_SIDE; j++, map++) { + line[(j * 2) + 0] = (*map == 0x00) ? CHAR_NONE : CHAR_USED; + line[(j * 2) + 1] = (*map == 0x00) ? CHAR_NONE : CHAR_USED; + } + puts(line); + } +} diff --git a/src/bitmap.h b/src/bitmap.h index 912c645..36995f9 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -22,4 +22,7 @@ bitmap_diffmap(unsigned char *diff, size_t bitmap_unpack(const unsigned char *map, unsigned char ** const buf); + +void +bitmap_print(const unsigned char *map); #endif