NXWidgets  1.19
glyph_play24x24.cxx
Go to the documentation of this file.
1 /********************************************************************************************
2  * NxWidgets/nxwm/src/glyph_play24x24.cxx
3  *
4  * Copyright (C) 2012-2013 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 24
60 #define BITMAP_NCOLUMNS 24
61 #define BITMAP_NLUTCODES 5
62 
63 #define DARK_PLAY_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_PLAY_ICON
75 
76 static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
77 {
78  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
79  0x00bd00, 0x008100, 0x006300, 0x003600 /* Codes 1-4 */
80 };
81 
82 static const uint32_t g_playBrightLut[BITMAP_NLUTCODES] =
83 {
84  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
85  0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
86 };
87 
88 # else /* DARK_PLAY_ICON */
89 
90 static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
91 {
92  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
93  0x00fc00, 0x00ac00, 0x008400, 0x004800 /* Codes 1-4 */
94 };
95 
96 static const uint32_t g_playBrightLut[BITMAP_NLUTCODES] =
97 {
98  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
99  0x00fc00, 0x00c000, 0x00a200, 0x007500 /* Codes 1-4 */
100 };
101 # endif /* DARK_PLAY_ICON */
102 
103 /* RGB16 (565) Colors (four of the colors in this map are duplicates) */
104 
105 #elif CONFIG_NXWIDGETS_BPP == 16
106 # ifdef DARK_PLAY_ICON
107 
108 static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
109 {
110  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
111  0x05e0, 0x0400, 0x0300, 0x01a0 /* Codes 1-4 */
112 };
113 
114 static const uint16_t g_playBrightLut[BITMAP_NLUTCODES] =
115 {
116  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
117  0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
118 };
119 
120 # else /* DARK_PLAY_ICON */
121 
122 static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
123 {
124  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
125  0x07e0, 0x0560, 0x0420, 0x0240 /* Codes 1-4 */
126 };
127 
128 static const uint16_t g_playBrightLut[BITMAP_NLUTCODES] =
129 {
130  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
131  0x07e0, 0x0600, 0x0500, 0x03a0 /* Codes 1-4 */
132 };
133 
134 # endif /* DARK_PLAY_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 p;ointless 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_PLAY_ICON
149 
150 static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
151 {
152  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
153  0x6e, 0x4b, 0x3a, 0x1f /* Codes 1-4 */
154 };
155 
156 static const uint8_t g_playBrightLut[BITMAP_NLUTCODES] =
157 {
158  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
159  0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
160 };
161 
162 # else /* DARK_PLAY_ICON */
163 
164 static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
165 {
166  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
167  0x93, 0x64, 0x4d, 0x2a /* Codes 1-4 */
168 };
169 
170 static const uint8_t g_playBrightLut[BITMAP_NLUTCODES] =
171 {
172  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
173  0x93, 0x70, 0x5f, 0x44 /* Codes 1-4 */
174 };
175 
176 # endif /* DARK_PLAY_ICON */
177 # else /* CONFIG_NXWIDGETS_GREYSCALE */
178 
179 /* RGB8 (332) Colors */
180 
181 # ifdef DARK_PLAY_ICON
182 static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
183 {
184  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
185  0x14, 0x10, 0x0c, 0x04 /* Codes 1-4 */
186 };
187 
188 static const nxgl_mxpixel_t g_playBrightLut[BITMAP_NLUTCODES] =
189 {
190  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
191  0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
192 };
193 
194 # else /* DARK_PLAY_ICON */
195 
196 static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
197 {
198  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
199  0x1c, 0x14, 0x10, 0x08 /* Codes 1-4 */
200 };
201 
202 static const nxgl_mxpixel_t g_playBrightLut[BITMAP_NLUTCODES] =
203 {
204  CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
205  0x1c, 0x18, 0x14, 0x0c /* Codes 1-4 */
206 };
207 
208 # endif /* DARK_PLAY_ICON */
209 # endif /* CONFIG_NXWIDGETS_GREYSCALE */
210 #else
211 # error "Unsupport pixel format"
212 #endif
213 
215 {
216  { 2, 1}, { 22, 0}, /* Row 0 */
217  { 2, 2}, { 2, 1}, { 20, 0}, /* Row 1 */
218  { 4, 2}, { 2, 1}, { 18, 0}, /* Row 2 */
219  { 6, 2}, { 2, 1}, { 16, 0}, /* Row 3 */
220  { 8, 2}, { 2, 1}, { 14, 0}, /* Row 4 */
221  { 10, 2}, { 2, 1}, { 12, 0}, /* Row 5 */
222  { 12, 2}, { 2, 1}, { 10, 0}, /* Row 6 */
223  { 14, 2}, { 2, 1}, { 8, 0}, /* Row 7 */
224  { 16, 2}, { 2, 1}, { 6, 0}, /* Row 8 */
225  { 18, 2}, { 2, 1}, { 4, 0}, /* Row 9 */
226  { 20, 2}, { 2, 1}, { 2, 0}, /* Row 10 */
227  { 22, 2}, { 2, 1}, /* Row 11 */
228  { 22, 3}, { 2, 4}, /* Row 12 */
229  { 20, 3}, { 2, 4}, { 2, 0}, /* Row 13 */
230  { 18, 3}, { 2, 4}, { 4, 0}, /* Row 14 */
231  { 16, 3}, { 2, 4}, { 6, 0}, /* Row 15 */
232  { 14, 3}, { 2, 4}, { 8, 0}, /* Row 16 */
233  { 12, 3}, { 2, 4}, { 10, 0}, /* Row 17 */
234  { 10, 3}, { 2, 4}, { 12, 0}, /* Row 18 */
235  { 8, 3}, { 2, 4}, { 14, 0}, /* Row 19 */
236  { 6, 3}, { 2, 4}, { 16, 0}, /* Row 20 */
237  { 4, 3}, { 2, 4}, { 18, 0}, /* Row 21 */
238  { 2, 3}, { 2, 4}, { 20, 0}, /* Row 22 */
239  { 2, 4}, { 22, 0}, /* Row 23 */
240 };
241 
242 /********************************************************************************************
243  * Public Bitmap Structure Definitions
244  ********************************************************************************************/
245 
246 const struct NXWidgets::SRlePaletteBitmap NxWM::g_playBitmap =
247 {
248  CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
249  CONFIG_NXWIDGETS_FMT, // fmt - Color format
250  BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
251  BITMAP_NCOLUMNS, // width - Width in pixels
252  BITMAP_NROWS, // height - Height in rows
253  { // lut - Pointer to the beginning of the Look-Up Table (LUT)
254  g_playNormalLut, // Index 0: Unselected LUT
255  g_playBrightLut, // Index 1: Selected LUT
256  },
257  g_playRleEntries // data - Pointer to the beginning of the RLE data
258 };
static const struct NXWidgets::SRlePaletteBitmapEntry g_playRleEntries[]
static const uint32_t g_playBrightLut[BITMAP_NLUTCODES]
const struct NXWidgets::SRlePaletteBitmap g_playBitmap
Definition: nxwmglyphs.hxx:72
static const uint32_t g_playNormalLut[BITMAP_NLUTCODES]