GLIB BMP#
Bitmap Support.
Modules#
Functions#
Initializes BMP Module.
Makes the module ready for new bmp file.
Reads in data from BMP file and fills buffer with RGB values.
Fills buffer with raw data from BMP file.
Get width of BMP image in pixels.
Get height of BMP image in pixels.
Get color depth (bits per pixel)
Get compression type.
Get imageDataSize in bytes.
Get the offset, i.e.
Get the fileSize in bytes.
Macros#
BMP base error code.
Successful call.
End of file has been reached.
General IO error.
BMP_Header size in bytes is different from BMP_HEADER_SIZE.
Endian mismatch.
BMP file is not supported.
BMP "file" is not a BMP file.
Argument passed to function is invalid.
BMP module is not initialized.
Invalid palette size.
File not reset.
End of bmp file is reached.
Buffer provided is too small.
Bmp palette is not read.
Palette size in bytes.
BMP Header Size in bytes.
BMP Local cache limit.
Use RLE8 compression.
Use no compression.
BMP Local cache size.
Function Documentation#
__attribute__#
struct __BMP_Header __attribute__ ((__packed__) )
N/A |
1
of file platform/middleware/glib/glib/bmp.h
BMP_init#
EMSTATUS BMP_init (uint8_t * palette, uint32_t paletteSize, EMSTATUS(*)(uint8_t buffer[], uint32_t bufLength, uint32_t bytesToRead) fp)
Initializes BMP Module.
N/A | palette | Data buffer to hold palette. Required for 8bpp BMPs. |
N/A | paletteSize | Size of palette in bytes. If BMP is 8-bit, this potentially has to be 256 * 4 bytes. If the user knows that he only loads BMPs with N bytes, he can pass in paletteSize = N. Otherwise this value should be 256 * 4 = 1024 bytes to ensure that the palette is big enough for all 8-bits BMPs. |
N/A | fp | Function pointer that is used to read in bytes from BMP file. The function has to return an EMSTATUS and have the following parameter list (uint32_t buffer[], uint32_t bufLength, uint32_t bytesToRead). The function should fill (buffer) with (bytesToRead) bytes from the beginning. If it succeds it has to return BMP_OK, otherwise it should return BMP_ERROR_IO. When the function returns it should be ready to read from where it left off. |
Support:
24-bit Uncompressed.
8-bit Uncompressed.
8-bit RLE compressed.
Returns
Returns BMP_OK on success, or else error code.
178
of file platform/middleware/glib/glib/bmp.h
BMP_reset#
EMSTATUS BMP_reset (void )
Makes the module ready for new bmp file.
N/A |
Reads in header from file, and checks if the provided bmp file is valid and supported. It reads in palette if BMP file is 8bpp. Uses function pointer set in BMP_init().
Returns
Returns BMP_OK on success, or else error code
179
of file platform/middleware/glib/glib/bmp.h
BMP_readRgbData#
EMSTATUS BMP_readRgbData (uint8_t buffer, uint32_t bufLength, uint32_t * pixelsRead)
Reads in data from BMP file and fills buffer with RGB values.
N/A | buffer | Buffer to hold RGB values. |
N/A | bufLength | Buffer length in bytes. |
N/A | pixelsRead | Pointer to a uint32_t which holds how many bytes that are read. |
This function terminates either when the buffer is full, end of row is reached or end of file is reached.
Returns
Returns BMP_OK on success
Returns BMP_ERROR_END_OF_FILE if end of file is reached
Returns error code otherwise.
180
of file platform/middleware/glib/glib/bmp.h
BMP_readRawData#
EMSTATUS BMP_readRawData (BMP_DataType * dataType, uint8_t buffer, uint32_t bufLength)
Fills buffer with raw data from BMP file.
N/A | dataType | Data type struct which holds information about the data returned |
N/A | buffer | Buffer to be filled with raw data |
N/A | bufLength | Length of buffer |
If data is 24bit: Buffer is filled with RGB values till its full or end of row is reached.
If data is 8bit: Buffer is filled with palette indicies till its full or end of row is reached.
If data is RLE8: Buffer is filled with number of pixels, followed by palette indicies like this (N is number of pixels, P is palette index) buffer = { N P N P ... }.
Data is 24bpp if dataType.bitsPerPixel == 24 and dataType.compressionType == NO_COMPRESSION.
Data is 8bpp if dataType.bitsPerPixel == 8 and dataType.compressionType == NO_COMPRESSION.
Data is RLE8 if dataType.bitsPerPixel == 8 and dataType.compressionType == RLE8_COMPRESSION.
Returns
Returns BMP_OK on success, or else error code
181
of file platform/middleware/glib/glib/bmp.h
BMP_getWidth#
int32_t BMP_getWidth (void )
Get width of BMP image in pixels.
N/A |
Returns
Returns width of image, or -1 on error
184
of file platform/middleware/glib/glib/bmp.h
BMP_getHeight#
int32_t BMP_getHeight (void )
Get height of BMP image in pixels.
N/A |
Returns
Returns height, or -1 on error
185
of file platform/middleware/glib/glib/bmp.h
BMP_getBitsPerPixel#
int16_t BMP_getBitsPerPixel (void )
Get color depth (bits per pixel)
N/A |
Returns
Returns bitsPerPixel, or -1 on error
186
of file platform/middleware/glib/glib/bmp.h
BMP_getCompressionType#
int32_t BMP_getCompressionType (void )
Get compression type.
N/A |
0 - No compression 1 - RLE 8bpp 2 - RLE 4bpp Returns
Returns compressionType, or -1 on error
187
of file platform/middleware/glib/glib/bmp.h
BMP_getImageDataSize#
int32_t BMP_getImageDataSize (void )
Get imageDataSize in bytes.
N/A |
Returns
Returns imageDataSize, or -1 on error
188
of file platform/middleware/glib/glib/bmp.h
BMP_getDataOffset#
int32_t BMP_getDataOffset (void )
Get the offset, i.e.
N/A |
starting address, of the byte where the bitmap data can be found. Returns
Returns dataOffset, or -1 on error
189
of file platform/middleware/glib/glib/bmp.h
BMP_getFileSize#
int32_t BMP_getFileSize (void )
Get the fileSize in bytes.
N/A |
Returns
Returns fileSize, or -1 on error
190
of file platform/middleware/glib/glib/bmp.h
Macro Definition Documentation#
ECODE_BMP_BASE#
#define ECODE_BMP_BASEValue:
0x00000000
BMP base error code.
59
of file platform/middleware/glib/glib/bmp.h
BMP_OK#
#define BMP_OKValue:
0x00000000
Successful call.
63
of file platform/middleware/glib/glib/bmp.h
BMP_END_OF_FILE#
#define BMP_END_OF_FILE
End of file has been reached.
65
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_IO#
#define BMP_ERROR_IOValue:
(ECODE_BMP_BASE | 0x0001)
General IO error.
67
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_HEADER_SIZE_MISMATCH#
#define BMP_ERROR_HEADER_SIZE_MISMATCHValue:
(ECODE_BMP_BASE | 0x0002)
BMP_Header size in bytes is different from BMP_HEADER_SIZE.
69
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_ENDIAN_MISMATCH#
#define BMP_ERROR_ENDIAN_MISMATCHValue:
(ECODE_BMP_BASE | 0x0003)
Endian mismatch.
71
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_FILE_NOT_SUPPORTED#
#define BMP_ERROR_FILE_NOT_SUPPORTEDValue:
(ECODE_BMP_BASE | 0x0004)
BMP file is not supported.
73
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_FILE_INVALID#
#define BMP_ERROR_FILE_INVALIDValue:
(ECODE_BMP_BASE | 0x0005)
BMP "file" is not a BMP file.
75
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_INVALID_ARGUMENT#
#define BMP_ERROR_INVALID_ARGUMENTValue:
(ECODE_BMP_BASE | 0x0006)
Argument passed to function is invalid.
77
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_MODULE_NOT_INITIALIZED#
#define BMP_ERROR_MODULE_NOT_INITIALIZEDValue:
(ECODE_BMP_BASE | 0x0007)
BMP module is not initialized.
Call BMP_init()
79
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_INVALID_PALETTE_SIZE#
#define BMP_ERROR_INVALID_PALETTE_SIZEValue:
(ECODE_BMP_BASE | 0x0008)
Invalid palette size.
81
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_FILE_NOT_RESET#
#define BMP_ERROR_FILE_NOT_RESETValue:
(ECODE_BMP_BASE | 0x0009)
File not reset.
Call BMP_reset()
83
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_END_OF_FILE#
#define BMP_ERROR_END_OF_FILEValue:
(ECODE_BMP_BASE | 0x0010)
End of bmp file is reached.
85
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_BUFFER_TOO_SMALL#
#define BMP_ERROR_BUFFER_TOO_SMALLValue:
(ECODE_BMP_BASE | 0x0020)
Buffer provided is too small.
87
of file platform/middleware/glib/glib/bmp.h
BMP_ERROR_PALETTE_NOT_READ#
#define BMP_ERROR_PALETTE_NOT_READValue:
(ECODE_BMP_BASE | 0x0030)
Bmp palette is not read.
89
of file platform/middleware/glib/glib/bmp.h
BMP_PALETTE_8BIT_SIZE#
#define BMP_PALETTE_8BIT_SIZEValue:
(256 * 4)
Palette size in bytes.
92
of file platform/middleware/glib/glib/bmp.h
BMP_HEADER_SIZE#
#define BMP_HEADER_SIZEValue:
(54)
BMP Header Size in bytes.
94
of file platform/middleware/glib/glib/bmp.h
BMP_LOCAL_CACHE_LIMIT#
#define BMP_LOCAL_CACHE_LIMITValue:
(3)
BMP Local cache limit.
96
of file platform/middleware/glib/glib/bmp.h
RLE8_COMPRESSION#
#define RLE8_COMPRESSIONValue:
(1)
Use RLE8 compression.
99
of file platform/middleware/glib/glib/bmp.h
NO_COMPRESSION#
#define NO_COMPRESSIONValue:
(0)
Use no compression.
101
of file platform/middleware/glib/glib/bmp.h
BMP_LOCAL_CACHE_SIZE#
#define BMP_LOCAL_CACHE_SIZEValue:
(BMP_CONFIG_LOCAL_CACHE_SIZE)
BMP Local cache size.
104
of file platform/middleware/glib/glib/bmp.h