summaryrefslogtreecommitdiff
path: root/glcdgraphics/bitmap.c
diff options
context:
space:
mode:
authormrwastl <mrwastl@users.sourceforge.net>2011-06-05 18:33:23 +0200
committermrwastl <mrwastl@users.sourceforge.net>2011-06-05 18:33:23 +0200
commit245d1001901b69ded9dff996f7b09ac61ec5bed1 (patch)
treeaef595a3cb995da34c586dfa8124601b66837412 /glcdgraphics/bitmap.c
parent26f096b5cbf5f5102ce8bd24dff50b9ce7ecc558 (diff)
downloadgraphlcd-base-245d1001901b69ded9dff996f7b09ac61ec5bed1.tar.gz
graphlcd-base-245d1001901b69ded9dff996f7b09ac61ec5bed1.tar.bz2
bug fixes: offset fix when using #variables in <text/>, scrolling texts now stay correctly in the object area (no more drawing outside the right side of the object area)
Diffstat (limited to 'glcdgraphics/bitmap.c')
-rw-r--r--glcdgraphics/bitmap.c11
1 files changed, 8 insertions, 3 deletions
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;xt<charBitmap->Width();xt++) {
- for (yt=0;yt<charBitmap->Height();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;
}