1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4
5 #include "CColorConverter.h"
6 #include "SColor.h"
7 #include "os.h"
8 #include "irrString.h"
9
10 namespace irr
11 {
12 namespace video
13 {
14
15 //! converts a monochrome bitmap to A1R5G5B5 data
convert1BitTo16Bit(const u8 * in,s16 * out,s32 width,s32 height,s32 linepad,bool flip)16 void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip)
17 {
18 if (!in || !out)
19 return;
20
21 if (flip)
22 out += width * height;
23
24 for (s32 y=0; y<height; ++y)
25 {
26 s32 shift = 7;
27 if (flip)
28 out -= width;
29
30 for (s32 x=0; x<width; ++x)
31 {
32 out[x] = *in>>shift & 0x01 ? (s16)0xffff : (s16)0x8000;
33
34 if ((--shift)<0) // 8 pixel done
35 {
36 shift=7;
37 ++in;
38 }
39 }
40
41 if (shift != 7) // width did not fill last byte
42 ++in;
43
44 if (!flip)
45 out += width;
46 in += linepad;
47 }
48 }
49
50
51
52 //! converts a 4 bit palettized image to A1R5G5B5
convert4BitTo16Bit(const u8 * in,s16 * out,s32 width,s32 height,const s32 * palette,s32 linepad,bool flip)53 void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip)
54 {
55 if (!in || !out || !palette)
56 return;
57
58 if (flip)
59 out += width*height;
60
61 for (s32 y=0; y<height; ++y)
62 {
63 s32 shift = 4;
64 if (flip)
65 out -= width;
66
67 for (s32 x=0; x<width; ++x)
68 {
69 out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)((*in >> shift) & 0xf)]);
70
71 if (shift==0)
72 {
73 shift = 4;
74 ++in;
75 }
76 else
77 shift = 0;
78 }
79
80 if (shift == 0) // odd width
81 ++in;
82
83 if (!flip)
84 out += width;
85 in += linepad;
86 }
87 }
88
89
90
91 //! converts a 8 bit palettized image into A1R5G5B5
convert8BitTo16Bit(const u8 * in,s16 * out,s32 width,s32 height,const s32 * palette,s32 linepad,bool flip)92 void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip)
93 {
94 if (!in || !out || !palette)
95 return;
96
97 if (flip)
98 out += width * height;
99
100 for (s32 y=0; y<height; ++y)
101 {
102 if (flip)
103 out -= width; // one line back
104 for (s32 x=0; x<width; ++x)
105 {
106 out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)(*in)]);
107 ++in;
108 }
109 if (!flip)
110 out += width;
111 in += linepad;
112 }
113 }
114
115 //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8
convert8BitTo24Bit(const u8 * in,u8 * out,s32 width,s32 height,const u8 * palette,s32 linepad,bool flip)116 void CColorConverter::convert8BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad, bool flip)
117 {
118 if (!in || !out )
119 return;
120
121 const s32 lineWidth = 3 * width;
122 if (flip)
123 out += lineWidth * height;
124
125 for (s32 y=0; y<height; ++y)
126 {
127 if (flip)
128 out -= lineWidth; // one line back
129 for (s32 x=0; x< lineWidth; x += 3)
130 {
131 if ( palette )
132 {
133 #ifdef __BIG_ENDIAN__
134 out[x+0] = palette[ (in[0] << 2 ) + 0];
135 out[x+1] = palette[ (in[0] << 2 ) + 1];
136 out[x+2] = palette[ (in[0] << 2 ) + 2];
137 #else
138 out[x+0] = palette[ (in[0] << 2 ) + 2];
139 out[x+1] = palette[ (in[0] << 2 ) + 1];
140 out[x+2] = palette[ (in[0] << 2 ) + 0];
141 #endif
142 }
143 else
144 {
145 out[x+0] = in[0];
146 out[x+1] = in[0];
147 out[x+2] = in[0];
148 }
149 ++in;
150 }
151 if (!flip)
152 out += lineWidth;
153 in += linepad;
154 }
155 }
156
157 //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8
convert8BitTo32Bit(const u8 * in,u8 * out,s32 width,s32 height,const u8 * palette,s32 linepad,bool flip)158 void CColorConverter::convert8BitTo32Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad, bool flip)
159 {
160 if (!in || !out )
161 return;
162
163 const u32 lineWidth = 4 * width;
164 if (flip)
165 out += lineWidth * height;
166
167 u32 x;
168 u32 c;
169 for (u32 y=0; y < (u32) height; ++y)
170 {
171 if (flip)
172 out -= lineWidth; // one line back
173
174 if ( palette )
175 {
176 for (x=0; x < (u32) width; x += 1)
177 {
178 c = in[x];
179 ((u32*)out)[x] = ((u32*)palette)[ c ];
180 }
181 }
182 else
183 {
184 for (x=0; x < (u32) width; x += 1)
185 {
186 c = in[x];
187 #ifdef __BIG_ENDIAN__
188 ((u32*)out)[x] = c << 24 | c << 16 | c << 8 | 0x000000FF;
189 #else
190 ((u32*)out)[x] = 0xFF000000 | c << 16 | c << 8 | c;
191 #endif
192 }
193
194 }
195
196 if (!flip)
197 out += lineWidth;
198 in += width + linepad;
199 }
200 }
201
202
203
204 //! converts 16bit data to 16bit data
convert16BitTo16Bit(const s16 * in,s16 * out,s32 width,s32 height,s32 linepad,bool flip)205 void CColorConverter::convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad, bool flip)
206 {
207 if (!in || !out)
208 return;
209
210 if (flip)
211 out += width * height;
212
213 for (s32 y=0; y<height; ++y)
214 {
215 if (flip)
216 out -= width;
217 #ifdef __BIG_ENDIAN__
218 for (s32 x=0; x<width; ++x)
219 out[x]=os::Byteswap::byteswap(in[x]);
220 #else
221 memcpy(out, in, width*sizeof(s16));
222 #endif
223 if (!flip)
224 out += width;
225 in += width;
226 in += linepad;
227 }
228 }
229
230
231
232 //! copies R8G8B8 24bit data to 24bit data
convert24BitTo24Bit(const u8 * in,u8 * out,s32 width,s32 height,s32 linepad,bool flip,bool bgr)233 void CColorConverter::convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad, bool flip, bool bgr)
234 {
235 if (!in || !out)
236 return;
237
238 const s32 lineWidth = 3 * width;
239 if (flip)
240 out += lineWidth * height;
241
242 for (s32 y=0; y<height; ++y)
243 {
244 if (flip)
245 out -= lineWidth;
246 if (bgr)
247 {
248 for (s32 x=0; x<lineWidth; x+=3)
249 {
250 out[x+0] = in[x+2];
251 out[x+1] = in[x+1];
252 out[x+2] = in[x+0];
253 }
254 }
255 else
256 {
257 memcpy(out,in,lineWidth);
258 }
259 if (!flip)
260 out += lineWidth;
261 in += lineWidth;
262 in += linepad;
263 }
264 }
265
266
267
268 //! Resizes the surface to a new size and converts it at the same time
269 //! to an A8R8G8B8 format, returning the pointer to the new buffer.
convert16bitToA8R8G8B8andResize(const s16 * in,s32 * out,s32 newWidth,s32 newHeight,s32 currentWidth,s32 currentHeight)270 void CColorConverter::convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight)
271 {
272 if (!newWidth || !newHeight)
273 return;
274
275 // note: this is very very slow. (i didn't want to write a fast version.
276 // but hopefully, nobody wants to convert surfaces every frame.
277
278 f32 sourceXStep = (f32)currentWidth / (f32)newWidth;
279 f32 sourceYStep = (f32)currentHeight / (f32)newHeight;
280 f32 sy;
281 s32 t;
282
283 for (s32 x=0; x<newWidth; ++x)
284 {
285 sy = 0.0f;
286
287 for (s32 y=0; y<newHeight; ++y)
288 {
289 t = in[(s32)(((s32)sy)*currentWidth + x*sourceXStep)];
290 t = (((t >> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) |
291 (((t >> 5)&0x1F)<<11) | (t&0x1F)<<3;
292 out[(s32)(y*newWidth + x)] = t;
293
294 sy+=sourceYStep;
295 }
296 }
297 }
298
299
300
301 //! copies X8R8G8B8 32 bit data
convert32BitTo32Bit(const s32 * in,s32 * out,s32 width,s32 height,s32 linepad,bool flip)302 void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip)
303 {
304 if (!in || !out)
305 return;
306
307 if (flip)
308 out += width * height;
309
310 for (s32 y=0; y<height; ++y)
311 {
312 if (flip)
313 out -= width;
314 #ifdef __BIG_ENDIAN__
315 for (s32 x=0; x<width; ++x)
316 out[x]=os::Byteswap::byteswap(in[x]);
317 #else
318 memcpy(out, in, width*sizeof(s32));
319 #endif
320 if (!flip)
321 out += width;
322 in += width;
323 in += linepad;
324 }
325 }
326
327
328
convert_A1R5G5B5toR8G8B8(const void * sP,s32 sN,void * dP)329 void CColorConverter::convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP)
330 {
331 u16* sB = (u16*)sP;
332 u8 * dB = (u8 *)dP;
333
334 for (s32 x = 0; x < sN; ++x)
335 {
336 dB[2] = (*sB & 0x7c00) >> 7;
337 dB[1] = (*sB & 0x03e0) >> 2;
338 dB[0] = (*sB & 0x1f) << 3;
339
340 sB += 1;
341 dB += 3;
342 }
343 }
344
convert_A1R5G5B5toB8G8R8(const void * sP,s32 sN,void * dP)345 void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP)
346 {
347 u16* sB = (u16*)sP;
348 u8 * dB = (u8 *)dP;
349
350 for (s32 x = 0; x < sN; ++x)
351 {
352 dB[0] = (*sB & 0x7c00) >> 7;
353 dB[1] = (*sB & 0x03e0) >> 2;
354 dB[2] = (*sB & 0x1f) << 3;
355
356 sB += 1;
357 dB += 3;
358 }
359 }
360
convert_A1R5G5B5toR5G5B5A1(const void * sP,s32 sN,void * dP)361 void CColorConverter::convert_A1R5G5B5toR5G5B5A1(const void* sP, s32 sN, void* dP)
362 {
363 const u16* sB = (const u16*)sP;
364 u16* dB = (u16*)dP;
365
366 for (s32 x = 0; x < sN; ++x)
367 {
368 *dB = (*sB<<1)|(*sB>>15);
369 ++sB; ++dB;
370 }
371 }
372
convert_A1R5G5B5toA8R8G8B8(const void * sP,s32 sN,void * dP)373 void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP)
374 {
375 u16* sB = (u16*)sP;
376 u32* dB = (u32*)dP;
377
378 for (s32 x = 0; x < sN; ++x)
379 *dB++ = A1R5G5B5toA8R8G8B8(*sB++);
380 }
381
convert_A1R5G5B5toA1R5G5B5(const void * sP,s32 sN,void * dP)382 void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP)
383 {
384 memcpy(dP, sP, sN * 2);
385 }
386
convert_A1R5G5B5toR5G6B5(const void * sP,s32 sN,void * dP)387 void CColorConverter::convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP)
388 {
389 u16* sB = (u16*)sP;
390 u16* dB = (u16*)dP;
391
392 for (s32 x = 0; x < sN; ++x)
393 *dB++ = A1R5G5B5toR5G6B5(*sB++);
394 }
395
convert_A8R8G8B8toR8G8B8(const void * sP,s32 sN,void * dP)396 void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP)
397 {
398 u8* sB = (u8*)sP;
399 u8* dB = (u8*)dP;
400
401 for (s32 x = 0; x < sN; ++x)
402 {
403 // sB[3] is alpha
404 dB[0] = sB[2];
405 dB[1] = sB[1];
406 dB[2] = sB[0];
407
408 sB += 4;
409 dB += 3;
410 }
411 }
412
convert_A8R8G8B8toB8G8R8(const void * sP,s32 sN,void * dP)413 void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP)
414 {
415 u8* sB = (u8*)sP;
416 u8* dB = (u8*)dP;
417
418 for (s32 x = 0; x < sN; ++x)
419 {
420 // sB[3] is alpha
421 dB[0] = sB[0];
422 dB[1] = sB[1];
423 dB[2] = sB[2];
424
425 sB += 4;
426 dB += 3;
427 }
428 }
429
convert_A8R8G8B8toA8R8G8B8(const void * sP,s32 sN,void * dP)430 void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP)
431 {
432 memcpy(dP, sP, sN * 4);
433 }
434
convert_A8R8G8B8toA1R5G5B5(const void * sP,s32 sN,void * dP)435 void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP)
436 {
437 u32* sB = (u32*)sP;
438 u16* dB = (u16*)dP;
439
440 for (s32 x = 0; x < sN; ++x)
441 *dB++ = A8R8G8B8toA1R5G5B5(*sB++);
442 }
443
convert_A8R8G8B8toR5G6B5(const void * sP,s32 sN,void * dP)444 void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP)
445 {
446 u8 * sB = (u8 *)sP;
447 u16* dB = (u16*)dP;
448
449 for (s32 x = 0; x < sN; ++x)
450 {
451 s32 r = sB[2] >> 3;
452 s32 g = sB[1] >> 2;
453 s32 b = sB[0] >> 3;
454
455 dB[0] = (r << 11) | (g << 5) | (b);
456
457 sB += 4;
458 dB += 1;
459 }
460 }
461
convert_A8R8G8B8toR3G3B2(const void * sP,s32 sN,void * dP)462 void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP)
463 {
464 u8* sB = (u8*)sP;
465 u8* dB = (u8*)dP;
466
467 for (s32 x = 0; x < sN; ++x)
468 {
469 u8 r = sB[2] & 0xe0;
470 u8 g = (sB[1] & 0xe0) >> 3;
471 u8 b = (sB[0] & 0xc0) >> 6;
472
473 dB[0] = (r | g | b);
474
475 sB += 4;
476 dB += 1;
477 }
478 }
479
convert_R8G8B8toR8G8B8(const void * sP,s32 sN,void * dP)480 void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP)
481 {
482 memcpy(dP, sP, sN * 3);
483 }
484
convert_R8G8B8toA8R8G8B8(const void * sP,s32 sN,void * dP)485 void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP)
486 {
487 u8* sB = (u8* )sP;
488 u32* dB = (u32*)dP;
489
490 for (s32 x = 0; x < sN; ++x)
491 {
492 *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2];
493
494 sB += 3;
495 ++dB;
496 }
497 }
498
convert_R8G8B8toA1R5G5B5(const void * sP,s32 sN,void * dP)499 void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP)
500 {
501 u8 * sB = (u8 *)sP;
502 u16* dB = (u16*)dP;
503
504 for (s32 x = 0; x < sN; ++x)
505 {
506 s32 r = sB[0] >> 3;
507 s32 g = sB[1] >> 3;
508 s32 b = sB[2] >> 3;
509
510 dB[0] = (0x8000) | (r << 10) | (g << 5) | (b);
511
512 sB += 3;
513 dB += 1;
514 }
515 }
516
convert_B8G8R8toA8R8G8B8(const void * sP,s32 sN,void * dP)517 void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP)
518 {
519 u8* sB = (u8* )sP;
520 u32* dB = (u32*)dP;
521
522 for (s32 x = 0; x < sN; ++x)
523 {
524 *dB = 0xff000000 | (sB[2]<<16) | (sB[1]<<8) | sB[0];
525
526 sB += 3;
527 ++dB;
528 }
529 }
530
convert_A8R8G8B8toR8G8B8A8(const void * sP,s32 sN,void * dP)531 void CColorConverter::convert_A8R8G8B8toR8G8B8A8(const void* sP, s32 sN, void* dP)
532 {
533 const u32* sB = (const u32*)sP;
534 u32* dB = (u32*)dP;
535
536 for (s32 x = 0; x < sN; ++x)
537 {
538 *dB++ = (*sB<<8) | (*sB>>24);
539 ++sB;
540 }
541 }
542
convert_A8R8G8B8toA8B8G8R8(const void * sP,s32 sN,void * dP)543 void CColorConverter::convert_A8R8G8B8toA8B8G8R8(const void* sP, s32 sN, void* dP)
544 {
545 const u32* sB = (const u32*)sP;
546 u32* dB = (u32*)dP;
547
548 for (s32 x = 0; x < sN; ++x)
549 {
550 *dB++ = (*sB&0xff00ff00)|((*sB&0x00ff0000)>>16)|((*sB&0x000000ff)<<16);
551 ++sB;
552 }
553 }
554
convert_B8G8R8A8toA8R8G8B8(const void * sP,s32 sN,void * dP)555 void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP)
556 {
557 u8* sB = (u8*)sP;
558 u8* dB = (u8*)dP;
559
560 for (s32 x = 0; x < sN; ++x)
561 {
562 dB[0] = sB[3];
563 dB[1] = sB[2];
564 dB[2] = sB[1];
565 dB[3] = sB[0];
566
567 sB += 4;
568 dB += 4;
569 }
570
571 }
572
convert_R8G8B8toB8G8R8(const void * sP,s32 sN,void * dP)573 void CColorConverter::convert_R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP)
574 {
575 u8* sB = (u8*)sP;
576 u8* dB = (u8*)dP;
577
578 for (s32 x = 0; x < sN; ++x)
579 {
580 dB[2] = sB[0];
581 dB[1] = sB[1];
582 dB[0] = sB[2];
583
584 sB += 3;
585 dB += 3;
586 }
587 }
588
convert_R8G8B8toR5G6B5(const void * sP,s32 sN,void * dP)589 void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP)
590 {
591 u8 * sB = (u8 *)sP;
592 u16* dB = (u16*)dP;
593
594 for (s32 x = 0; x < sN; ++x)
595 {
596 s32 r = sB[0] >> 3;
597 s32 g = sB[1] >> 2;
598 s32 b = sB[2] >> 3;
599
600 dB[0] = (r << 11) | (g << 5) | (b);
601
602 sB += 3;
603 dB += 1;
604 }
605 }
606
convert_R5G6B5toR5G6B5(const void * sP,s32 sN,void * dP)607 void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP)
608 {
609 memcpy(dP, sP, sN * 2);
610 }
611
convert_R5G6B5toR8G8B8(const void * sP,s32 sN,void * dP)612 void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP)
613 {
614 u16* sB = (u16*)sP;
615 u8 * dB = (u8 *)dP;
616
617 for (s32 x = 0; x < sN; ++x)
618 {
619 dB[0] = (*sB & 0xf800) >> 8;
620 dB[1] = (*sB & 0x07e0) >> 3;
621 dB[2] = (*sB & 0x001f) << 3;
622
623 sB += 1;
624 dB += 3;
625 }
626 }
627
convert_R5G6B5toB8G8R8(const void * sP,s32 sN,void * dP)628 void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP)
629 {
630 u16* sB = (u16*)sP;
631 u8 * dB = (u8 *)dP;
632
633 for (s32 x = 0; x < sN; ++x)
634 {
635 dB[2] = (*sB & 0xf800) >> 8;
636 dB[1] = (*sB & 0x07e0) >> 3;
637 dB[0] = (*sB & 0x001f) << 3;
638
639 sB += 1;
640 dB += 3;
641 }
642 }
643
convert_R5G6B5toA8R8G8B8(const void * sP,s32 sN,void * dP)644 void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP)
645 {
646 u16* sB = (u16*)sP;
647 u32* dB = (u32*)dP;
648
649 for (s32 x = 0; x < sN; ++x)
650 *dB++ = R5G6B5toA8R8G8B8(*sB++);
651 }
652
convert_R5G6B5toA1R5G5B5(const void * sP,s32 sN,void * dP)653 void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP)
654 {
655 u16* sB = (u16*)sP;
656 u16* dB = (u16*)dP;
657
658 for (s32 x = 0; x < sN; ++x)
659 *dB++ = R5G6B5toA1R5G5B5(*sB++);
660 }
661
662
convert_viaFormat(const void * sP,ECOLOR_FORMAT sF,s32 sN,void * dP,ECOLOR_FORMAT dF)663 void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN,
664 void* dP, ECOLOR_FORMAT dF)
665 {
666 switch (sF)
667 {
668 case ECF_A1R5G5B5:
669 switch (dF)
670 {
671 case ECF_A1R5G5B5:
672 convert_A1R5G5B5toA1R5G5B5(sP, sN, dP);
673 break;
674 case ECF_R5G6B5:
675 convert_A1R5G5B5toR5G6B5(sP, sN, dP);
676 break;
677 case ECF_A8R8G8B8:
678 convert_A1R5G5B5toA8R8G8B8(sP, sN, dP);
679 break;
680 case ECF_R8G8B8:
681 convert_A1R5G5B5toR8G8B8(sP, sN, dP);
682 break;
683 #ifndef _DEBUG
684 default:
685 break;
686 #endif
687 }
688 break;
689 case ECF_R5G6B5:
690 switch (dF)
691 {
692 case ECF_A1R5G5B5:
693 convert_R5G6B5toA1R5G5B5(sP, sN, dP);
694 break;
695 case ECF_R5G6B5:
696 convert_R5G6B5toR5G6B5(sP, sN, dP);
697 break;
698 case ECF_A8R8G8B8:
699 convert_R5G6B5toA8R8G8B8(sP, sN, dP);
700 break;
701 case ECF_R8G8B8:
702 convert_R5G6B5toR8G8B8(sP, sN, dP);
703 break;
704 #ifndef _DEBUG
705 default:
706 break;
707 #endif
708 }
709 break;
710 case ECF_A8R8G8B8:
711 switch (dF)
712 {
713 case ECF_A1R5G5B5:
714 convert_A8R8G8B8toA1R5G5B5(sP, sN, dP);
715 break;
716 case ECF_R5G6B5:
717 convert_A8R8G8B8toR5G6B5(sP, sN, dP);
718 break;
719 case ECF_A8R8G8B8:
720 convert_A8R8G8B8toA8R8G8B8(sP, sN, dP);
721 break;
722 case ECF_R8G8B8:
723 convert_A8R8G8B8toR8G8B8(sP, sN, dP);
724 break;
725 #ifndef _DEBUG
726 default:
727 break;
728 #endif
729 }
730 break;
731 case ECF_R8G8B8:
732 switch (dF)
733 {
734 case ECF_A1R5G5B5:
735 convert_R8G8B8toA1R5G5B5(sP, sN, dP);
736 break;
737 case ECF_R5G6B5:
738 convert_R8G8B8toR5G6B5(sP, sN, dP);
739 break;
740 case ECF_A8R8G8B8:
741 convert_R8G8B8toA8R8G8B8(sP, sN, dP);
742 break;
743 case ECF_R8G8B8:
744 convert_R8G8B8toR8G8B8(sP, sN, dP);
745 break;
746 #ifndef _DEBUG
747 default:
748 break;
749 #endif
750 }
751 break;
752 default:
753 break;
754 }
755 }
756
757
758 } // end namespace video
759 } // end namespace irr
760