|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tdisplaymode_mapping.h" |
|
23 |
|
24 const TPtrC KPixelFormatNames[] = |
|
25 { |
|
26 _L("EUidPixelFormatUnknown"), //0 |
|
27 _L("EUidPixelFormatXRGB_8888"), //1 |
|
28 _L("EUidPixelFormatARGB_8888"), //2 |
|
29 _L("EUidPixelFormatARGB_8888_PRE"), //3 |
|
30 _L("EUidPixelFormatRGB_888"), //4 |
|
31 _L("EUidPixelFormatA_8"), //5 |
|
32 _L("EUidPixelFormatRGB_565"), //6 |
|
33 _L("EUidPixelFormatXRGB_4444"), //7 |
|
34 _L("EUidPixelFormatP_8"), //8 |
|
35 _L("EUidPixelFormatP_4"), //9 |
|
36 _L("EUidPixelFormatL_8"), //10 |
|
37 _L("EUidPixelFormatL_4"), //11 |
|
38 _L("EUidPixelFormatL_2"), //12 |
|
39 _L("EUidPixelFormatL_1"), //13 |
|
40 }; |
|
41 |
|
42 const TPtrC KShortPixelFormatNames[] = |
|
43 { |
|
44 _L("Unknown"), //0 |
|
45 _L("XRGB_8888"), //1 |
|
46 _L("ARGB_8888"), //2 |
|
47 _L("ARGB_8888_PRE"), //3 |
|
48 _L("RGB_888"), //4 |
|
49 _L("A_8"), //5 |
|
50 _L("RGB_565"), //6 |
|
51 _L("XRGB_4444"), //7 |
|
52 _L("P_8"), //8 |
|
53 _L("P_4"), //9 |
|
54 _L("L_8"), //10 |
|
55 _L("L_4"), //11 |
|
56 _L("L_2"), //12 |
|
57 _L("L_1"), //13 |
|
58 }; |
|
59 |
|
60 /** |
|
61 Convert the string of pixel format to TDisplayMode |
|
62 @param aPixelformatString The input string of pixel format |
|
63 @return On return, it contains a display mode enum value |
|
64 */ |
|
65 TDisplayMode TDisplayModeMapping::ConvertPixelFormatStringToDisplayMode(const TPtrC aPixelformatString) |
|
66 { |
|
67 TUidPixelFormat format = ConvertPixelFormatStringToPixelFormat(aPixelformatString); |
|
68 |
|
69 return MapPixelFormatToDisplayMode(format); |
|
70 } |
|
71 |
|
72 /** |
|
73 Converts a pixel format string to TUidPixelFormat |
|
74 @see ConvertPixelformatToShortPixelFormatString() |
|
75 @param aPixelformatString The pixel format string to convert |
|
76 @return Returns a pixel format enum value TUidPixelFormat |
|
77 */ |
|
78 TUidPixelFormat TDisplayModeMapping::ConvertPixelFormatStringToPixelFormat(const TPtrC aPixelformatString) |
|
79 { |
|
80 TUidPixelFormat format = EUidPixelFormatUnknown; |
|
81 |
|
82 if (aPixelformatString == KPixelFormatNames[1]) |
|
83 { |
|
84 format = EUidPixelFormatXRGB_8888; |
|
85 } |
|
86 else if (aPixelformatString == KPixelFormatNames[2]) |
|
87 { |
|
88 format = EUidPixelFormatARGB_8888; |
|
89 } |
|
90 else if (aPixelformatString == KPixelFormatNames[3]) |
|
91 { |
|
92 format = EUidPixelFormatARGB_8888_PRE; |
|
93 } |
|
94 else if (aPixelformatString == KPixelFormatNames[4]) |
|
95 { |
|
96 format = EUidPixelFormatRGB_888; |
|
97 } |
|
98 else if (aPixelformatString == KPixelFormatNames[5]) |
|
99 { |
|
100 format = EUidPixelFormatA_8; |
|
101 } |
|
102 else if (aPixelformatString == KPixelFormatNames[6]) |
|
103 { |
|
104 format = EUidPixelFormatRGB_565; |
|
105 } |
|
106 else if (aPixelformatString == KPixelFormatNames[7]) |
|
107 { |
|
108 format = EUidPixelFormatXRGB_4444; |
|
109 } |
|
110 else if (aPixelformatString == KPixelFormatNames[8]) |
|
111 { |
|
112 format = EUidPixelFormatP_8; |
|
113 } |
|
114 else if (aPixelformatString == KPixelFormatNames[9]) |
|
115 { |
|
116 format = EUidPixelFormatP_4; |
|
117 } |
|
118 else if (aPixelformatString == KPixelFormatNames[10]) |
|
119 { |
|
120 format = EUidPixelFormatL_8; |
|
121 } |
|
122 else if (aPixelformatString == KPixelFormatNames[11]) |
|
123 { |
|
124 format = EUidPixelFormatL_4; |
|
125 } |
|
126 else if (aPixelformatString == KPixelFormatNames[12]) |
|
127 { |
|
128 format = EUidPixelFormatL_2; |
|
129 } |
|
130 else if (aPixelformatString == KPixelFormatNames[13]) |
|
131 { |
|
132 format = EUidPixelFormatL_1; |
|
133 } |
|
134 |
|
135 return format; |
|
136 } |
|
137 |
|
138 /* |
|
139 Convert the pixel format enum to a string |
|
140 @param aFormat The pixel format enum |
|
141 @return On return, it contains the pixel format string |
|
142 */ |
|
143 TPtrC TDisplayModeMapping::ConvertPixelFormatToPixelFormatString(const TUidPixelFormat aFormat) |
|
144 { |
|
145 TPtrC pixelFormatString(KPixelFormatNames[0]); |
|
146 |
|
147 if (aFormat == EUidPixelFormatXRGB_8888) |
|
148 { |
|
149 pixelFormatString.Set(KPixelFormatNames[1]); |
|
150 } |
|
151 else if (aFormat == EUidPixelFormatARGB_8888) |
|
152 { |
|
153 pixelFormatString.Set(KPixelFormatNames[2]); |
|
154 } |
|
155 else if (aFormat == EUidPixelFormatARGB_8888_PRE) |
|
156 { |
|
157 pixelFormatString.Set(KPixelFormatNames[3]); |
|
158 } |
|
159 else if (aFormat == EUidPixelFormatRGB_888) |
|
160 { |
|
161 pixelFormatString.Set(KPixelFormatNames[4]); |
|
162 } |
|
163 else if (aFormat == EUidPixelFormatA_8) |
|
164 { |
|
165 pixelFormatString.Set(KPixelFormatNames[5]); |
|
166 } |
|
167 else if (aFormat == EUidPixelFormatRGB_565) |
|
168 { |
|
169 pixelFormatString.Set(KPixelFormatNames[6]); |
|
170 } |
|
171 else if (aFormat == EUidPixelFormatXRGB_4444) |
|
172 { |
|
173 pixelFormatString.Set(KPixelFormatNames[7]); |
|
174 } |
|
175 else if (aFormat == EUidPixelFormatP_8) |
|
176 { |
|
177 pixelFormatString.Set(KPixelFormatNames[8]); |
|
178 } |
|
179 else if (aFormat == EUidPixelFormatP_4) |
|
180 { |
|
181 pixelFormatString.Set(KPixelFormatNames[9]); |
|
182 } |
|
183 else if (aFormat == EUidPixelFormatL_8) |
|
184 { |
|
185 pixelFormatString.Set(KPixelFormatNames[10]); |
|
186 } |
|
187 else if (aFormat == EUidPixelFormatL_4) |
|
188 { |
|
189 pixelFormatString.Set(KPixelFormatNames[11]); |
|
190 } |
|
191 else if (aFormat == EUidPixelFormatL_2) |
|
192 { |
|
193 pixelFormatString.Set(KPixelFormatNames[12]); |
|
194 } |
|
195 else if (aFormat == EUidPixelFormatL_1) |
|
196 { |
|
197 pixelFormatString.Set(KPixelFormatNames[13]); |
|
198 } |
|
199 |
|
200 return pixelFormatString; |
|
201 } |
|
202 |
|
203 /* |
|
204 Convert the pixel format enum to a shorter string than is achieved with ConvertPixelformatToPixelFormatString(). |
|
205 The EUidPixelFormat portion of the pixel format string is not added to the string. |
|
206 @see ConvertPixelformatToPixelFormatString() |
|
207 @param aFormat The pixel format enum |
|
208 @return On return, it contains the pixel format string |
|
209 */ |
|
210 TPtrC TDisplayModeMapping::ConvertPixelFormatToShortPixelFormatString(const TUidPixelFormat aFormat) |
|
211 { |
|
212 TPtrC pixelFormatString(KShortPixelFormatNames[0]); |
|
213 |
|
214 if (aFormat == EUidPixelFormatXRGB_8888) |
|
215 { |
|
216 pixelFormatString.Set(KShortPixelFormatNames[1]); |
|
217 } |
|
218 else if (aFormat == EUidPixelFormatARGB_8888) |
|
219 { |
|
220 pixelFormatString.Set(KShortPixelFormatNames[2]); |
|
221 } |
|
222 else if (aFormat == EUidPixelFormatARGB_8888_PRE) |
|
223 { |
|
224 pixelFormatString.Set(KShortPixelFormatNames[3]); |
|
225 } |
|
226 else if (aFormat == EUidPixelFormatRGB_888) |
|
227 { |
|
228 pixelFormatString.Set(KShortPixelFormatNames[4]); |
|
229 } |
|
230 else if (aFormat == EUidPixelFormatA_8) |
|
231 { |
|
232 pixelFormatString.Set(KShortPixelFormatNames[5]); |
|
233 } |
|
234 else if (aFormat == EUidPixelFormatRGB_565) |
|
235 { |
|
236 pixelFormatString.Set(KShortPixelFormatNames[6]); |
|
237 } |
|
238 else if (aFormat == EUidPixelFormatXRGB_4444) |
|
239 { |
|
240 pixelFormatString.Set(KShortPixelFormatNames[7]); |
|
241 } |
|
242 else if (aFormat == EUidPixelFormatP_8) |
|
243 { |
|
244 pixelFormatString.Set(KShortPixelFormatNames[8]); |
|
245 } |
|
246 else if (aFormat == EUidPixelFormatP_4) |
|
247 { |
|
248 pixelFormatString.Set(KShortPixelFormatNames[9]); |
|
249 } |
|
250 else if (aFormat == EUidPixelFormatL_8) |
|
251 { |
|
252 pixelFormatString.Set(KShortPixelFormatNames[10]); |
|
253 } |
|
254 else if (aFormat == EUidPixelFormatL_4) |
|
255 { |
|
256 pixelFormatString.Set(KShortPixelFormatNames[11]); |
|
257 } |
|
258 else if (aFormat == EUidPixelFormatL_2) |
|
259 { |
|
260 pixelFormatString.Set(KShortPixelFormatNames[12]); |
|
261 } |
|
262 else if (aFormat == EUidPixelFormatL_1) |
|
263 { |
|
264 pixelFormatString.Set(KShortPixelFormatNames[13]); |
|
265 } |
|
266 |
|
267 return pixelFormatString; |
|
268 } |
|
269 |
|
270 /* |
|
271 Maps a pixel format enum to a display mode enum |
|
272 @param aFormat The pixel format enum |
|
273 @return Returns the display mode enum |
|
274 */ |
|
275 TDisplayMode TDisplayModeMapping::MapPixelFormatToDisplayMode(const TUidPixelFormat aFormat) |
|
276 { |
|
277 TDisplayMode mode; |
|
278 |
|
279 switch(aFormat) |
|
280 { |
|
281 /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ |
|
282 case EUidPixelFormatXRGB_8888: |
|
283 mode = EColor16MU; |
|
284 break; |
|
285 |
|
286 /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ |
|
287 case EUidPixelFormatARGB_8888: |
|
288 mode = EColor16MA; |
|
289 break; |
|
290 |
|
291 /** Pre-multiplied Alpha display mode (24bpp color multiplied with the alpha channel value, plus 8bpp alpha) */ |
|
292 case EUidPixelFormatARGB_8888_PRE: |
|
293 mode = EColor16MAP; |
|
294 break; |
|
295 |
|
296 /** True colour display mode (24 bpp) */ |
|
297 case EUidPixelFormatRGB_888: |
|
298 mode = EColor16M; |
|
299 break; |
|
300 |
|
301 case EUidPixelFormatXRGB_4444: |
|
302 mode = EColor4K; |
|
303 break; |
|
304 |
|
305 /** 64,000 colour display mode (16 bpp) */ |
|
306 case EUidPixelFormatRGB_565: |
|
307 mode = EColor64K; |
|
308 break; |
|
309 |
|
310 /** 256 grayscales display mode (8 bpp) */ |
|
311 case EUidPixelFormatA_8: |
|
312 mode = EGray256; |
|
313 break; |
|
314 |
|
315 /** 256 grayscales (8 bpp) */ |
|
316 case EUidPixelFormatL_8: |
|
317 mode = EGray256; |
|
318 break; |
|
319 |
|
320 /** Eight grayscales (4 bpp) */ |
|
321 case EUidPixelFormatL_4: |
|
322 mode = EGray16; |
|
323 break; |
|
324 |
|
325 /** Four grayscales display mode (2 bpp) */ |
|
326 case EUidPixelFormatL_2: |
|
327 mode = EGray4; |
|
328 break; |
|
329 |
|
330 /** Two grayscales (black and white) display mode (1 bpp) */ |
|
331 case EUidPixelFormatL_1: |
|
332 mode = EGray2; |
|
333 break; |
|
334 |
|
335 /** 256 colour display mode (8 bpp) */ |
|
336 case EUidPixelFormatP_8: |
|
337 mode = EColor256; |
|
338 break; |
|
339 |
|
340 /** Low colour EGA 16 colour display mode (4 bpp) */ |
|
341 case EUidPixelFormatP_4: |
|
342 mode = EColor16; |
|
343 break; |
|
344 |
|
345 /** Monochrome display mode (1 bpp) */ |
|
346 case EUidPixelFormatP_1: |
|
347 mode = EGray2; |
|
348 break; |
|
349 |
|
350 // Unknown display mode |
|
351 default: |
|
352 case EUidPixelFormatUnknown: |
|
353 mode = ENone; |
|
354 break; |
|
355 } |
|
356 |
|
357 return mode; |
|
358 } |
|
359 |
|
360 /* |
|
361 Map display mode enum to pixel formation enum |
|
362 @param aDisplayMode The display mode enum |
|
363 @return On return, it contains the pixel format enum |
|
364 */ |
|
365 TUidPixelFormat TDisplayModeMapping::MapDisplayModeToPixelFormat(const TDisplayMode aDisplayMode) |
|
366 { |
|
367 TUidPixelFormat format; |
|
368 |
|
369 switch(aDisplayMode) |
|
370 { |
|
371 /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ |
|
372 case EColor16MU: |
|
373 format = EUidPixelFormatXRGB_8888; |
|
374 break; |
|
375 |
|
376 /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ |
|
377 case EColor16MA: |
|
378 format = EUidPixelFormatARGB_8888; |
|
379 break; |
|
380 |
|
381 /** Pre-multiplied Alpha display mode (24bpp color multiplied with the alpha channel value, plus 8bpp alpha) */ |
|
382 case EColor16MAP: |
|
383 format = EUidPixelFormatARGB_8888_PRE; |
|
384 break; |
|
385 |
|
386 /** True colour display mode (24 bpp) */ |
|
387 case EColor16M: |
|
388 format = EUidPixelFormatRGB_888; |
|
389 break; |
|
390 |
|
391 case EColor4K: |
|
392 format = EUidPixelFormatXRGB_4444; |
|
393 break; |
|
394 |
|
395 /** 64,000 colour display mode (16 bpp) */ |
|
396 case EColor64K: |
|
397 format = EUidPixelFormatRGB_565; |
|
398 break; |
|
399 |
|
400 /** 256 grayscale display mode (8 bpp) */ |
|
401 case EGray256: |
|
402 format = EUidPixelFormatL_8; |
|
403 break; |
|
404 |
|
405 /** Sixteen grayscales display mode (4 bpp) */ |
|
406 case EGray16: |
|
407 format = EUidPixelFormatL_4; |
|
408 break; |
|
409 |
|
410 /** Four grayscales display mode (2 bpp) */ |
|
411 case EGray4: |
|
412 format = EUidPixelFormatL_2; |
|
413 break; |
|
414 |
|
415 /** Monochrome display mode (1 bpp) */ |
|
416 case EGray2: |
|
417 format = EUidPixelFormatL_1; |
|
418 break; |
|
419 |
|
420 /** 256 Color paletised (8 bpp) */ |
|
421 case EColor256: |
|
422 format = EUidPixelFormatP_8; |
|
423 break; |
|
424 |
|
425 /** Sixteen Colour paletised (4 bpp)*/ |
|
426 case EColor16: |
|
427 format = EUidPixelFormatP_4; |
|
428 break; |
|
429 |
|
430 // Unknown display mode |
|
431 default: |
|
432 case ENone: |
|
433 format = EUidPixelFormatUnknown; |
|
434 break; |
|
435 } |
|
436 |
|
437 return format; |
|
438 } |
|
439 |