diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-05-15 12:40:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-05-15 12:40:59 +0000 |
commit | a778f0c7e076b4bab911945ee2630d767448d147 (patch) | |
tree | 09b07d102f0fc5d4d08f5233f0a17e47f44f5150 /nuttx/examples/nx/nx_kbdin.c | |
parent | c1a162433f5694f2ff3bea4258bdbd3141712ba1 (diff) | |
download | px4-nuttx-a778f0c7e076b4bab911945ee2630d767448d147.tar.gz px4-nuttx-a778f0c7e076b4bab911945ee2630d767448d147.tar.bz2 px4-nuttx-a778f0c7e076b4bab911945ee2630d767448d147.zip |
NX for 4bpp
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2671 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nx/nx_kbdin.c')
-rw-r--r-- | nuttx/examples/nx/nx_kbdin.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/nuttx/examples/nx/nx_kbdin.c b/nuttx/examples/nx/nx_kbdin.c index 3088885ba..057f725d2 100644 --- a/nuttx/examples/nx/nx_kbdin.c +++ b/nuttx/examples/nx/nx_kbdin.c @@ -154,6 +154,9 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, { FAR struct nxeg_glyph_s *glyph = NULL; FAR nxgl_mxpixel_t *ptr; +#if CONFIG_EXAMPLES_NX_BPP < 8 + nxgl_mxpixel_t pixel; +#endif int bmsize; int row; int col; @@ -184,18 +187,54 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, { /* Initialize the glyph memory to the background color */ -#if CONFIG_EXAMPLES_NX_BPP < 8 || CONFIG_EXAMPLES_NX_BPP == 24 -# error "Additional logic is needed here" -#else +#if CONFIG_EXAMPLES_NX_BPP < 8 + pixel = st->color[0]; +# if CONFIG_EXAMPLES_NX_BPP == 1 + /* Pack 1-bit pixels into a 2-bits */ + + pixel &= 0x01; + pixel = (pixel) << 1 |pixel; +# endif +# if CONFIG_EXAMPLES_NX_BPP < 4 + /* Pack 2-bit pixels into a nibble */ + + pixel &= 0x03; + pixel = (pixel) << 2 |pixel; +# endif + + /* Pack 4-bit nibbles into a byte */ + + pixel &= 0x0f; + pixel = (pixel) << 4 |pixel; + + ptr = (FAR nxgl_mxpixel_t *)glyph->bitmap; + for (row = 0; row < glyph->height; row++) + { + for (col = 0; col < glyph->stride; col++) + { + /* Transfer the packed bytes into the buffer */ + + *ptr++ = pixel; + } + } + +#elif CONFIG_EXAMPLES_NX_BPP == 24 +# error "Additional logic is needed here for 24bpp support" + +#else /* CONFIG_EXAMPLES_NX_BPP = {8,16,32} */ + ptr = (FAR nxgl_mxpixel_t *)glyph->bitmap; for (row = 0; row < glyph->height; row++) { + /* Just copy the color value into the glyph memory */ + for (col = 0; col < glyph->width; col++) { *ptr++ = st->color[0]; } } #endif + /* Then render the glyph into the allocated memory */ ret = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap, |