NXWidgets: glyph_minimize42x42.cxx Source File

NXWidgets 1.19

glyph_minimize42x42.cxx
Go to the documentation of this file.
1 /********************************************************************************************
2 * NxWidgets/nxwm/src/glyph_minimize42x42.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 42
61 #define BITMAP_NLUTCODES 7
62
63 #define DARK_MINIMIZE_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_MINIMIZE_ICON
75
76 static const uint32_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
77 {
78 0x6f99b4, 0x001b8a, 0x001ba5, 0x060f4b, 0x00007b, 0xbdbdbd, 0xa5bdbd /* Codes 0-6 */
79 };
80
81 static const uint32_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
82 {
83 0x94ccf0, 0x0024b8, 0x0024dc, 0x081464, 0x0000a4, 0xfcfcfc, 0xdcfcfc /* Codes 0-6 */
84 };
85
86 # else /* DARK_MINIMIZE_ICON */
87
88 static const uint32_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
89 {
90 0x94ccf0, 0x0024b8, 0x0024dc, 0x081464, 0x0000a4, 0xfcfcfc, 0xdcfcfc /* Codes 0-6 */
91 };
92
93 static const uint32_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
94 {
95 0xb9ffff, 0x002de6, 0x002dff, 0x0a197d, 0x0000cd, 0xffffff, 0xffffff /* Codes 0-6 */
96 };
97 # endif /* DARK_MINIMIZE_ICON */
98
99 /* RGB16 (565) Colors */
100
101 #elif CONFIG_NXWIDGETS_BPP == 16
102 # ifdef DARK_MINIMIZE_ICON
103
104 static const uint16_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
105 {
106 0x6cd6, 0x00d1, 0x00d4, 0x0069, 0x000f, 0xbdf7, 0xa5f7 /* Codes 0-6 */
107 };
108
109 static const uint16_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
110 {
111 0x967e, 0x0137, 0x013b, 0x08ac, 0x0014, 0xffff, 0xdfff /* Codes 0-6 */
112 };
113
114 # else /* DARK_MINIMIZE_ICON */
115
116 static const uint16_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
117 {
118 0x967e, 0x0137, 0x013b, 0x08ac, 0x0014, 0xffff, 0xdfff /* Codes 0-6 */
119 };
120
121 static const uint16_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
122 {
123 0xbfff, 0x017c, 0x017f, 0x08cf, 0x0019, 0xffff, 0xffff /* Codes 0-6 */
124 };
125
126 # endif /* DARK_MINIMIZE_ICON */
127
128 /* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
129 * to lookup an 8-bit value. There is no savings in that! It would be better to just put
130 * the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
131 * pointless lookups. But these pointless lookups do make the logic compatible with the
132 * 16- and 24-bit types.
133 */
134
135 #elif CONFIG_NXWIDGETS_BPP == 8
136 # ifdef CONFIG_NXWIDGETS_GREYSCALE
137
138 /* 8-bit Greyscale */
139
140 # ifdef DARK_MINIMIZE_ICON
141
142 static const uint8_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
143 {
144 0x8f, 0x1f, 0x22, 0x13, 0x0e, 0xbd, 0xb5 /* Codes 0-6 */
145 };
146
147 static const uint8_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
148 {
149 0xbf, 0x2a, 0x2e, 0x19, 0x12, 0xfc, 0xf2 /* Codes 0-6 */
150 };
151
152 # else /* DARK_MINIMIZE_ICON */
153
154 static const uint8_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
155 {
156 0xbf, 0x2a, 0x2e, 0x19, 0x12, 0xfc, 0xf2 /* Codes 0-6 */
157 };
158
159 static const uint8_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
160 {
161 0xea, 0x34, 0x37, 0x1f, 0x17, 0xff, 0xff /* Codes 0-6 */
162 };
163
164 # endif /* DARK_MINIMIZE_ICON */
165
166 # else /* CONFIG_NXWIDGETS_GREYSCALE */
167
168 /* RGB8 (332) Colors */
169
170 # ifdef DARK_MINIMIZE_ICON
171
172 static const nxgl_mxpixel_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
173 {
174 0x72, 0x02, 0x02, 0x01, 0x01, 0xb6, 0xb6 /* Codes 0-6 */
175 };
176
177 static const nxgl_mxpixel_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
178 {
179 0x9b, 0x06, 0x07, 0x01, 0x02, 0xff, 0xdf /* Codes 0-6 */
180 };
181
182 # else /* DARK_MINIMIZE_ICON */
183
184 static const nxgl_mxpixel_t g_minimizeNormalLut[BITMAP_NLUTCODES] =
185 {
186 0x9b, 0x06, 0x07, 0x01, 0x02, 0xff, 0xdf /* Codes 0-6 */
187 };
188
189 static const nxgl_mxpixel_t g_minimizeBrightLut[BITMAP_NLUTCODES] =
190 {
191 0xbf, 0x07, 0x07, 0x01, 0x03, 0xff, 0xff /* Codes 0-6 */
192 };
193
194 # endif /* DARK_MINIMIZE_ICON */
195 # endif /* CONFIG_NXWIDGETS_GREYSCALE */
196 #else
197 # error Unsupported pixel format
198 #endif
199
200 static const struct NXWidgets::SRlePaletteBitmapEntry g_minimizeRleEntries[] =
201 {
202 {42, 0}, /* Row 0 */
203 { 1, 0}, {11, 1}, {10, 2}, {19, 1}, { 1, 0}, /* Row 1 */
204 { 1, 0}, { 9, 1}, {14, 2}, {17, 1}, { 1, 3}, /* Row 2 */
205 { 1, 0}, { 7, 1}, {17, 2}, {16, 1}, { 1, 3}, /* Row 3 */
206 { 1, 0}, { 6, 1}, {18, 2}, {16, 1}, { 1, 3}, /* Row 4 */
207 { 1, 0}, { 5, 1}, {19, 2}, {16, 1}, { 1, 3}, /* Row 5 */
208 { 1, 0}, { 4, 1}, {20, 2}, {16, 1}, { 1, 3}, /* Row 6 */
209 { 1, 0}, { 3, 1}, {20, 2}, {17, 1}, { 1, 3}, /* Row 7 */
210 { 1, 0}, { 3, 1}, {20, 2}, {17, 1}, { 1, 3}, /* Row 8 */
211 { 1, 0}, { 2, 1}, {20, 2}, {17, 1}, { 1, 4}, { 1, 3}, /* Row 9 */
212 { 1, 0}, { 2, 1}, {19, 2}, {18, 1}, { 1, 4}, { 1, 3}, /* Row 10 */
213 { 1, 0}, { 1, 1}, {19, 2}, {19, 1}, { 1, 4}, { 1, 3}, /* Row 11 */
214 { 1, 0}, { 1, 1}, {18, 2}, {20, 1}, { 1, 4}, { 1, 3}, /* Row 12 */
215 { 1, 0}, {18, 2}, {20, 1}, { 2, 4}, { 1, 3}, /* Row 13 */
216 { 1, 0}, {17, 2}, {21, 1}, { 2, 4}, { 1, 3}, /* Row 14 */
217 { 1, 0}, {15, 2}, {22, 1}, { 3, 4}, { 1, 3}, /* Row 15 */
218 { 1, 0}, {14, 2}, {23, 1}, { 3, 4}, { 1, 3}, /* Row 16 */
219 { 1, 0}, {12, 2}, {24, 1}, { 4, 4}, { 1, 3}, /* Row 17 */
220 { 1, 0}, {10, 2}, {26, 1}, { 4, 4}, { 1, 3}, /* Row 18 */
221 { 1, 0}, { 1, 1}, { 8, 2}, {26, 1}, { 5, 4}, { 1, 3}, /* Row 19 */
222 { 1, 0}, { 2, 1}, { 5, 2}, {27, 1}, { 6, 4}, { 1, 3}, /* Row 20 */
223 { 1, 0}, { 4, 1}, { 1, 2}, {29, 1}, { 6, 4}, { 1, 3}, /* Row 21 */
224 { 1, 0}, {33, 1}, { 7, 4}, { 1, 3}, /* Row 22 */
225 { 1, 0}, {32, 1}, { 8, 4}, { 1, 3}, /* Row 23 */
226 { 1, 0}, {31, 1}, { 9, 4}, { 1, 3}, /* Row 24 */
227 { 1, 0}, {30, 1}, {10, 4}, { 1, 3}, /* Row 25 */
228 { 1, 0}, {29, 1}, {11, 4}, { 1, 3}, /* Row 26 */
229 { 1, 0}, {28, 1}, {12, 4}, { 1, 3}, /* Row 27 */
230 { 1, 0}, {27, 1}, {13, 4}, { 1, 3}, /* Row 28 */
231 { 1, 0}, {26, 1}, {14, 4}, { 1, 3}, /* Row 29 */
232 { 1, 0}, {24, 1}, {16, 4}, { 1, 3}, /* Row 30 */
233 { 1, 0}, {22, 1}, {18, 4}, { 1, 3}, /* Row 31 */
234 { 1, 0}, { 6, 1}, {28, 5}, { 6, 4}, { 1, 3}, /* Row 32 */
235 { 1, 0}, { 5, 1}, {29, 5}, { 1, 6}, { 5, 4}, { 1, 3}, /* Row 33 */
236 { 1, 0}, { 5, 1}, {29, 5}, { 1, 6}, { 5, 4}, { 1, 3}, /* Row 34 */
237 { 1, 0}, { 5, 1}, {29, 5}, { 1, 6}, { 5, 4}, { 1, 3}, /* Row 35 */
238 { 1, 0}, { 5, 1}, {29, 5}, { 1, 6}, { 5, 4}, { 1, 3}, /* Row 36 */
239 { 1, 0}, { 6, 1}, {28, 6}, { 6, 4}, { 1, 3}, /* Row 37 */
240 { 1, 0}, { 4, 1}, {36, 4}, { 1, 3}, /* Row 38 */
241 { 1, 0}, { 2, 1}, {38, 4}, { 1, 3}, /* Row 39 */
242 { 1, 0}, {40, 4}, { 1, 3}, /* Row 40 */
243 { 2, 0}, {40, 3} /* Row 41 */
244 };
245
246 /********************************************************************************************
247 * Public Bitmap Structure Definitions
248 ********************************************************************************************/
249
250 const struct NXWidgets::SRlePaletteBitmap NxWM::g_minimizeBitmap =
251 {
252 CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
253 CONFIG_NXWIDGETS_FMT, // fmt - Color format
254 BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
255 BITMAP_NCOLUMNS, // width - Width in pixels
256 BITMAP_NROWS, // height - Height in rows
257 { // lut - Pointer to the beginning of the Look-Up Table (LUT)
258 g_minimizeNormalLut, // Index 0: Unselected LUT
259 g_minimizeBrightLut, // Index 1: Selected LUT
260 },
261 g_minimizeRleEntries // data - Pointer to the beginning of the RLE data
262 };
crlepalettebitmap.hxx
NXWidgets::SRlePaletteBitmapEntry
Definition: crlepalettebitmap.hxx:70
g_minimizeNormalLut
static const uint32_t g_minimizeNormalLut[BITMAP_NLUTCODES]
Definition: glyph_minimize42x42.cxx:76
NxWM::BITMAP_NLUTCODES
BITMAP_NLUTCODES
Definition: glyph_calculator24x25.cxx:181
nxwmconfig.hxx
NxWM::g_minimizeBitmap
const struct NXWidgets::SRlePaletteBitmap g_minimizeBitmap
Definition: nxwmglyphs.hxx:71
nxwmglyphs.hxx
NxWM
Definition: capplicationwindow.hxx:66
NxWM::CONFIG_NXWIDGETS_BPP
CONFIG_NXWIDGETS_BPP
Definition: glyph_calculator24x25.cxx:181
NxWM::BITMAP_NCOLUMNS
BITMAP_NCOLUMNS
Definition: glyph_calculator24x25.cxx:181
g_minimizeRleEntries
static const struct NXWidgets::SRlePaletteBitmapEntry g_minimizeRleEntries[]
Definition: glyph_minimize42x42.cxx:200
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
g_minimizeBrightLut
static const uint32_t g_minimizeBrightLut[BITMAP_NLUTCODES]
Definition: glyph_minimize42x42.cxx:81