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:
7:f96367d6e3e2
Parent:
5:0330a01310ae
Child:
9:092f7ac73c03
--- a/tjpgd.cpp	Mon May 16 10:46:06 2016 +0000
+++ b/tjpgd.cpp	Mon May 16 11:07:15 2016 +0000
@@ -171,7 +171,7 @@
 {
     char *rp = 0;
     INFO("alloc_pool(%p,%d) %p:%d", jd, nd, jd->pool, jd->sz_pool);
-
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
     nd = (nd + 3) & ~3;         /* Align block size to the word boundary */
 
     if (jd->sz_pool >= nd) {
@@ -201,6 +201,8 @@
     uint8_t d, z;
     int32_t *pb;
 
+    INFO("create qt table (%p,%p,%d)", jd, data, ndata);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     while (ndata) { /* Process all tables in the segment */
         if (ndata < 65) return JDR_FMT1;    /* Err: table size is unaligned */
@@ -295,7 +297,7 @@
     uint8_t msk, s, *dp;
     uint16_t dc, v, f;
 
-
+    //INFO("bitext");
     msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr;   /* Bit mask, number of data available, read ptr */
     s = *dp; v = f = 0;
     do {
@@ -348,7 +350,7 @@
     uint8_t msk, s, *dp;
     uint16_t dc, v, f, bl, nd;
 
-
+    //INFO("huffext");
     msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr;   /* Bit mask, number of data available, read ptr */
     s = *dp; v = f = 0;
     bl = 16;    /* Max code length */
@@ -410,6 +412,7 @@
     int32_t t10, t11, t12, t13;
     uint16_t i;
 
+    INFO("block_idct");
     /* Process columns */
     for (i = 0; i < 8; i++) {
         v0 = src[8 * 0];    /* Get even elements */
@@ -525,6 +528,8 @@
     const uint16_t *hc;
     const int32_t *dqf;
 
+    INFO("mcu_load(%p)", jd);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     nby = jd->msx * jd->msy;    /* Number of Y blocks (1, 2 or 4) */
     nbc = 2;                    /* Number of C blocks (2) */
@@ -609,6 +614,8 @@
     uint8_t *py, *pc, *rgb24;
     JRECT rect;
 
+    INFO("mcu_output(%p,%p,%d,%d)", jd, outfunc, x, y);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     mx = jd->msx * 8; my = jd->msy * 8;                 /* MCU size (pixel) */
     rx = (x + mx <= jd->width) ? mx : jd->width - x;    /* Output rectangular size (it may be clipped at right/bottom end) */
@@ -756,6 +763,8 @@
     uint16_t d;
     uint8_t *dp;
 
+    INFO("restart(%p,%d)", jd, rstn);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     /* Discard padding bits and get two bytes from the input stream */
     dp = jd->dptr; dc = jd->dctr;
@@ -807,6 +816,8 @@
     uint16_t n, i, j, len;
     JRESULT rc;
 
+    INFO("jd_prepare(%p,%p,%p,%d,%p)", jd, infunc, pool, sz_pool, dev);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     if (!pool) return JDR_PAR;
 
@@ -999,6 +1010,8 @@
     uint16_t rst, rsc;
     JRESULT rc;
 
+    INFO("jd_decom(%p,%p,%d)", jd, outfunc, scale);
+    HexDump("JDEC", (uint8_t *)jd, sizeof(JDEC));
 
     if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR;
     jd->scale = scale;