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

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Wed Apr 27 01:30:31 2016 +0000
Child:
1:84fb3e9adaaf
Commit message:
Demonstration that loads various bitmap files of different color depth.

Changed in this revision

RA8875.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RA8875.lib	Wed Apr 27 01:30:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/WiredHome/code/RA8875/#325ca91bc03d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 27 01:30:31 2016 +0000
@@ -0,0 +1,60 @@
+//      ______________  ______________  ______________  _______________
+//     /_____   _____/ /  ___________/ /  ___________/ /_____   ______/
+//          /  /      /  /            /  /                  /  /
+//         /  /      /  /___         /  /__________        /  /
+//        /  /      /  ____/        /__________   /       /  /
+//       /  /      /  /                       /  /       /  /
+//      /  /      /  /__________  ___________/  /       /  /
+//     /__/      /_____________/ /_____________/       /__/
+//
+
+#include "mbed.h"           // v118
+#include "RA8875.h"         // v111
+#include "WebColors.h"
+#include <algorithm>
+
+
+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;
+    char * filename;
+} TestImage_T;
+
+TestImage_T TestImage[] = {
+    { 0, 0, "/local/01601602.bmp"},
+    { 0, 0, "/local/48027224.bmp"},
+    { 0, 0, "/local/48027208.bmp"},
+    { 0, 0, "/local/48027204.bmp"},
+    { 0, 0, "/local/48027202.bmp"},
+    { 0, 0, "/local/TestPat.bmp"}
+};
+
+// deefine your screen size and color depth.
+#define SCREEN_W 480
+#define SCREEN_H 272
+#define SCREEN_BPP 16
+
+int main()
+{
+    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);
+    
+    int count = sizeof(TestImage)/sizeof(TestImage[0]);
+    for (int i=0; i<count; i++) {
+        lcd.cls();
+        printf("RenderBitmapFile(%d, %d, %s) ", TestImage[i].x, TestImage[i].y, TestImage[i].filename);
+        RetCode_t r = lcd.RenderBitmapFile(TestImage[i].x, TestImage[i].y, TestImage[i].filename);
+        printf("returned %d\r\n", r);
+        wait(5);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 27 01:30:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f
\ No newline at end of file