summaryrefslogtreecommitdiff
path: root/apps/examples/nxhello/nxhello_bkgd.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-27 14:43:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-27 14:43:45 +0000
commit99ffb319c5af373ef135c2a3e73bf1171e55559e (patch)
tree7aa08fa81a006d354469de2652043ab969d8a3c4 /apps/examples/nxhello/nxhello_bkgd.c
parentce09509ff8c3127b4cc07ebcaae78229d5b2d90a (diff)
downloadnuttx-99ffb319c5af373ef135c2a3e73bf1171e55559e.tar.gz
nuttx-99ffb319c5af373ef135c2a3e73bf1171e55559e.tar.bz2
nuttx-99ffb319c5af373ef135c2a3e73bf1171e55559e.zip
Incorporated new fonts into examples; fix glyph allocation bug in nxhello
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3822 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/nxhello/nxhello_bkgd.c')
-rw-r--r--apps/examples/nxhello/nxhello_bkgd.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/examples/nxhello/nxhello_bkgd.c b/apps/examples/nxhello/nxhello_bkgd.c
index 43bfc0516..93b7798e1 100644
--- a/apps/examples/nxhello/nxhello_bkgd.c
+++ b/apps/examples/nxhello/nxhello_bkgd.c
@@ -233,7 +233,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos,
{
/* Add the font size */
- width += fbm->metric.width;
+ width += fbm->metric.width + fbm->metric.xoffset;
}
else
{
@@ -349,6 +349,7 @@ void nxhello_hello(NXWINDOW hwnd)
FAR struct nxgl_rect_s dest;
FAR const void *src[CONFIG_NX_NPLANES];
unsigned int glyphsize;
+ unsigned int mxstride;
int ret;
/* Get information about the font we are going to use */
@@ -357,8 +358,9 @@ void nxhello_hello(NXWINDOW hwnd)
/* Allocate a bit of memory to hold the largest rendered font */
- glyphsize = (unsigned int)fontset->mxheight * (unsigned int)fontset->mxwidth;
- glyph = (FAR uint8_t*)malloc(glyphsize);
+ mxstride = (fontset->mxwidth * CONFIG_EXAMPLES_NXHELLO_BPP + 7) >> 3;
+ glyphsize = (unsigned int)fontset->mxheight * mxstride;
+ glyph = (FAR uint8_t*)malloc(glyphsize);
/* NOTE: no check for failure to allocate the memory. In a real application
* you would need to handle that event.
@@ -388,7 +390,7 @@ void nxhello_hello(NXWINDOW hwnd)
fwidth = fbm->metric.width + fbm->metric.xoffset;
fheight = fbm->metric.height + fbm->metric.yoffset;
- fstride = (fwidth * CONFIG_EXAMPLES_NXHELLO_BPP + 7) / 8;
+ fstride = (fwidth * CONFIG_EXAMPLES_NXHELLO_BPP + 7) >> 3;
/* Initialize the glyph memory to the background color */
@@ -434,4 +436,8 @@ void nxhello_hello(NXWINDOW hwnd)
pos.x += fontset->spwidth;
}
}
+
+ /* Free the allocated glyph */
+
+ free(glyph);
}