91 #error Add the FatFs Library or delete the Bitmap module.
103 static const char* BMP_ERROR_STRING[] = {
106 "Could not allocate enough memory to complete the operation",
107 "File input/output error",
109 "File is not a supported BMP variant (must be uncompressed 16, 24 or 32 BPP)",
110 "File is not a valid BMP image",
111 "An argument is invalid or out of range",
112 "The requested action is not compatible with the BMP's type"
137 if (filename == NULL) {
142 if (f_open(&f, filename, FA_READ) != FR_OK) {
167 &bytesread) == FR_OK) {
170 pixel = (buffer[0] << 8) | buffer[1];
174 pixel = ((buffer[0] >> 3) & 0x001F)
175 | ((buffer[1] << 3) & 0x07E0)
176 | ((buffer[2] << 8) & 0xF800);
205 if (filename == NULL) {
214 if (f_open(&f, filename, FA_READ) != FR_OK) {
235 if (bmp->
Data == NULL) {
305 uint8_t *g, uint8_t *b) {
308 uint32_t bytes_per_row;
309 uint8_t bytes_per_pixel;
311 if (bmp == NULL || x < 0 || x >= bmp->
Header.
Width || y < 0
324 + x * bytes_per_pixel);
349 return BMP_ERROR_STRING[errorcode];
364 if (bmp == NULL || f == NULL) {
417 if (x == NULL || f == NULL) {
421 if ((f_read(f, little, 4, &bytesread) != FR_OK) || (bytesread != 4)) {
425 *x = (little[3] << 24 | little[2] << 16 | little[1] << 8 | little[0]);
441 if (x == NULL || f == NULL) {
445 if ((f_read(f, little, 2, &bytesread) != FR_OK) || (bytesread != 2)) {
449 *x = (little[1] << 8 | little[0]);
uint32_t LCD_BMP_GetWidth(BMP *bmp)
Returns the image's width.
static int LCD_BMP_Read_uint16_t(uint16_t *x, FIL *f)
Reads a little-endian unsigned short int from the file.
static void LCD_WritePixel(uint16_t x, uint16_t y, uint16_t pixel)
Write one pixel to the display.
BMP_STATUS LCD_BMP_GetPixelRGB(BMP *bmp, uint32_t x, uint32_t y, uint8_t *r, uint8_t *g, uint8_t *b)
Populates the arguments with the specified pixel's RGB values.
BMP_STATUS LCD_BMP_DrawBitmap(const char *filename, uint16_t Xpos, uint16_t Ypos)
Reads the specified BMP image file and print it to the LCD. It does only read bitmaps with 16...
const char * LCD_BMP_GetErrorDescription(uint8_t errorcode)
Returns a description of the last error code.
uint16_t LCD_BMP_GetDepth(BMP *bmp)
Returns the image's color depth (bits per pixel).
BMP_STATUS LCD_BMP_ReadHeader(BMP *bmp, FIL *f)
Reads the BMP file's header into the data structure.
Simple graphic library main functionality.
enum _BMP_STATUS BMP_STATUS
Error codes.
static int LCD_BMP_Read_uint32_t(uint32_t *x, FIL *f)
Reads a little-endian unsigned int from the file.
uint32_t LCD_BMP_GetHeight(BMP *bmp)
Returns the image's height.
BMP_STATUS LCD_BMP_ReadFile(BMP *bmp, const char *filename)
Reads the specified BMP image file. It does only read bitmaps with 16, 24 or 32 bits per pixel and u...