NXWidgets: glyph_calculator24x25.cxx Source File

NXWidgets 1.19

glyph_calculator24x25.cxx
Go to the documentation of this file.
1 /********************************************************************************************
2 * NxWidgets/nxwm/src/glyph_calculator24x25.cxx
3 *
4 * Copyright (C) 2012 Gregory Nutt. All rights reserved.
5 * Author: Gregory Nutt <gnutt@nuttx.org>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
18 * me be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ********************************************************************************************/
35
36 /********************************************************************************************
37 * Included Files
38 ********************************************************************************************/
39
40 #include <nuttx/config.h>
41
42 #include <sys/types.h>
43 #include <stdint.h>
44 #include <stdbool.h>
45
46 #include <nuttx/nx/nxglib.h>
47 #include <nuttx/video/fb.h>
48 #include <nuttx/video/rgbcolors.h>
49
50 #include "crlepalettebitmap.hxx"
51
52 #include "nxwmconfig.hxx"
53 #include "nxwmglyphs.hxx"
54
55 /********************************************************************************************
56 * Pre-Processor Definitions
57 ********************************************************************************************/
58
59 #define BITMAP_NROWS 25
60 #define BITMAP_NCOLUMNS 24
61 #define BITMAP_NLUTCODES 8
62
63 /********************************************************************************************
64 * Private Bitmap Data
65 ********************************************************************************************/
66
67 using namespace NxWM;
68
69 /* RGB24 (8-8-8) Colors */
70
71 #if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
72
73 static const uint32_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
74 {
75 0xfcfcfc, 0xb8bcbc, 0xf8f8f8, 0x6890c8, 0x384c80, 0xe8e8e8, 0x646464, 0x909090 /* Codes 0-7 */
76 };
77
78 static const uint32_t g_calculatorBrightLut[BITMAP_NLUTCODES] =
79 {
80 0xffffff, 0xc9cccc, 0xf9f9f9, 0x8dabd5, 0x69789f, 0xededed, 0x8a8a8a, 0xababab /* Codes 0-7 */
81 };
82
83 /* RGB16 (565) Colors (four of the colors in this map are duplicates) */
84
85 #elif CONFIG_NXWIDGETS_BPP == 16
86
87 static const uint16_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
88 {
89 0xffff, 0xbdf7, 0xffdf, 0x6c99, 0x3a70, 0xef5d, 0x632c, 0x9492 /* Codes 0-7 */
90 };
91
92 static const uint16_t g_calculatorBrightLut[BITMAP_NLUTCODES] =
93 {
94 0xffff, 0xce79, 0xffdf, 0x8d5a, 0x6bd3, 0xef7d, 0x8c51, 0xad55 /* Codes 0-7 */
95 };
96
97 /* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
98 * to lookup an 8-bit value. There is no savings in that! It would be better to just put
99 * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
100 * pointless lookups. But these p;ointless lookups do make the logic compatible with the
101 * 16- and 24-bit types.
102 */
103
104 #elif CONFIG_NXWIDGETS_BPP == 8
105 # ifdef CONFIG_NXWIDGETS_GREYSCALE
106
107 static const uint8_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
108 {
109 0xfc, 0xba, 0xf8, 0x8a, 0x4b, 0xe8, 0x64, 0x90 /* Codes 0-7 */
110 };
111
112 static const uint8_t g_calculatorBrightLut[BITMAP_NLUTCODES] =
113 {
114 0xff, 0xcb, 0xf9, 0xa6, 0x77, 0xed, 0x8a, 0xab /* Codes 0-7 */
115 };
116
117 # else /* CONFIG_NXWIDGETS_GREYSCALE */
118
119 static const nxgl_mxpixel_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
120 {
121 0xff, 0xb7, 0xff, 0x73, 0x2a, 0xff, 0x6d, 0x92 /* Codes 0-7 */
122 };
123
124 static const nxgl_mxpixel_t g_calculatorBrightLut[BITMAP_NLUTCODES] =
125 {
126 0xff, 0xdb, 0xff, 0x97, 0x6e, 0xff, 0x92, 0xb6 /* Codes 0-7 */
127 };
128
129 # endif /* CONFIG_NXWIDGETS_GREYSCALE */
130 #else
131 # error "Unsupport pixel format"
132 #endif
133
134 static const struct NXWidgets::SRlePaletteBitmapEntry g_calculatorRleEntries[] =
135 {
136 { 23, 0}, { 1, 1}, /* Row 0 */
137 { 1, 0}, { 21, 1}, { 1, 2}, { 1, 1}, /* Row 1 */
138 { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 2 */
139 { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 3 */
140 { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 4 */
141 { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 5 */
142 { 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 6 */
143 { 1, 2}, { 1, 1}, { 20, 4}, { 1, 0}, { 1, 1}, /* Row 7 */
144 { 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 8 */
145 { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
146 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 9 */
147 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
148 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 10 */
149 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
150 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 11 */
151 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
152 { 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 12 */
153 { 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 13 */
154 { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
155 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 14 */
156 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
157 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 15 */
158 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
159 { 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 16 */
160 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
161 { 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 17 */
162 { 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 18 */
163 { 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
164 { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 19 */
165 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
166 { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 20 */
167 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
168 { 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 21 */
169 { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
170 { 1, 2}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 22 */
171 { 23, 0}, { 1, 1}, /* Row 23 */
172 { 24, 1} /* Row 24 */
173 };
174
175 /********************************************************************************************
176 * Public Bitmap Structure Definitions
177 ********************************************************************************************/
178
179 const struct NXWidgets::SRlePaletteBitmap NxWM::g_calculatorBitmap =
180 {
181 CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
182 CONFIG_NXWIDGETS_FMT, // fmt - Color format
183 BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
184 BITMAP_NCOLUMNS, // width - Width in pixels
185 BITMAP_NROWS, // height - Height in rows
186 { // lut - Pointer to the beginning of the Look-Up Table (LUT)
187 g_calculatorNormalLut, // Index 0: Unselected LUT
188 g_calculatorBrightLut, // Index 1: Selected LUT
189 },
190 g_calculatorRleEntries // data - Pointer to the beginning of the RLE data
191 };
crlepalettebitmap.hxx
NXWidgets::SRlePaletteBitmapEntry
Definition: crlepalettebitmap.hxx:70
g_calculatorRleEntries
static const struct NXWidgets::SRlePaletteBitmapEntry g_calculatorRleEntries[]
Definition: glyph_calculator24x25.cxx:134
NxWM::BITMAP_NLUTCODES
BITMAP_NLUTCODES
Definition: glyph_calculator24x25.cxx:181
nxwmconfig.hxx
NxWM::g_calculatorBitmap
const struct NXWidgets::SRlePaletteBitmap g_calculatorBitmap
Definition: nxwmglyphs.hxx:60
nxwmglyphs.hxx
NxWM
Definition: capplicationwindow.hxx:66
g_calculatorNormalLut
static const uint32_t g_calculatorNormalLut[BITMAP_NLUTCODES]
Definition: glyph_calculator24x25.cxx:73
NxWM::CONFIG_NXWIDGETS_BPP
CONFIG_NXWIDGETS_BPP
Definition: glyph_calculator24x25.cxx:181
NxWM::BITMAP_NCOLUMNS
BITMAP_NCOLUMNS
Definition: glyph_calculator24x25.cxx:181
g_calculatorBrightLut
static const uint32_t g_calculatorBrightLut[BITMAP_NLUTCODES]
Definition: glyph_calculator24x25.cxx:78
NXWidgets::SRlePaletteBitmap
Definition: crlepalettebitmap.hxx:80
NxWM::CONFIG_NXWIDGETS_FMT
CONFIG_NXWIDGETS_FMT
Definition: glyph_calculator24x25.cxx:181
NxWM::BITMAP_NROWS
BITMAP_NROWS
Definition: glyph_calculator24x25.cxx:181