2 Copyright © 2011, The AROS Development Team. All rights reserved.
5 Desc: RGB pixel format conversion functions.
11 ULONG
Convert_RGB24_To_BGR032(APTR srcPixels
, ULONG srcMod
,
12 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
13 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
15 WORD x
, y
, src_step
, dst_step
;
16 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
17 UBYTE src_red
, src_green
, src_blue
;
19 src_step
= srcMod
- width
* 3;
20 dst_step
= dstMod
- width
* 4;
22 for(y
= 0; y
< height
; y
++)
24 for(x
= 0; x
< width
; x
++)
43 ULONG
Convert_BGR24_To_BGR032(APTR srcPixels
, ULONG srcMod
,
44 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
45 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
47 WORD x
, y
, src_step
, dst_step
;
48 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
49 UBYTE src_red
, src_green
, src_blue
;
51 src_step
= srcMod
- width
* 3;
52 dst_step
= dstMod
- width
* 4;
54 for(y
= 0; y
< height
; y
++)
56 for(x
= 0; x
< width
; x
++)
75 ULONG
Convert_RGB16_To_BGR032(APTR srcPixels
, ULONG srcMod
,
76 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
77 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
79 WORD x
, y
, src_step
, dst_step
;
80 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
81 UBYTE src_red
, src_green
, src_blue
;
83 src_step
= srcMod
- width
* 2;
84 dst_step
= dstMod
- width
* 4;
86 for(y
= 0; y
< height
; y
++)
88 for(x
= 0; x
< width
; x
++)
92 src_green
= src_red
<< 5 | src_blue
>> 3 & 0x1c;
109 ULONG
Convert_RGB16LE_To_BGR032(APTR srcPixels
, ULONG srcMod
,
110 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
111 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
113 WORD x
, y
, src_step
, dst_step
;
114 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
115 UBYTE src_red
, src_green
, src_blue
;
117 src_step
= srcMod
- width
* 2;
118 dst_step
= dstMod
- width
* 4;
120 for(y
= 0; y
< height
; y
++)
122 for(x
= 0; x
< width
; x
++)
126 src_green
= src_red
<< 5 | src_blue
>> 3 & 0x1c;
143 ULONG
Convert_BGR16_To_BGR032(APTR srcPixels
, ULONG srcMod
,
144 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
145 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
147 WORD x
, y
, src_step
, dst_step
;
148 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
149 UBYTE src_red
, src_green
, src_blue
;
151 src_step
= srcMod
- width
* 2;
152 dst_step
= dstMod
- width
* 4;
154 for(y
= 0; y
< height
; y
++)
156 for(x
= 0; x
< width
; x
++)
160 src_green
= src_blue
<< 5 | src_red
>> 3 & 0x1c;
177 ULONG
Convert_BGR16LE_To_BGR032(APTR srcPixels
, ULONG srcMod
,
178 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
179 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
181 WORD x
, y
, src_step
, dst_step
;
182 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
183 UBYTE src_red
, src_green
, src_blue
;
185 src_step
= srcMod
- width
* 2;
186 dst_step
= dstMod
- width
* 4;
188 for(y
= 0; y
< height
; y
++)
190 for(x
= 0; x
< width
; x
++)
194 src_green
= src_blue
<< 5 | src_red
>> 3 & 0x1c;
211 ULONG
Convert_ARGB32_To_BGR032(APTR srcPixels
, ULONG srcMod
,
212 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
213 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
215 WORD x
, y
, src_step
, dst_step
;
216 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
217 UBYTE src_red
, src_green
, src_blue
;
219 src_step
= srcMod
- width
* 4;
220 dst_step
= dstMod
- width
* 4;
222 for(y
= 0; y
< height
; y
++)
224 for(x
= 0; x
< width
; x
++)
244 ULONG
Convert_BGRA32_To_BGR032(APTR srcPixels
, ULONG srcMod
,
245 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
246 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
248 WORD x
, y
, src_step
, dst_step
;
249 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
250 UBYTE src_red
, src_green
, src_blue
;
252 src_step
= srcMod
- width
* 4;
253 dst_step
= dstMod
- width
* 4;
255 for(y
= 0; y
< height
; y
++)
257 for(x
= 0; x
< width
; x
++)
277 ULONG
Convert_RGBA32_To_BGR032(APTR srcPixels
, ULONG srcMod
,
278 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
279 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
281 WORD x
, y
, src_step
, dst_step
;
282 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
283 UBYTE src_red
, src_green
, src_blue
;
285 src_step
= srcMod
- width
* 4;
286 dst_step
= dstMod
- width
* 4;
288 for(y
= 0; y
< height
; y
++)
290 for(x
= 0; x
< width
; x
++)
310 ULONG
Convert_ABGR32_To_BGR032(APTR srcPixels
, ULONG srcMod
,
311 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
312 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
314 WORD x
, y
, src_step
, dst_step
;
315 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
316 UBYTE src_red
, src_green
, src_blue
;
318 src_step
= srcMod
- width
* 4;
319 dst_step
= dstMod
- width
* 4;
321 for(y
= 0; y
< height
; y
++)
323 for(x
= 0; x
< width
; x
++)
343 ULONG
Convert_BGR032_To_ARGB32(APTR srcPixels
, ULONG srcMod
,
344 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
345 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
347 WORD x
, y
, src_step
, dst_step
;
348 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
349 UBYTE src_red
, src_green
, src_blue
;
351 src_step
= srcMod
- width
* 4;
352 dst_step
= dstMod
- width
* 4;
354 for(y
= 0; y
< height
; y
++)
356 for(x
= 0; x
< width
; x
++)
376 ULONG
Convert_RGB24_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
377 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
378 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
380 WORD x
, y
, src_step
, dst_step
;
381 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
382 UBYTE src_red
, src_green
, src_blue
;
384 src_step
= srcMod
- width
* 3;
385 dst_step
= dstMod
- width
* 2;
387 for(y
= 0; y
< height
; y
++)
389 for(x
= 0; x
< width
; x
++)
395 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
396 *q
++ = src_red
& 0xf8 | src_green
>> 5;
406 ULONG
Convert_BGR24_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
407 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
408 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
410 WORD x
, y
, src_step
, dst_step
;
411 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
412 UBYTE src_red
, src_green
, src_blue
;
414 src_step
= srcMod
- width
* 3;
415 dst_step
= dstMod
- width
* 2;
417 for(y
= 0; y
< height
; y
++)
419 for(x
= 0; x
< width
; x
++)
425 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
426 *q
++ = src_red
& 0xf8 | src_green
>> 5;
436 ULONG
Convert_RGB16_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
437 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
438 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
440 WORD x
, y
, src_step
, dst_step
;
441 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
442 UBYTE src_red
, src_blue
;
444 src_step
= srcMod
- width
* 2;
445 dst_step
= dstMod
- width
* 2;
447 for(y
= 0; y
< height
; y
++)
449 for(x
= 0; x
< width
; x
++)
465 ULONG
Convert_RGB16LE_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
466 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
467 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
469 WORD x
, y
, src_step
, dst_step
;
470 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
471 UBYTE src_red
, src_blue
;
473 src_step
= srcMod
- width
* 2;
474 dst_step
= dstMod
- width
* 2;
476 for(y
= 0; y
< height
; y
++)
478 for(x
= 0; x
< width
; x
++)
494 ULONG
Convert_BGR16_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
495 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
496 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
498 WORD x
, y
, src_step
, dst_step
;
499 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
500 UBYTE src_red
, src_green
, src_blue
;
502 src_step
= srcMod
- width
* 4;
503 dst_step
= dstMod
- width
* 2;
505 for(y
= 0; y
< height
; y
++)
507 for(x
= 0; x
< width
; x
++)
511 src_green
= src_blue
<< 5 | src_red
>> 3 & 0x1c;
515 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
516 *q
++ = src_red
& 0xf8 | src_green
>> 5;
526 ULONG
Convert_BGR16LE_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
527 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
528 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
530 WORD x
, y
, src_step
, dst_step
;
531 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
532 UBYTE src_red
, src_green
, src_blue
;
534 src_step
= srcMod
- width
* 4;
535 dst_step
= dstMod
- width
* 2;
537 for(y
= 0; y
< height
; y
++)
539 for(x
= 0; x
< width
; x
++)
543 src_green
= src_blue
<< 5 | src_red
>> 3 & 0x1c;
547 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
548 *q
++ = src_red
& 0xf8 | src_green
>> 5;
558 ULONG
Convert_ARGB32_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
559 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
560 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
562 WORD x
, y
, src_step
, dst_step
;
563 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
564 UBYTE src_red
, src_green
, src_blue
;
566 src_step
= srcMod
- width
* 4;
567 dst_step
= dstMod
- width
* 2;
569 for(y
= 0; y
< height
; y
++)
571 for(x
= 0; x
< width
; x
++)
578 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
579 *q
++ = src_red
& 0xf8 | src_green
>> 5;
589 ULONG
Convert_BGRA32_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
590 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
591 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
593 WORD x
, y
, src_step
, dst_step
;
594 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
595 UBYTE src_red
, src_green
, src_blue
;
597 src_step
= srcMod
- width
* 4;
598 dst_step
= dstMod
- width
* 2;
600 for(y
= 0; y
< height
; y
++)
602 for(x
= 0; x
< width
; x
++)
609 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
610 *q
++ = src_red
& 0xf8 | src_green
>> 5;
620 ULONG
Convert_RGBA32_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
621 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
622 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
624 WORD x
, y
, src_step
, dst_step
;
625 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
626 UBYTE src_red
, src_green
, src_blue
;
628 src_step
= srcMod
- width
* 4;
629 dst_step
= dstMod
- width
* 2;
631 for(y
= 0; y
< height
; y
++)
633 for(x
= 0; x
< width
; x
++)
640 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
641 *q
++ = src_red
& 0xf8 | src_green
>> 5;
651 ULONG
Convert_ABGR32_To_RGB16LE(APTR srcPixels
, ULONG srcMod
,
652 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
653 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
655 WORD x
, y
, src_step
, dst_step
;
656 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
657 UBYTE src_red
, src_green
, src_blue
;
659 src_step
= srcMod
- width
* 4;
660 dst_step
= dstMod
- width
* 2;
662 for(y
= 0; y
< height
; y
++)
664 for(x
= 0; x
< width
; x
++)
671 *q
++ = (src_green
<< 3) & 0xe0 | src_blue
>> 3;
672 *q
++ = src_red
& 0xf8 | src_green
>> 5;
682 ULONG
Convert_RGB16LE_To_ARGB32(APTR srcPixels
, ULONG srcMod
,
683 HIDDT_StdPixFmt srcPixFmt
, APTR dstPixels
, ULONG dstMod
,
684 HIDDT_StdPixFmt dstPixFmt
, ULONG width
, ULONG height
)
686 WORD x
, y
, src_step
, dst_step
;
687 UBYTE
*p
= srcPixels
, *q
= dstPixels
;
688 UBYTE src_red
, src_green
, src_blue
;
690 src_step
= srcMod
- width
* 2;
691 dst_step
= dstMod
- width
* 4;
693 for(y
= 0; y
< height
; y
++)
695 for(x
= 0; x
< width
; x
++)
699 src_green
= src_red
<< 5 | src_blue
>> 3 & 0x1c;