aboutsummaryrefslogtreecommitdiff
path: root/src/bitmap.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-09-02 17:29:51 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-09-02 17:29:51 +0200
commit96fe104e6b1c1452a8408bb46baa73d2b93bcf0e (patch)
tree88a883853fb100d54d35921c0d3e7c6b39a899ee /src/bitmap.c
parentf546868b1f4d0eae4dc3ecc26035829cf0f2f721 (diff)
downloadAsciiMap-96fe104e6b1c1452a8408bb46baa73d2b93bcf0e.tar.gz
bitmap_strerror: More verbose bitmap failures
Diffstat (limited to 'src/bitmap.c')
-rw-r--r--src/bitmap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bitmap.c b/src/bitmap.c
index 6d72cb0..31256e8 100644
--- a/src/bitmap.c
+++ b/src/bitmap.c
@@ -6,6 +6,15 @@
#include "bitmap.h"
+static const int bitmap_errors_cnt = 5;
+static const char* bitmap_errors[] = {
+ "OK.",
+ "Error opening file.", // Use errno instead
+ "Invalid or corrupted file.",
+ "Unsupported bit depth.",
+ "Compression not supported."
+};
+
static struct bitmap_file_header bitmap_read_file_header(FILE *_file);
static struct bitmap_image bitmap_read_pixel_data(FILE *_file, struct bitmap_file_header _header);
@@ -265,3 +274,10 @@ static uint8_t bitmap_rgb_luminance(uint8_t R, uint8_t G, uint8_t B) {
return ret;
}
+
+char* bitmap_strerror( int _error ) {
+ if ( _error >= bitmap_errors_cnt || _error < 0)
+ return "Unknown Error.";
+
+ return (char*) bitmap_errors[_error];
+}