LCD LIB
Fork of RA8875 by
Diff: RA8875.cpp
- Revision:
- 63:ed787f5fcdc4
- Parent:
- 53:86d24b9480b9
--- a/RA8875.cpp Mon Mar 17 11:29:40 2014 +0000 +++ b/RA8875.cpp Sun Mar 23 16:27:55 2014 +0000 @@ -1658,6 +1658,54 @@ } } +void TestGraphicsPNG(RA8875 &display, Serial &pc) +{ + loc_t x, y; + dim_t bmpWid; + dim_t bmpHei; + char *fn = "/local/test.png"; + + LocalFileSystem local("local"); + if (!SuppressSlowStuff) + pc.printf("PNG File Load\r\n"); + display.background(Black); + display.foreground(Blue); + display.cls(); + display.puts(0,0, "Graphics Test, loading "); + display.puts(fn); + wait(3); + YsRawPngDecoder png; + png.Initialize(); + pc.printf("png.Initialize() completed.\r\n"); + if (png.Decode(fn)==YSOK) + { + bmpWid = (png.wid+3)&(~3); + bmpHei = png.hei; + + pc.printf("png.Decode(%s) completed.\r\n", fn); + for(y=0; y<bmpHei; y++) + { + pc.printf(" y = %d\r\n", y); + for(x=0; x<bmpWid; x++) + { + const unsigned char *rgba; + if(x<png.wid) + { + rgba=png.rgba+(y*png.wid+x)*4; + } + else + { + rgba=png.rgba+(y*png.wid+png.wid-1)*4; + } + display.pixel(x, y, RGB(rgba[0], rgba[1], rgba[2])); + //buf[(y*bmpWid+x)*3 ]=rgba[2]; + //buf[(y*bmpWid+x)*3+1]=rgba[1]; + //buf[(y*bmpWid+x)*3+2]=rgba[0]; + } + } + } + //int r = display.RenderBitmapFile(0,0, "/local/test.png"); +} void TestGraphicsBitmap(RA8875 & display, Serial & pc) { @@ -1697,6 +1745,7 @@ EllipseTest(display, pc); LayerTest(display, pc); //TestGraphicsBitmap(display, pc); + //TestGraphicsPNG(display, pc); pc.printf("SpeedTest completed in %d msec\r\n", t.read_ms()); #ifdef PERF_METRICS display.ReportPerformance(pc); @@ -1724,7 +1773,7 @@ pc.printf("\r\n" "B - Backlight up b - backlight dim\r\n" "D - DOS Colors W - Web Colors\r\n" - "t - text cursor G - Graphics Bitmap\r\n" + "t - text cursor G - Graphics Bitmap g - PNG\r\n" "L - Lines F - external Font\r\n" "R - Rectangles O - rOund rectangles\r\n" "T - Triangles P - Pixels \r\n" @@ -1804,6 +1853,9 @@ case 'G': TestGraphicsBitmap(lcd, pc); break; + case 'g': + TestGraphicsPNG(lcd, pc); + break; case 'C': CircleTest(lcd, pc); break;