From 245d1001901b69ded9dff996f7b09ac61ec5bed1 Mon Sep 17 00:00:00 2001 From: mrwastl Date: Sun, 5 Jun 2011 18:33:23 +0200 Subject: bug fixes: offset fix when using #variables in , scrolling texts now stay correctly in the object area (no more drawing outside the right side of the object area) --- glcdgraphics/bitmap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'glcdgraphics') diff --git a/glcdgraphics/bitmap.c b/glcdgraphics/bitmap.c index 470b208..464f189 100644 --- a/glcdgraphics/bitmap.c +++ b/glcdgraphics/bitmap.c @@ -676,11 +676,16 @@ int cBitmap::DrawCharacter(int x, int y, int xmax, uint32_t c, const cFont * fon charBitmap = font->GetCharacter(c); if (charBitmap) { + int drawWidth = charBitmap->Width() - skipPixels; + if ( x + drawWidth-1 > xmax) + drawWidth = xmax - x + 1; + drawBitmap = new cBitmap(charBitmap->Width()-skipPixels,charBitmap->Height()); drawBitmap->Clear(bgcolor); if (drawBitmap) { - for (xt=0;xtWidth();xt++) { - for (yt=0;ytHeight();yt++) { + + for (xt = 0; xt < drawWidth; xt++) { + for (yt = 0; yt < charBitmap->Height() ; yt++) { dot = charBitmap->GetPixel(xt+skipPixels,yt); if ((dot | 0xFF000000) == cColor::Black) { // todo: does not work with antialising? drawBitmap->DrawPixel(xt, yt, color); @@ -692,7 +697,7 @@ int cBitmap::DrawCharacter(int x, int y, int xmax, uint32_t c, const cFont * fon DrawBitmap(x, y, *drawBitmap); delete drawBitmap; } - return charBitmap->Width() - skipPixels; + return drawWidth; //charBitmap->Width() - skipPixels; } return 0; } -- cgit v1.2.3