X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/a7be12a4e68fcaaa92f81a394bc316a592ec6270..64f3f4c19cc280c2bff7ee57d5bcdda036dfcbf8:/drivers/displays/tft/bmp.c diff --git a/drivers/displays/tft/bmp.c b/drivers/displays/tft/bmp.c index a378a86..db55fe7 100644 --- a/drivers/displays/tft/bmp.c +++ b/drivers/displays/tft/bmp.c @@ -122,7 +122,7 @@ bmp_error_t bmpParseBitmap(uint16_t x, uint16_t y, FIL file) // Render pixel // ToDo: This is a brutally slow way of rendering bitmaps ... // update to pass one row of data at a time - drawPixel(x + px, y + py - 1, drawRGB24toRGB565(buffer[(px * 3) + 2], buffer[(px * 3) + 1], buffer[(px * 3)])); + drawPixel(x + px, y + py - 1, colorsRGB24toRGB565(buffer[(px * 3) + 2], buffer[(px * 3) + 1], buffer[(px * 3)])); } } @@ -146,12 +146,34 @@ bmp_error_t bmpParseBitmap(uint16_t x, uint16_t y, FIL file) #include "drivers/displays/tft/bmp.h" - bmp_error_t error; - // Draw image.bmp (from the root folder) starting at pixel 0,0 - error = bmpDrawBitmap(0, 0, "/image.bmp"); + bmp_error_t error = bmpDrawBitmap(0, 0, "/image.bmp"); - // Check 'error' for problems such as BMP_ERROR_FILENOTFOUND + if (error) + { + switch (error) + { + case BMP_ERROR_SDINITFAIL: + break; + case BMP_ERROR_FILENOTFOUND: + break; + case BMP_ERROR_NOTABITMAP: + // First two bytes of image not 'BM' + break; + case BMP_ERROR_INVALIDBITDEPTH: + // Image is not 24-bits + break; + case BMP_ERROR_COMPRESSEDDATA: + // Image contains compressed data + break; + case BMP_ERROR_INVALIDDIMENSIONS: + // Width or Height is > LCD size + break; + case BMP_ERROR_PREMATUREEOF: + // EOF unexpectedly reached in pixel data + break; + } + } @endcode */ @@ -326,7 +348,7 @@ bmp_error_t bmpSaveScreenshot(const char* filename) for (x = 0; x < lcdWidth; x++) { rgb565 = lcdGetPixel(x, y - 1); // Get RGB565 pixel - bgra32 = drawRGB565toBGRA32(rgb565); // Convert RGB565 to 24-bit color + bgra32 = colorsRGB565toBGRA32(rgb565); // Convert RGB565 to 24-bit color r = (bgra32 & 0x00FF0000) >> 16; g = (bgra32 & 0x0000FF00) >> 8; b = (bgra32 & 0x000000FF);