diff -r 1193bd7d460f -r 6b80a37fdf8d brewpanel/sdlgui.c --- a/brewpanel/sdlgui.c Sat Nov 28 21:00:29 2015 +0100 +++ b/brewpanel/sdlgui.c Wed Dec 02 17:16:41 2015 +0100 @@ -245,6 +245,63 @@ +void SDLGui_CGChar(SGOBJ *dlg, int fd, int x, int y, Uint8 data[8]) +{ + int i, j, x1, x2, y1, y2, dstpitch = 0; + SDL_Rect sr, dr; + Uint32 bg; + Uint8 *dstbits = NULL, mask; + SDL_Surface *CGchar; + SDL_Color blackWhiteColors[2] = {{255, 255, 255, 0}, {53, 59, 61, 0}}; + + CGchar = SDL_CreateRGBSurface(SDL_SWSURFACE, 10, 16, 8, 0, 0, 0, 0); + if (CGchar == NULL) { + fprintf(stderr, "SDLGui_CGChar Can not init font graphics!\n"); + return; + } + dstbits = (Uint8 *)CGchar->pixels; + dstpitch = CGchar->pitch; + mask = 0x10; + i = j = 0; + + /* + * Create a bitmap with the character pixels + */ + for (y1 = 0; y1 < 8; y1++) { + for (y2 = 0; y2 < 2; y2++) { + j = 0; + for (x1 = 0; x1 < 5; x1++) { + for (x2 = 0; x2 < 2; x2++) { + dstbits[j] = (data[i] & mask) ? 1 : 0; + j++; + } + mask >>= 1; + if (! mask) + mask = 0x10; + } + dstbits += dstpitch; + } + i++; + } + + SDL_SetColors(CGchar, blackWhiteColors, 0, 2); + SDL_SetColorKey(CGchar, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0); + bg = LCDbg0; + + sr.x = sr.y = 0; + dr.x = x; + dr.y = y; + sr.w = dr.w = fontwidth; + sr.h = dr.h = fontheight; + + SDL_FillRect(pSdlGuiScrn, &dr, bg); + SDL_BlitSurface(CGchar, &sr, pSdlGuiScrn, &dr); + SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); + SDL_FreeSurface(CGchar); +} + + + /* * Draw a text character */