Demonstration of the Bitmap rendering - reads BMP and JPG files in many format variants and renders to the screen.

Dependencies:   FlashFileSystem mbed RA8875

Bitmap and JPEG Demo

This demo publishes each graphic file from a list of files to the display. The graphic files can be BMP, JPG, or ICO. On the terminal it displays the filename and the return-code (in case of an error). This demo works as intended on the 480x272 display in either 8 or 16 bit per pixel mode and it should work on larger displays.

Items of interest to change and rebuild/test:

// Not all systems have the LocalFileSystem. Plug in the library and driver for yours.
LocalFileSystem local("local");             // Image source

TestImage_T TestImage[] = {
    { 0, 0, "/local/01601602.bmp"},
    { 0, 0, "/local/48027202.bmp"},
    { 0, 0, "/local/48027204.bmp"},
    { 0, 0, "/local/48027208.bmp"},
    { 0, 0, "/local/48027224.bmp"},
    { 0, 0, "/local/p480272.jpg"},
    { 0, 0, "/local/p480272.bmp"}
};

// deefine your screen size and color depth. 
#define SCREEN_W 480
#define SCREEN_H 272
#define SCREEN_BPP 16

LocalFileSystem may need to be altered to SDFileSystem (for example) and the corresponding paths in the TestImage array.

Also, the Screen size and bit per pixel color depth.

Images

The following image files are saved in different resolution and color depth. The first, and smallest, was simply for developing the monochrome support. Others are 4-bit color, 8-bit color, 24-bit color, and a mislabeled 1-bit color (shown as 02).

/media/uploads/WiredHome/testimages.zip

Revision:
15:f33dcd24d8d1
Parent:
14:694822610507
Child:
16:987892bebe05
--- a/main.cpp	Wed Aug 03 11:08:02 2016 +0000
+++ b/main.cpp	Sat Aug 06 14:50:25 2016 +0000
@@ -13,7 +13,30 @@
 #include "WebColors.h"
 #include <algorithm>
 
-#define JPEG_TEST
+//#define JPEG_TEST
+
+
+// These two defines can be enabled, or commented out
+//#define BIG_SCREEN
+//#define CAP_TOUCH
+#define LCD_C 16         // color - bits per pixel
+
+#ifdef CAP_TOUCH
+RA8875 lcd(p5, p6, p7, p12, NC, p9,p10,p13, "tft"); // MOSI,MISO,SCK,/ChipSelect,/reset, SDA,SCL,/IRQ, name
+#else
+RA8875 lcd(p5, p6, p7, p12, NC, "tft");             //MOSI, MISO, SCK, /ChipSelect, /reset, name
+LocalFileSystem local("local");                     // access to calibration file for resistive touch.
+#endif
+
+#ifdef BIG_SCREEN
+    #define LCD_W 800
+    #define LCD_H 480
+#else
+    #define LCD_W 480
+    #define LCD_H 272
+#endif
+
+
 
 //#define DEBUG "Main"
 // ...
@@ -50,14 +73,10 @@
 #define HexDump(a, b, c)
 #endif
 
-RA8875 lcd(p5, p6, p7, p12, NC, "tft");     // MOSI, MISO, SCK, /ChipSelect, /reset, name
 Serial pc(USBTX, USBRX);
 extern "C" void mbed_reset();
 
 
-// Not all systems have the LocalFileSystem. Plug in the library and driver for yours.
-LocalFileSystem local("local");             // BMP test
-
 typedef struct {
     loc_t x;
     loc_t y;
@@ -74,10 +93,6 @@
     { 0, 0, "/local/p480272.bmp"}
 };
 
-// deefine your screen size and color depth.
-#define SCREEN_W 480
-#define SCREEN_H 272
-#define SCREEN_BPP 16
 
 #ifdef JPEG_TEST
 //#include "tjpgd.h"
@@ -151,7 +166,7 @@
     pc.baud(460800);    // I like a snappy terminal, so crank it up!
     pc.printf("\r\nRA8875 Bitmap Test - Build " __DATE__ " " __TIME__ "\r\n");
 
-    lcd.init(SCREEN_W, SCREEN_H, SCREEN_BPP);
+    lcd.init(LCD_W, LCD_H, LCD_C);
     lcd.Backlight(0.5f);
     
     int count = sizeof(TestImage)/sizeof(TestImage[0]);