Packed 12bit Raw image file load to display to Nokia LCD. Add function "blit12" to Nokia LCD for native 12bit color buffer.
Diff: main.cpp
- Revision:
- 3:8739f7e5148a
- Parent:
- 2:7cf441bf092d
- Child:
- 4:f746ea56e891
--- a/main.cpp Thu Feb 10 13:44:58 2011 +0000 +++ b/main.cpp Thu Feb 10 14:29:29 2011 +0000 @@ -2,10 +2,6 @@ #include "NokiaLCD.h" #include "SDFileSystem.h" -typedef struct { - unsigned char r, g, b; -} RGB24; - NokiaLCD lcd(p11, p13, p14, p15, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type SDFileSystem sd(p5, p6, p7, p8, "sd"); @@ -13,46 +9,15 @@ lcd.background(0x000000); lcd.cls(); FILE *fp = NULL; -#if 1 fp = fopen("/sd/128x128.r12", "r"); if (fp != NULL) { printf("Start!\r\n"); - unsigned char bufLine[64 * 3]; - for (int y = 0; y < 128; y++) { - fread(bufLine, sizeof(unsigned char), (64 * 3), fp); - lcd.blit12(0, y, 128, 1, bufLine); - } + unsigned char bufLine[64 * 3 * 128]; + fread(bufLine, sizeof(unsigned char), (64 * 3 * 128), fp); + lcd.blit12(0, 0, 128, 128, bufLine); fclose(fp); printf("Finish!\r\n"); } else { printf("Can't open file.\r\n"); } -#else - fp = fopen("/sd/128x128.raw", "r"); - if (fp != NULL) { - printf("Start!\r\n"); - RGB24 bufLine[128]; - for (int y = 0; y < 128; y++) { - fread(bufLine, sizeof(RGB24), 128, fp); - int bufColor[128]; - for (int x = 0; x < 128; x++) { -#if 1 - int pix = (bufLine[x].r << 16) | (bufLine[x].g << 8) | bufLine[x].b; -#else - int pix = bufLine[x].r; - pix <<= 8; - pix |= bufLine[x].g; - pix <<= 8; - pix |= bufLine[x].b; -#endif - bufColor[x] = pix; - } - lcd.blit(0, y, 128, 1, bufColor); - } - fclose(fp); - printf("Finish!\r\n"); - } else { - printf("Can't open file.\r\n"); - } -#endif }