WebRadioApp  0.1
ewextpxl_RGB565.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * E M B E D D E D W I Z A R D P R O J E C T
4  *
5  * Copyright (c) TARA Systems
6  *GmbH written by Paul Banach and Manfred Schweyer
7  *
8  ********************************************************************************
9  *
10  * This software and related documentation ("Software") are intellectual
11  * property owned by TARA Systems and are copyright of TARA Systems.
12  * Any modification, copying, reproduction or redistribution of the Software in
13  * whole or in part by any means not in accordance with the End-User License
14  * Agreement for Embedded Wizard is expressly prohibited. The removal of this
15  * preamble is expressly prohibited.
16  *
17  ********************************************************************************
18  *
19  * DESCRIPTION:
20  * This header belongs to the low level software driver for target platforms
21  * based on the RGB565 screen and RGBA8888 native pixel format whereby the
22  * screen pixel format does correspond exclusively to the format of the frame
23  * buffer.
24  *
25  * This implementation includes following special options:
26  *
27  * > Pre-multiplied or non pre-multiplied pixel RGB color channels. Depending
28  * on the graphics hardware, it may be expected that RGB color channels are
29  * stored and calculated as already alpha pre-multiplied values.
30  *
31  * This option is controlled by the definition
32  *EW_PREMULTIPLY_COLOR_CHANNELS. If this macro is defined, the pixel driver
33  *handles the RGB color channels as already pre-multiplied by the corresponding
34  *pixel alpha value.
35  *
36  * To select the pre-multiplied color format take following line into your
37  * 'ewextgfx.h' file:
38  *
39  * #define EW_PREMULTIPLY_COLOR_CHANNELS 1
40  *
41  * If your graphics hardware doesn't work with pre-multiplied color channels
42  * set the following line into your 'ewextgfx.h' file:
43  *
44  * #define EW_PREMULTIPLY_COLOR_CHANNELS 0
45  *
46  * Please note, this option affects the native pixel format RGBA8888 only.
47  * The screen pixel format does not store any alpha information.
48  *
49  * > Custom specific color channel order of the native pixel format. Depending
50  * on the graphics hardware, it may be necessary to adapt the order in which
51  * the color channels are stored in the video memory of a native surface.
52  *
53  * The format name 'RGBA8888' refers to the generic 32 bit color format
54  * where the color and alpha channels are stored within a 32 bit value
55  * in the following manner:
56  *
57  * 31 24 16 8 0
58  * +------------+---------------------------------------+
59  * | alpha | blue | green | red |
60  * +------------+---------------------------------------+
61  *
62  *
63  * To control the order of channels, specify the bit start position of each
64  * channel. For this purpose the macros EW_COLOR_CHANNEL_BIT_OFFSET_XXX are
65  * available (XXX stands for RED, GREEN, BLUE and ALPHA). For example to
66  * adapt this pixel driver to graphics hardware using BGRA8888 color format,
67  * add following lines to your 'ewextgfx.h' file:
68  *
69  * #define EW_COLOR_CHANNEL_BIT_OFFSET_RED 16
70  * #define EW_COLOR_CHANNEL_BIT_OFFSET_GREEN 8
71  * #define EW_COLOR_CHANNEL_BIT_OFFSET_BLUE 0
72  * #define EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA 24
73  *
74  * Please note, these options affect the native pixel format RGBA8888 only.
75  *
76  * > Custom specific color channel order of the screen pixel format. Depending
77  * on the graphics hardware, it may be necessary to adapt the order in which
78  * the color channels are stored in the video memory of a screen surface.
79  *
80  * The format name 'RGB565' refers to the generic 16 bit color format where
81  * the color channels are stored within a 16 bit value in the following
82  * manner:
83  *
84  * 15 11 5 0
85  * +---------------------------------------+
86  * | blue | green | red |
87  * +---------------------------------------+
88  *
89  *
90  * Note, the green information always occupies the middle 6 bit wide
91  *channel. This can not be changed.
92  *
93  * To control the order of channels, specify the bit start position of each
94  * channel. For this purpose the macros
95  *EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_XXX are available (XXX stands for RED and
96  *BLUE - green channel position is fixed as mentioned above). For example to
97  *adapt this pixel driver to graphics hardware using BGR565 color format, add
98  *following lines to your 'ewextgfx.h' file:
99  *
100  * #define EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED 11
101  * #define EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE 0
102  *
103  * Please note, these options affect the screen pixel format RGB565 only.
104  *
105  * > The RGB565 bitmap source format configuration does correspond to the of
106  * the SCREEN format as described above.
107  *
108  *******************************************************************************/
109 
110 /* If not explicitly defined, assume default bit positions for the RGBA channels
111  within a pixel memory. */
112 #ifndef EW_COLOR_CHANNEL_BIT_OFFSET_RED
113 #define EW_COLOR_CHANNEL_BIT_OFFSET_RED 0
114 #endif
115 
116 #ifndef EW_COLOR_CHANNEL_BIT_OFFSET_GREEN
117 #define EW_COLOR_CHANNEL_BIT_OFFSET_GREEN 8
118 #endif
119 
120 #ifndef EW_COLOR_CHANNEL_BIT_OFFSET_BLUE
121 #define EW_COLOR_CHANNEL_BIT_OFFSET_BLUE 16
122 #endif
123 
124 #ifndef EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA
125 #define EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA 24
126 #endif
127 
128 /* Verify the position of the red, green, blue and alpha channel */
129 #if ((EW_COLOR_CHANNEL_BIT_OFFSET_RED != 0) && \
130  (EW_COLOR_CHANNEL_BIT_OFFSET_RED != 8) && \
131  (EW_COLOR_CHANNEL_BIT_OFFSET_RED != 16) && \
132  (EW_COLOR_CHANNEL_BIT_OFFSET_RED != 24))
133 #error Wrong 'red' channel bit position. Only '0', '8', '16' or '24' allowed.
134 #endif
135 
136 #if ((EW_COLOR_CHANNEL_BIT_OFFSET_GREEN != 0) && \
137  (EW_COLOR_CHANNEL_BIT_OFFSET_GREEN != 8) && \
138  (EW_COLOR_CHANNEL_BIT_OFFSET_GREEN != 16) && \
139  (EW_COLOR_CHANNEL_BIT_OFFSET_GREEN != 24))
140 #error Wrong 'green' channel bit position. Only '0', '8', '16' or '24' allowed.
141 #endif
142 
143 #if ((EW_COLOR_CHANNEL_BIT_OFFSET_BLUE != 0) && \
144  (EW_COLOR_CHANNEL_BIT_OFFSET_BLUE != 8) && \
145  (EW_COLOR_CHANNEL_BIT_OFFSET_BLUE != 16) && \
146  (EW_COLOR_CHANNEL_BIT_OFFSET_BLUE != 24))
147 #error Wrong 'blue' channel bit position. Only '0', '8', '16' or '24' allowed.
148 #endif
149 
150 #if ((EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA != 0) && \
151  (EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA != 8) && \
152  (EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA != 16) && \
153  (EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA != 24))
154 #error Wrong 'alpha' channel bit position. Only '0', '8', '16' or '24' allowed.
155 #endif
156 
157 #if (EW_COLOR_CHANNEL_BIT_OFFSET_RED == EW_COLOR_CHANNEL_BIT_OFFSET_BLUE) || \
158  (EW_COLOR_CHANNEL_BIT_OFFSET_RED == EW_COLOR_CHANNEL_BIT_OFFSET_GREEN) || \
159  (EW_COLOR_CHANNEL_BIT_OFFSET_RED == EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA) || \
160  (EW_COLOR_CHANNEL_BIT_OFFSET_GREEN == EW_COLOR_CHANNEL_BIT_OFFSET_BLUE) || \
161  (EW_COLOR_CHANNEL_BIT_OFFSET_GREEN == \
162  EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA) || \
163  (EW_COLOR_CHANNEL_BIT_OFFSET_BLUE == EW_COLOR_CHANNEL_BIT_OFFSET_ALPHA)
164 #error Bit offset conflict in the color channel definition.
165 #endif
166 
167 /* If not explicitly defined, assume default bit positions for the RGB channels
168  of the screen format within a pixel memory. */
169 #ifndef EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED
170 #define EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED 0
171 #endif
172 
173 #ifndef EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_GREEN
174 #define EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_GREEN 5
175 #endif
176 
177 #ifndef EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE
178 #define EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE 11
179 #endif
180 
181 /* Verify the position of the red, green and blue channels of the screen
182  format */
183 #if ((EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED != 0) && \
184  (EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED != 11))
185 #error Wrong 'red' channel bit position. Only '0' or '11' allowed.
186 #endif
187 
188 #if EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_GREEN != 5
189 #error Wrong 'green' channel bit position. Only '5' allowed.
190 #endif
191 
192 #if ((EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE != 0) && \
193  (EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE != 11))
194 #error Wrong 'blue' channel bit position. Only '0' or '11' allowed.
195 #endif
196 
197 #if EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED == \
198  EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE
199 #error Bit offset conflict in the color channel definition.
200 #endif
201 
202 /* This pixel driver expects the channel order of the RGB565 and SCREEN surfaces
203  to be identical. The channel order of the RGB565 surface can't be configured
204  individually. */
205 #define EW_RGB565_COLOR_CHANNEL_BIT_OFFSET_RED \
206  EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_RED
207 
208 #define EW_RGB565_COLOR_CHANNEL_BIT_OFFSET_GREEN \
209  EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_GREEN
210 
211 #define EW_RGB565_COLOR_CHANNEL_BIT_OFFSET_BLUE \
212  EW_SCREEN_COLOR_CHANNEL_BIT_OFFSET_BLUE
213 
214 /* The following mode can be enabled for Index8 target systems only. RGB565 /
215  RGBA8888 don't support the global CLUT/pallete. */
216 #ifdef EW_ENABLE_COLOR_TABLE
217 #error Please remove the macro 'EW_ENABLE_COLOR_TABLE' from your make file.
218 #endif
219 
220 /* RGB565 / RGBA8888 expects the 'screen' color format to be enabled in the
221  Graphics Engine. Verify whether the correct macro is defined. */
222 #ifndef EW_USE_PIXEL_FORMAT_SCREEN
223 #error Please ensure the macro 'EW_USE_PIXEL_FORMAT_SCREEN' is defined.
224 #endif
225 
226 /* pba */