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

Committer:
WiredHome
Date:
Wed Apr 27 01:30:31 2016 +0000
Revision:
0:9ecf49d75058
Child:
1:84fb3e9adaaf
Demonstration that loads various bitmap files of different color depth.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 0:9ecf49d75058 1 // ______________ ______________ ______________ _______________
WiredHome 0:9ecf49d75058 2 // /_____ _____/ / ___________/ / ___________/ /_____ ______/
WiredHome 0:9ecf49d75058 3 // / / / / / / / /
WiredHome 0:9ecf49d75058 4 // / / / /___ / /__________ / /
WiredHome 0:9ecf49d75058 5 // / / / ____/ /__________ / / /
WiredHome 0:9ecf49d75058 6 // / / / / / / / /
WiredHome 0:9ecf49d75058 7 // / / / /__________ ___________/ / / /
WiredHome 0:9ecf49d75058 8 // /__/ /_____________/ /_____________/ /__/
WiredHome 0:9ecf49d75058 9 //
WiredHome 0:9ecf49d75058 10
WiredHome 0:9ecf49d75058 11 #include "mbed.h" // v118
WiredHome 0:9ecf49d75058 12 #include "RA8875.h" // v111
WiredHome 0:9ecf49d75058 13 #include "WebColors.h"
WiredHome 0:9ecf49d75058 14 #include <algorithm>
WiredHome 0:9ecf49d75058 15
WiredHome 0:9ecf49d75058 16
WiredHome 0:9ecf49d75058 17 RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 0:9ecf49d75058 18 Serial pc(USBTX, USBRX);
WiredHome 0:9ecf49d75058 19 extern "C" void mbed_reset();
WiredHome 0:9ecf49d75058 20
WiredHome 0:9ecf49d75058 21
WiredHome 0:9ecf49d75058 22 // Not all systems have the LocalFileSystem. Plug in the library and driver for yours.
WiredHome 0:9ecf49d75058 23 LocalFileSystem local("local"); // BMP test
WiredHome 0:9ecf49d75058 24
WiredHome 0:9ecf49d75058 25 typedef struct {
WiredHome 0:9ecf49d75058 26 loc_t x;
WiredHome 0:9ecf49d75058 27 loc_t y;
WiredHome 0:9ecf49d75058 28 char * filename;
WiredHome 0:9ecf49d75058 29 } TestImage_T;
WiredHome 0:9ecf49d75058 30
WiredHome 0:9ecf49d75058 31 TestImage_T TestImage[] = {
WiredHome 0:9ecf49d75058 32 { 0, 0, "/local/01601602.bmp"},
WiredHome 0:9ecf49d75058 33 { 0, 0, "/local/48027224.bmp"},
WiredHome 0:9ecf49d75058 34 { 0, 0, "/local/48027208.bmp"},
WiredHome 0:9ecf49d75058 35 { 0, 0, "/local/48027204.bmp"},
WiredHome 0:9ecf49d75058 36 { 0, 0, "/local/48027202.bmp"},
WiredHome 0:9ecf49d75058 37 { 0, 0, "/local/TestPat.bmp"}
WiredHome 0:9ecf49d75058 38 };
WiredHome 0:9ecf49d75058 39
WiredHome 0:9ecf49d75058 40 // deefine your screen size and color depth.
WiredHome 0:9ecf49d75058 41 #define SCREEN_W 480
WiredHome 0:9ecf49d75058 42 #define SCREEN_H 272
WiredHome 0:9ecf49d75058 43 #define SCREEN_BPP 16
WiredHome 0:9ecf49d75058 44
WiredHome 0:9ecf49d75058 45 int main()
WiredHome 0:9ecf49d75058 46 {
WiredHome 0:9ecf49d75058 47 pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 0:9ecf49d75058 48 pc.printf("\r\nRA8875 Bitmap Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 0:9ecf49d75058 49
WiredHome 0:9ecf49d75058 50 lcd.init(SCREEN_W, SCREEN_H, SCREEN_BPP);
WiredHome 0:9ecf49d75058 51
WiredHome 0:9ecf49d75058 52 int count = sizeof(TestImage)/sizeof(TestImage[0]);
WiredHome 0:9ecf49d75058 53 for (int i=0; i<count; i++) {
WiredHome 0:9ecf49d75058 54 lcd.cls();
WiredHome 0:9ecf49d75058 55 printf("RenderBitmapFile(%d, %d, %s) ", TestImage[i].x, TestImage[i].y, TestImage[i].filename);
WiredHome 0:9ecf49d75058 56 RetCode_t r = lcd.RenderBitmapFile(TestImage[i].x, TestImage[i].y, TestImage[i].filename);
WiredHome 0:9ecf49d75058 57 printf("returned %d\r\n", r);
WiredHome 0:9ecf49d75058 58 wait(5);
WiredHome 0:9ecf49d75058 59 }
WiredHome 0:9ecf49d75058 60 }