NXWidgets  1.19
glyph_calibration48x42.cxx
Go to the documentation of this file.
1 /********************************************************************************************
2  * NxWidgets/nxwm/src/glyph_calibration48x42.cxx
3  *
4  * Copyright (C) 2014 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 42
60 #define BITMAP_NCOLUMNS 48
61 #define BITMAP_NLUTCODES 7
62 
63 #define DARK_CALIB_ICON 1
64 
65 /********************************************************************************************
66  * Private Bitmap Data
67  ********************************************************************************************/
68 
69 using namespace NxWM;
70 
71 /* RGB24 (8-8-8) Colors */
72 
73 #if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
74 # ifdef DARK_CALIB_ICON
75 
76 static const uint32_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
77 {
78  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
79  0xbdbdbd, 0xababab, 0x818181, 0x3f3f3f, 0xab6c15, 0x813f15 /* Codes 1-6 */
80 };
81 
82 static const uint32_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
83 {
84  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
85  0xfcfcfc, 0xe4e4e4, 0xacacac, 0x545454, 0xe4901c, 0xac541c /* Codes 1-6 */
86 };
87 
88 # else /* DARK_CALIB_ICON */
89 
90 static const uint32_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
91 {
92  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
93  0xfcfcfc, 0xe4e4e4, 0xacacac, 0x545454, 0xe4901c, 0xac541c /* Codes 1-6 */
94 };
95 
96 static const uint32_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
97 {
98  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
99  0xffffff, 0xffffff, 0xd7d7d7, 0x696969, 0xffb423, 0xd76923 /* Codes 1-6 */
100 };
101 # endif /* DARK_CALIB_ICON */
102 
103 /* RGB16 (565) Colors */
104 
105 #elif CONFIG_NXWIDGETS_BPP == 16
106 # ifdef DARK_CALIB_ICON
107 
108 static const uint16_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
109 {
110  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
111  0xbdf7, 0xad55, 0x8410, 0x39e7, 0xab62, 0x81e2 /* Codes 1-6 */
112 };
113 
114 static const uint16_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
115 {
116  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
117  0xffff, 0xe73c, 0xad75, 0x52aa, 0xe483, 0xaaa3 /* Codes 1-6 */
118 };
119 
120 # else /* DARK_CALIB_ICON */
121 
122 static const uint16_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
123 {
124  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
125  0xffff, 0xe73c, 0xad75, 0x52aa, 0xe483, 0xaaa3 /* Codes 1-6 */
126 };
127 
128 static const uint16_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
129 {
130  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
131  0xffff, 0xffff, 0xd6ba, 0x6b4d, 0xfda4, 0xd344 /* Codes 1-6 */
132 };
133 
134 # endif /* DARK_CALIB_ICON */
135 
136 /* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
137  * to lookup an 8-bit value. There is no savings in that! It would be better to just put
138  * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
139  * pointless lookups. But these pointless lookups do make the logic compatible with the
140  * 16- and 24-bit types.
141  */
142 
143 #elif CONFIG_NXWIDGETS_BPP == 8
144 # ifdef CONFIG_NXWIDGETS_GREYSCALE
145 
146 /* 8-bit Greyscale */
147 
148 # ifdef DARK_CALIB_ICON
149 
150 static const uint8_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
151 {
152  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
153  0xbd, 0xab, 0x81, 0x3f, 0x74, 0x4d /* Codes 1-6 */
154 };
155 
156 static const uint8_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
157 {
158  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
159  0xfc, 0xe4, 0xac, 0x54, 0x9b, 0x67 /* Codes 1-6 */
160 };
161 
162 # else /* DARK_CALIB_ICON */
163 
164 static const uint8_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
165 {
166  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
167  0xfc, 0xe4, 0xac, 0x54, 0x9b, 0x67 /* Codes 1-6 */
168 };
169 
170 static const uint8_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
171 {
172  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
173  0xff, 0xff, 0xd7, 0x69, 0xb9, 0x81 /* Codes 1-6 */
174 };
175 
176 # endif /* DARK_CALIB_ICON */
177 
178 # else /* CONFIG_NXWIDGETS_GREYSCALE */
179 
180 /* RGB8 (332) Colors */
181 
182 # ifdef DARK_CALIB_ICON
183 
184 static const nxgl_mxpixel_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
185 {
186  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
187  0xb6, 0xb6, 0x92, 0x24, 0xac, 0x84 /* Codes 1-6 */
188 };
189 
190 static const nxgl_mxpixel_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
191 {
192  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
193  0xff, 0xff, 0xb6, 0x49, 0xf0, 0xa8 /* Codes 1-6 */
194 };
195 
196 # else /* DARK_CALIB_ICON */
197 
198 static const nxgl_mxpixel_t g_calibrationNormalLut[BITMAP_NLUTCODES] =
199 {
200  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
201  0xff, 0xff, 0xb6, 0x49, 0xf0, 0xa8 /* Codes 1-6 */
202 };
203 
204 static const nxgl_mxpixel_t g_calibrationBrightLut[BITMAP_NLUTCODES] =
205 {
206  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
207  0xff, 0xff, 0xdb, 0x6d, 0xf4, 0xcc /* Codes 1-6 */
208 };
209 
210 # endif /* DARK_CALIB_ICON */
211 # endif /* CONFIG_NXWIDGETS_GREYSCALE */
212 #else
213 # error Unsupported pixel format
214 #endif
215 
217 {
218  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {12, 0}, { 2, 1}, { 8, 0}, /* Row 0 */
219  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {11, 0}, { 1, 2}, { 2, 1}, { 1, 3}, /* Row 1 */
220  { 2, 0}, { 1, 2}, { 4, 0},
221  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {10, 0}, { 2, 1}, { 2, 4}, { 4, 1}, /* Row 2 */
222  { 4, 0},
223  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 8, 0}, { 1, 2}, { 2, 1}, { 1, 3}, /* Row 3 */
224  { 2, 4}, { 1, 1}, { 3, 3}, { 4, 0},
225  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 6, 0}, { 1, 2}, { 1, 1}, { 2, 3}, /* Row 4 */
226  { 2, 4}, { 2, 2}, { 1, 3}, { 7, 0},
227  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 4, 0}, { 1, 2}, { 2, 1}, { 1, 3}, /* Row 5 */
228  { 4, 0}, { 2, 2}, { 8, 0},
229  {22, 0}, { 2, 1}, { 2, 2}, { 2, 0}, { 1, 2}, { 1, 1}, { 2, 3}, { 1, 4}, /* Row 6 */
230  { 5, 0}, { 1, 1}, { 1, 2}, { 8, 0},
231  {22, 0}, { 2, 1}, { 2, 2}, { 3, 1}, { 1, 3}, { 1, 4}, { 7, 0}, { 1, 1}, /* Row 7 */
232  { 1, 2}, { 8, 0},
233  {20, 0}, { 1, 2}, { 1, 1}, { 4, 2}, { 2, 3}, { 1, 4}, { 9, 0}, { 1, 1}, /* Row 8 */
234  { 1, 2}, { 8, 0},
235  {18, 0}, { 1, 2}, { 3, 1}, { 4, 2}, {12, 0}, { 1, 1}, { 1, 2}, { 8, 0}, /* Row 9 */
236  { 8, 0}, { 1, 1}, { 1, 3}, { 6, 0}, { 2, 1}, { 2, 3}, { 1, 4}, { 1, 0}, /* Row 10 */
237  { 2, 1}, { 1, 2}, { 1, 3}, {11, 0}, { 1, 1}, { 2, 2}, { 1, 4}, { 7, 0},
238  { 4, 0}, { 1, 2}, { 2, 0}, { 2, 1}, { 2, 3}, { 3, 0}, { 1, 2}, { 2, 1}, /* Row 11 */
239  { 1, 3}, { 1, 4}, { 3, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {10, 0}, { 2, 1},
240  { 3, 2}, { 1, 4}, { 6, 0},
241  { 4, 0}, { 4, 1}, { 2, 4}, { 1, 3}, { 3, 1}, { 2, 3}, { 1, 4}, { 5, 0}, /* Row 12 */
242  { 1, 1}, { 2, 2}, { 1, 3}, { 9, 0}, { 1, 1}, { 2, 2}, { 2, 0}, { 2, 2},
243  { 1, 4}, { 5, 0},
244  { 4, 0}, { 3, 3}, { 1, 1}, { 2, 4}, { 2, 1}, { 1, 3}, { 1, 4}, { 8, 0}, /* Row 13 */
245  { 1, 1}, { 2, 2}, { 1, 3}, { 8, 0}, { 1, 2}, { 1, 1}, { 1, 2}, { 4, 0},
246  { 2, 2}, { 1, 4}, { 4, 0},
247  { 7, 0}, { 1, 3}, { 2, 2}, { 1, 3}, {11, 0}, { 1, 1}, { 2, 2}, { 1, 3}, /* Row 14 */
248  { 8, 0}, { 1, 1}, { 1, 2}, { 6, 0}, { 2, 2}, { 4, 0},
249  { 8, 0}, { 2, 2}, {12, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 7, 0}, { 1, 2}, /* Row 15 */
250  { 1, 1}, { 8, 0}, { 1, 2}, { 1, 4}, { 3, 0},
251  { 8, 0}, { 1, 1}, { 1, 2}, {12, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 7, 0}, /* Row 16 */
252  { 1, 1}, { 1, 2}, { 8, 0}, { 2, 2}, { 3, 0},
253  { 8, 0}, { 1, 1}, { 1, 2}, {12, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 6, 0}, /* Row 17 */
254  { 1, 2}, { 1, 1}, { 1, 2}, { 8, 0}, { 1, 1}, { 1, 2}, { 1, 4}, { 2, 0},
255  { 7, 0}, { 1, 1}, { 2, 2}, { 1, 4}, {11, 0}, { 1, 1}, { 2, 2}, { 1, 3}, /* Row 18 */
256  { 6, 0}, { 2, 1}, {10, 0}, { 1, 1}, { 1, 2}, { 2, 0},
257  { 6, 0}, { 2, 1}, { 3, 2}, { 1, 4}, {10, 0}, { 1, 1}, { 2, 2}, { 1, 3}, /* Row 19 */
258  { 6, 0}, { 1, 1}, { 1, 2}, {10, 0}, { 1, 1}, { 1, 2}, { 2, 0},
259  { 5, 0}, { 1, 1}, { 2, 2}, { 2, 0}, { 2, 2}, { 1, 4}, { 9, 0}, { 1, 1}, /* Row 20 */
260  { 2, 2}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6},
261  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0},
262  { 4, 0}, { 1, 2}, { 1, 1}, { 1, 2}, { 4, 0}, { 2, 2}, { 1, 4}, { 8, 0}, /* Row 21 */
263  { 1, 1}, { 2, 2}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5},
264  { 2, 6}, { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0},
265  { 4, 0}, { 1, 1}, { 1, 2}, { 6, 0}, { 2, 2}, { 8, 0}, { 1, 1}, { 2, 2}, /* Row 22 */
266  { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0},
267  { 1, 1}, { 1, 2}, { 2, 0},
268  { 3, 0}, { 1, 2}, { 1, 1}, { 8, 0}, { 1, 2}, { 1, 4}, { 7, 0}, { 1, 1}, /* Row 23 */
269  { 2, 2}, { 1, 3}, { 6, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6},
270  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0},
271  { 3, 0}, { 1, 1}, { 1, 2}, { 8, 0}, { 2, 2}, { 7, 0}, { 1, 1}, { 2, 2}, /* Row 24 */
272  { 1, 3}, { 4, 0}, { 4, 1}, {10, 2}, { 4, 3},
273  { 2, 0}, { 1, 2}, { 1, 1}, { 1, 2}, { 1, 0}, { 4, 5}, { 2, 6}, { 1, 0}, /* Row 25 */
274  { 1, 1}, { 1, 2}, { 1, 4}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, { 4, 0},
275  { 4, 1}, {10, 2}, { 4, 3},
276  { 2, 0}, { 2, 1}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, { 1, 2}, /* Row 26 */
277  { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
278  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, /* Row 27 */
279  { 1, 2}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
280  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, /* Row 28 */
281  { 1, 2}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
282  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, /* Row 29 */
283  { 1, 2}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
284  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, /* Row 30 */
285  { 1, 2}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
286  { 2, 0}, { 1, 1}, { 1, 2}, { 2, 0}, { 4, 5}, { 2, 6}, { 2, 0}, { 1, 1}, /* Row 31 */
287  { 1, 2}, { 6, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0},
288  { 4, 1}, {10, 2}, { 4, 3}, { 4, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0}, /* Row 32 */
289  { 4, 1}, {10, 2}, { 4, 3}, { 4, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0}, /* Row 33 */
290  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0}, /* Row 34 */
291  {22, 0}, { 1, 1}, { 2, 2}, { 1, 3}, {22, 0}, /* Row 35 */
292  {20, 0}, { 1, 2}, { 1, 1}, { 4, 2}, { 1, 3}, { 1, 4}, {20, 0}, /* Row 36 */
293  {20, 0}, { 1, 2}, { 1, 1}, { 4, 2}, { 1, 3}, { 1, 4}, {20, 0}, /* Row 37 */
294  {10, 0}, { 1, 2}, { 7, 1}, {12, 2}, { 7, 3}, { 1, 4}, {10, 0}, /* Row 38 */
295  {10, 0}, { 1, 2}, { 7, 1}, {12, 2}, { 7, 3}, { 1, 4}, {10, 0}, /* Row 39 */
296  { 8, 0}, { 1, 2}, { 7, 1}, {16, 2}, { 7, 3}, { 1, 4}, { 8, 0}, /* Row 40 */
297  { 8, 0}, { 1, 2}, { 7, 1}, {16, 2}, { 7, 3}, { 1, 4}, { 8, 0} /* Row 41 */
298 };
299 
300 /********************************************************************************************
301  * Public Bitmap Structure Definitions
302  ********************************************************************************************/
303 
305 {
306  CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
307  CONFIG_NXWIDGETS_FMT, // fmt - Color format
308  BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
309  BITMAP_NCOLUMNS, // width - Width in pixels
310  BITMAP_NROWS, // height - Height in rows
311  { // lut - Pointer to the beginning of the Look-Up Table (LUT)
312  g_calibrationNormalLut, // Index 0: Unselected LUT
313  g_calibrationBrightLut, // Index 1: Selected LUT
314  },
315  g_calibrationRleEntries // data - Pointer to the beginning of the RLE data
316 };
static const uint32_t g_calibrationNormalLut[BITMAP_NLUTCODES]
const struct NXWidgets::SRlePaletteBitmap g_calibrationBitmap
Definition: nxwmglyphs.hxx:61
static const uint32_t g_calibrationBrightLut[BITMAP_NLUTCODES]
static const struct NXWidgets::SRlePaletteBitmapEntry g_calibrationRleEntries[]