From 6484da572117eaee88567f7b167ab261e28e7873 Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Sun, 21 Apr 2019 15:49:49 +0300 Subject: Import 4/1 bit bmp images Add some sanity checks according to bmp specification. Read color table and index data within the same scope and then simply extend the color palette. This particular implementation has one limitation: not all 4/1 bit images can be imported as it requires bit unpacking (size dimensions must be a multiple of 8 for 1-bit and 2 (even) for 4-bit images). --- modules/bmp/image_loader_bmp.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/bmp/image_loader_bmp.h') diff --git a/modules/bmp/image_loader_bmp.h b/modules/bmp/image_loader_bmp.h index b27a47d402..0082cf778a 100644 --- a/modules/bmp/image_loader_bmp.h +++ b/modules/bmp/image_loader_bmp.h @@ -37,6 +37,9 @@ class ImageLoaderBMP : public ImageFormatLoader { protected: static const unsigned BITMAP_SIGNATURE = 0x4d42; + static const unsigned BITMAP_FILE_HEADER_SIZE = 14; // bmp_file_header_s + static const unsigned BITMAP_INFO_HEADER_MIN_SIZE = 40; // bmp_info_header_s + enum bmp_compression_s { BI_RGB = 0x00, BI_RLE8 = 0x01, @@ -76,6 +79,7 @@ protected: static Error convert_to_image(Ref p_image, const uint8_t *p_buffer, const uint8_t *p_color_buffer, + const uint32_t color_table_size, const bmp_header_s &p_header); public: -- cgit v1.2.3