File library for Bitmap images (*.bmp, *.dib). Currently supports only Windows V3 format with 24-bit-per-pixel color depth.
Diff: BMPFile.h
- Revision:
- 0:4617bf407fe5
- Child:
- 1:8cf4beca9695
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BMPFile.h Wed Mar 04 00:29:12 2015 +0000 @@ -0,0 +1,70 @@ +// ==================================================== Mar 04 2015, kayeks == +// BMPFile.h +// =========================================================================== +// File library for Bitmap images (*.bmp, *.dib). + +#ifndef BMPFILE_H_ +#define BMPFILE_H_ + +#include "mbed.h" + +struct BMPFile { + /** Object status. + * This indicates the error type when reading/parsing file is failed. */ + enum Status { + Success /** Read successfully. (no errors) */ + , NullFilename /** File name string is missing. */ + , NoSuchFile /** File is missing or cannot be opened. */ + , NotABitmapFile /** File is not a bitmap image. (wrong magic number) */ + , UnsupportedFormat /** Unsupported bitmap format type. */ + , UnsupportedDepth /** Unsupported color depth configuration. + This library does not support any indexed color depth (1/4/8 bpp). */ + , AllocationFailed /** Data space allocation failed. */ + }; + + /** Bitmap format type. */ + enum Format { + Windows_V3 /** Windows bitmap version 3. header size is 40 bytes. */ + , Windows_V4 /** Windows bitmap version 4. header size is 108 bytes. */ + , Windows_V5 /** Windows bitmap version 5. header size is 124 bytes. */ + , OS2_V1 /** OS/2 bitmap version 1. header size is 12 bytes. */ + , OS2_V2 /** OS/2 bitmap version 2. header size is 64 bytes. */ + , Unknown /** Unknown bitmap format type. */ + }; + static const char* StatusString[]; + static const char* FormatString[]; + + /** The object status. */ + Status status; + + /** The bitmap format type. */ + Format format; + + /** The image file size in bytes, including its header part. */ + uint32_t fileSize; + + /** The image data part size in bytes. */ + uint32_t dataSize; + + /** The image width in pixels. */ + uint32_t width; + + /** The image height in pixels. */ + uint32_t height; + + /** The color depth of the image in bit-per-pixel. */ + uint16_t colorDepth; + + /** The data part of image (raw array). */ + uint8_t* data; + + /** Constructor of struct BMPFile. + * @param filename Input file name string. + */ + BMPFile(const char* filename); + + /** Destructor of struct BMPFile. */ + ~BMPFile(); +}; + +#endif