1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** GUIX Component */
16 /** */
17 /** Image Reader Management (Image Reader) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23 /* Include necessary system files. */
24
25 #include "gx_api.h"
26 #include "gx_system.h"
27 #include "gx_utility.h"
28 #include "gx_image_reader.h"
29
30 #if defined(GX_SOFTWARE_DECODER_SUPPORT)
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _gx_image_reader_8bit_alpha_read PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Kenneth Maxwell, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function reads 8bit alpha value from input pixelmap data. */
44 /* */
45 /* INPUT */
46 /* */
47 /* image_reader Image reader control block */
48 /* index Row index. */
49 /* pixel Retrieved pixel. */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* Completion Status */
54 /* */
55 /* CALLS */
56 /* */
57 /* None */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* _gx_image_reader_pixel_read_callback_set */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
68 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
69 /* resulting in version 6.1 */
70 /* */
71 /**************************************************************************/
_gx_image_reader_8bit_alpha_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)72 static UINT _gx_image_reader_8bit_alpha_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
73 {
74 GX_UBYTE *pLine;
75
76 pLine = image_reader -> gx_image_reader_getdata;
77 pLine += index;
78
79 pixel -> gx_pixel_red = 0;
80 pixel -> gx_pixel_green = 0;
81 pixel -> gx_pixel_blue = 0;
82 pixel -> gx_pixel_alpha = *pLine;
83
84 return GX_SUCCESS;
85 }
86
87 /**************************************************************************/
88 /* */
89 /* FUNCTION RELEASE */
90 /* */
91 /* _gx_image_reader_1bit_pixel_read PORTABLE C */
92 /* 6.1 */
93 /* AUTHOR */
94 /* */
95 /* Kenneth Maxwell, Microsoft Corporation */
96 /* */
97 /* DESCRIPTION */
98 /* */
99 /* This function reads a pixel from input pixelmap data structure. */
100 /* */
101 /* INPUT */
102 /* */
103 /* image_reader Image reader control block */
104 /* index Row index. */
105 /* pixel Retrieved pixel. */
106 /* */
107 /* OUTPUT */
108 /* */
109 /* Completion Status */
110 /* */
111 /* CALLS */
112 /* */
113 /* None */
114 /* */
115 /* CALLED BY */
116 /* */
117 /* _gx_image_reader_pixel_read_callback_set */
118 /* */
119 /* RELEASE HISTORY */
120 /* */
121 /* DATE NAME DESCRIPTION */
122 /* */
123 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
124 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
125 /* resulting in version 6.1 */
126 /* */
127 /**************************************************************************/
_gx_image_reader_1bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)128 static UINT _gx_image_reader_1bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
129 {
130 GX_UBYTE *pLine;
131 GX_COLOR *pal;
132 UINT palindex;
133
134 pLine = image_reader -> gx_image_reader_getdata;
135 pLine += (index >> 3);
136
137 palindex = *pLine;
138 palindex >>= (7 - (index & 0x7));
139 palindex &= 0x01;
140
141 if ((image_reader -> gx_image_reader_png_trans) &&
142 (palindex == image_reader -> gx_image_reader_png_trans[0]))
143 {
144 /* Transparent */
145 pixel -> gx_pixel_alpha = 0;
146 pixel -> gx_pixel_red = 0;
147 pixel -> gx_pixel_green = 0;
148 pixel -> gx_pixel_blue = 0;
149 }
150 else
151 {
152 pal = (GX_COLOR *)image_reader -> gx_image_reader_png_palette;
153
154 if (pal)
155 {
156 /* Palette */
157 if (palindex < image_reader -> gx_image_reader_png_palette_size)
158 {
159 pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
160 pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
161 pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
162 pixel -> gx_pixel_alpha = 0xff;
163 }
164 else
165 {
166 memset(pixel, 0, sizeof(GX_PIXEL));
167 }
168 }
169 else
170 {
171 /* Gray */
172 palindex *= 255;
173 pixel -> gx_pixel_red = (GX_UBYTE)palindex;
174 pixel -> gx_pixel_green = (GX_UBYTE)palindex;
175 pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
176 pixel -> gx_pixel_alpha = 0xff;
177 }
178 }
179
180 return GX_SUCCESS;
181 }
182
183 /**************************************************************************/
184 /* */
185 /* FUNCTION RELEASE */
186 /* */
187 /* _gx_image_reader_2bit_pixel_read PORTABLE C */
188 /* 6.1 */
189 /* AUTHOR */
190 /* */
191 /* Kenneth Maxwell, Microsoft Corporation */
192 /* */
193 /* DESCRIPTION */
194 /* */
195 /* This function reads a pixel from input pixelmap data structure. */
196 /* */
197 /* INPUT */
198 /* */
199 /* image_reader Image reader control block */
200 /* index Row index. */
201 /* pixel Retrieved pixel. */
202 /* */
203 /* OUTPUT */
204 /* */
205 /* Completion Status */
206 /* */
207 /* CALLS */
208 /* */
209 /* None */
210 /* */
211 /* CALLED BY */
212 /* */
213 /* _gx_image_reader_pixel_read_callback_set */
214 /* */
215 /* RELEASE HISTORY */
216 /* */
217 /* DATE NAME DESCRIPTION */
218 /* */
219 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
220 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
221 /* resulting in version 6.1 */
222 /* */
223 /**************************************************************************/
_gx_image_reader_2bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)224 static UINT _gx_image_reader_2bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
225 {
226 GX_UBYTE *pLine;
227 GX_COLOR *pal;
228 UINT palindex;
229
230 pLine = image_reader -> gx_image_reader_getdata;
231 pLine += (index >> 2);
232
233 palindex = *pLine;
234 palindex >>= (3 - (index & 0x3)) * 2;
235 palindex &= 0x03;
236
237 if ((image_reader -> gx_image_reader_png_trans) &&
238 (palindex == image_reader -> gx_image_reader_png_trans[0]))
239 {
240 /* Transparent */
241 pixel -> gx_pixel_alpha = 0;
242 pixel -> gx_pixel_red = 0;
243 pixel -> gx_pixel_green = 0;
244 pixel -> gx_pixel_blue = 0;
245 }
246 else
247 {
248 pal = image_reader -> gx_image_reader_png_palette;
249
250 if (pal)
251 {
252 /* Palette */
253 if (palindex < image_reader -> gx_image_reader_png_palette_size)
254 {
255 pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
256 pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
257 pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
258 pixel -> gx_pixel_alpha = 0xff;
259 }
260 else
261 {
262 memset(pixel, 0, sizeof(GX_PIXEL));
263 }
264 }
265 else
266 {
267 /* Gray */
268 palindex = palindex * 255 / 3;
269 pixel -> gx_pixel_red = (GX_UBYTE)palindex;
270 pixel -> gx_pixel_green = (GX_UBYTE)palindex;
271 pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
272 pixel -> gx_pixel_alpha = 0xff;
273 }
274 }
275
276 return GX_SUCCESS;
277 }
278
279
280 /**************************************************************************/
281 /* */
282 /* FUNCTION RELEASE */
283 /* */
284 /* _gx_image_reader_4bit_pixel_read PORTABLE C */
285 /* 6.1 */
286 /* AUTHOR */
287 /* */
288 /* Kenneth Maxwell, Microsoft Corporation */
289 /* */
290 /* DESCRIPTION */
291 /* */
292 /* This function reads a pixel from input pixelmap data structure. */
293 /* */
294 /* INPUT */
295 /* */
296 /* image_reader Image reader control block */
297 /* index Row index. */
298 /* pixel Retrieved pixel. */
299 /* */
300 /* OUTPUT */
301 /* */
302 /* Completion Status */
303 /* */
304 /* CALLS */
305 /* */
306 /* None */
307 /* */
308 /* CALLED BY */
309 /* */
310 /* _gx_image_reader_pixel_read_callback_set */
311 /* */
312 /* RELEASE HISTORY */
313 /* */
314 /* DATE NAME DESCRIPTION */
315 /* */
316 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
317 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
318 /* resulting in version 6.1 */
319 /* */
320 /**************************************************************************/
_gx_image_reader_4bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)321 static UINT _gx_image_reader_4bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
322 {
323 GX_UBYTE *pLine;
324 GX_COLOR *pal;
325 UINT palindex;
326
327 pLine = image_reader -> gx_image_reader_getdata;
328 pLine += (index >> 1);
329
330 palindex = *pLine;
331 palindex >>= (1 - (index & 0x01)) * 4;
332 palindex &= 0x0f;
333
334 if ((image_reader -> gx_image_reader_png_trans) &&
335 (palindex == image_reader -> gx_image_reader_png_trans[0]))
336 {
337 /* Transparent */
338 pixel -> gx_pixel_alpha = 0;
339 pixel -> gx_pixel_red = 0;
340 pixel -> gx_pixel_green = 0;
341 pixel -> gx_pixel_blue = 0;
342 }
343 else
344 {
345 pal = image_reader -> gx_image_reader_png_palette;
346
347 if (pal)
348 {
349 /* Pixel */
350 if (palindex < image_reader -> gx_image_reader_png_palette_size)
351 {
352 pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
353 pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
354 pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
355 pixel -> gx_pixel_alpha = 0xff;
356 }
357 else
358 {
359 memset(pixel, 0, sizeof(GX_PIXEL));
360 }
361 }
362 else
363 {
364 /* Gray */
365 palindex = palindex * 255 / 15;
366 pixel -> gx_pixel_red = (GX_UBYTE)palindex;
367 pixel -> gx_pixel_green = (GX_UBYTE)palindex;
368 pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
369 pixel -> gx_pixel_alpha = 0xff;
370 }
371 }
372
373 return GX_SUCCESS;
374 }
375
376 /**************************************************************************/
377 /* */
378 /* FUNCTION RELEASE */
379 /* */
380 /* _gx_image_reader_8bit_pixel_read PORTABLE C */
381 /* 6.1 */
382 /* AUTHOR */
383 /* */
384 /* Kenneth Maxwell, Microsoft Corporation */
385 /* */
386 /* DESCRIPTION */
387 /* */
388 /* This function reads a pixel from input pixelmap data structure. */
389 /* */
390 /* INPUT */
391 /* */
392 /* image_reader Image reader control block */
393 /* index Row index. */
394 /* pixel Retrieved pixel. */
395 /* */
396 /* OUTPUT */
397 /* */
398 /* Completion Status */
399 /* */
400 /* CALLS */
401 /* */
402 /* None */
403 /* */
404 /* CALLED BY */
405 /* */
406 /* _gx_image_reader_pixel_read_callback_set */
407 /* */
408 /* RELEASE HISTORY */
409 /* */
410 /* DATE NAME DESCRIPTION */
411 /* */
412 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
413 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
414 /* resulting in version 6.1 */
415 /* */
416 /**************************************************************************/
_gx_image_reader_8bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)417 static UINT _gx_image_reader_8bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
418 {
419 GX_COLOR *palette;
420 UINT palsize;
421 UINT palindex;
422
423 palindex = *(image_reader -> gx_image_reader_getdata + index);
424
425 if ((image_reader -> gx_image_reader_png_trans) &&
426 (palindex == image_reader -> gx_image_reader_png_trans[0]))
427 {
428 /* Transparent */
429 pixel -> gx_pixel_alpha = 0;
430 pixel -> gx_pixel_red = 0;
431 pixel -> gx_pixel_green = 0;
432 pixel -> gx_pixel_blue = 0;
433 }
434 else
435 {
436 palette = image_reader -> gx_image_reader_png_palette;
437 palsize = image_reader -> gx_image_reader_png_palette_size;
438
439 if (palette)
440 {
441 /* Palette */
442 if (palindex < palsize)
443 {
444 pixel -> gx_pixel_red = (GX_UBYTE)(palette[palindex] >> 16);
445 pixel -> gx_pixel_green = (GX_UBYTE)(palette[palindex] >> 8);
446 pixel -> gx_pixel_blue = (GX_UBYTE)palette[palindex];
447 pixel -> gx_pixel_alpha = 0xff;
448 }
449 else
450 {
451 memset(pixel, 0, sizeof(GX_PIXEL));
452 }
453 }
454 else
455 {
456 /* Gray */
457 pixel -> gx_pixel_red = (GX_UBYTE)palindex;
458 pixel -> gx_pixel_green = (GX_UBYTE)palindex;
459 pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
460 pixel -> gx_pixel_alpha = 0xff;
461 }
462 }
463
464 return GX_SUCCESS;
465 }
466
467 /**************************************************************************/
468 /* */
469 /* FUNCTION RELEASE */
470 /* */
471 /* _gx_image_reader_8bit_palette_pixel_read PORTABLE C */
472 /* 6.1 */
473 /* AUTHOR */
474 /* */
475 /* Kenneth Maxwell, Microsoft Corporation */
476 /* */
477 /* DESCRIPTION */
478 /* */
479 /* This function reads a pixel from input pixelmap data structure. */
480 /* */
481 /* INPUT */
482 /* */
483 /* image_reader Image reader control block */
484 /* index Row index. */
485 /* pixel Retrieved pixel. */
486 /* */
487 /* OUTPUT */
488 /* */
489 /* Completion Status */
490 /* */
491 /* CALLS */
492 /* */
493 /* None */
494 /* */
495 /* CALLED BY */
496 /* */
497 /* _gx_image_reader_pixel_read_callback_set */
498 /* */
499 /* RELEASE HISTORY */
500 /* */
501 /* DATE NAME DESCRIPTION */
502 /* */
503 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
504 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
505 /* resulting in version 6.1 */
506 /* */
507 /**************************************************************************/
_gx_image_reader_8bit_palette_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)508 static UINT _gx_image_reader_8bit_palette_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
509 {
510 GX_COLOR *palette = image_reader -> gx_image_reader_palette;
511 UINT palindex;
512
513 palindex = *(image_reader -> gx_image_reader_getdata + index);
514
515 if (palette)
516 {
517 /* Palette */
518 if ((image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) &&
519 (GX_TRANSPARENT_COLOR == palindex))
520 {
521 pixel -> gx_pixel_alpha = 0;
522 pixel -> gx_pixel_red = 0;
523 pixel -> gx_pixel_green = 0;
524 pixel -> gx_pixel_blue = 0;
525 }
526 else
527 {
528 pixel -> gx_pixel_red = (GX_UBYTE)(palette[palindex] >> 16);
529 pixel -> gx_pixel_green = (GX_UBYTE)(palette[palindex] >> 8);
530 pixel -> gx_pixel_blue = (GX_UBYTE)palette[palindex];
531 pixel -> gx_pixel_alpha = 0xff;
532 }
533 }
534 else
535 {
536 memset(pixel, 0, sizeof(GX_PIXEL));
537 }
538
539 return GX_SUCCESS;
540 }
541
542 /**************************************************************************/
543 /* */
544 /* FUNCTION RELEASE */
545 /* */
546 /* _gx_image_reader_16bit_gray_alpha_read PORTABLE C */
547 /* 6.1 */
548 /* AUTHOR */
549 /* */
550 /* Kenneth Maxwell, Microsoft Corporation */
551 /* */
552 /* DESCRIPTION */
553 /* */
554 /* This function reads a pixel from input pixelmap data structure. */
555 /* */
556 /* INPUT */
557 /* */
558 /* image_reader Image reader control block */
559 /* index Row index. */
560 /* pixel Retrieved pixel. */
561 /* */
562 /* OUTPUT */
563 /* */
564 /* Completion Status */
565 /* */
566 /* CALLS */
567 /* */
568 /* None */
569 /* */
570 /* CALLED BY */
571 /* */
572 /* _gx_image_reader_pixel_read_callback_set */
573 /* */
574 /* RELEASE HISTORY */
575 /* */
576 /* DATE NAME DESCRIPTION */
577 /* */
578 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
579 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
580 /* resulting in version 6.1 */
581 /* */
582 /**************************************************************************/
_gx_image_reader_16bit_gray_alpha_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)583 static UINT _gx_image_reader_16bit_gray_alpha_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
584 {
585 GX_UBYTE *pLine;
586
587 pLine = image_reader -> gx_image_reader_getdata;
588 pLine += (index << 1);
589
590 /* Trans is prohibited for this color types, since a full alpha channel is already present. */
591 pixel -> gx_pixel_red = *pLine;
592 pixel -> gx_pixel_green = *pLine;
593 pixel -> gx_pixel_blue = *pLine++;
594 pixel -> gx_pixel_alpha = *pLine;
595
596 return GX_SUCCESS;
597 }
598
599 /**************************************************************************/
600 /* */
601 /* FUNCTION RELEASE */
602 /* */
603 /* _gx_image_reader_32bit_gray_alpha_read PORTABLE C */
604 /* 6.1 */
605 /* AUTHOR */
606 /* */
607 /* Kenneth Maxwell, Microsoft Corporation */
608 /* */
609 /* DESCRIPTION */
610 /* */
611 /* This function reads a pixel from input pixelmap data structure. */
612 /* */
613 /* */
614 /* INPUT */
615 /* */
616 /* image_reader Image reader control block */
617 /* index Row index. */
618 /* pixel Retrieved pixel. */
619 /* */
620 /* OUTPUT */
621 /* */
622 /* Completion Status */
623 /* */
624 /* CALLS */
625 /* */
626 /* None */
627 /* */
628 /* CALLED BY */
629 /* */
630 /* _gx_image_reader_pixel_read_callback_set */
631 /* */
632 /* RELEASE HISTORY */
633 /* */
634 /* DATE NAME DESCRIPTION */
635 /* */
636 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
637 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
638 /* resulting in version 6.1 */
639 /* */
640 /**************************************************************************/
_gx_image_reader_32bit_gray_alpha_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)641 static UINT _gx_image_reader_32bit_gray_alpha_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
642 {
643 GX_UBYTE *pLine;
644
645 pLine = image_reader -> gx_image_reader_getdata;
646 pLine += (index << 2);
647
648 pixel -> gx_pixel_red = *pLine;
649 pixel -> gx_pixel_green = pixel -> gx_pixel_red;
650 pixel -> gx_pixel_blue = pixel -> gx_pixel_red;
651 pLine += 2;
652 pixel -> gx_pixel_alpha = (GX_UBYTE)*pLine;
653
654 return GX_SUCCESS;
655 }
656
657 /**************************************************************************/
658 /* */
659 /* FUNCTION RELEASE */
660 /* */
661 /* _gx_image_reader_24bit_pixel_read PORTABLE C */
662 /* 6.1 */
663 /* AUTHOR */
664 /* */
665 /* Kenneth Maxwell, Microsoft Corporation */
666 /* */
667 /* DESCRIPTION */
668 /* */
669 /* This function reads a pixel from input pixelmap data structure. */
670 /* */
671 /* INPUT */
672 /* */
673 /* image_reader Image reader control block */
674 /* index Row index. */
675 /* pixel Retrieved pixel. */
676 /* */
677 /* OUTPUT */
678 /* */
679 /* Completion Status */
680 /* */
681 /* CALLS */
682 /* */
683 /* None */
684 /* */
685 /* CALLED BY */
686 /* */
687 /* _gx_image_reader_pixel_read_callback_set */
688 /* */
689 /* RELEASE HISTORY */
690 /* */
691 /* DATE NAME DESCRIPTION */
692 /* */
693 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
694 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
695 /* resulting in version 6.1 */
696 /* */
697 /**************************************************************************/
_gx_image_reader_24bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)698 static UINT _gx_image_reader_24bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
699 {
700 GX_UBYTE *pLine;
701 GX_COLOR *pTrans = image_reader -> gx_image_reader_png_trans;
702
703 pLine = image_reader -> gx_image_reader_getdata;
704 pLine += index * 3;
705
706 pixel -> gx_pixel_red = *pLine++;
707 pixel -> gx_pixel_green = *pLine++;
708 pixel -> gx_pixel_blue = *pLine;
709
710 if ((pTrans) &&
711 (pixel -> gx_pixel_red == pTrans[0]) &&
712 (pixel -> gx_pixel_green == pTrans[1]) &&
713 (pixel -> gx_pixel_blue == pTrans[2]))
714 {
715 pixel -> gx_pixel_alpha = 0;
716 }
717 else
718 {
719 pixel -> gx_pixel_alpha = 0xff;
720 }
721
722 return GX_SUCCESS;
723 }
724
725 /**************************************************************************/
726 /* */
727 /* FUNCTION RELEASE */
728 /* */
729 /* _gx_image_reader_48bit_pixel_read PORTABLE C */
730 /* 6.1 */
731 /* AUTHOR */
732 /* */
733 /* Kenneth Maxwell, Microsoft Corporation */
734 /* */
735 /* DESCRIPTION */
736 /* */
737 /* This function reads a pixel from input pixelmap data structure. */
738 /* */
739 /* INPUT */
740 /* */
741 /* image_reader Image reader control block */
742 /* index Row index. */
743 /* pixel Retrieved pixel. */
744 /* */
745 /* OUTPUT */
746 /* */
747 /* Completion Status */
748 /* */
749 /* CALLS */
750 /* */
751 /* None */
752 /* */
753 /* CALLED BY */
754 /* */
755 /* _gx_image_reader_pixel_read_callback_set */
756 /* */
757 /* RELEASE HISTORY */
758 /* */
759 /* DATE NAME DESCRIPTION */
760 /* */
761 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
762 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
763 /* resulting in version 6.1 */
764 /* */
765 /**************************************************************************/
_gx_image_reader_48bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)766 static UINT _gx_image_reader_48bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
767 {
768 GX_UBYTE *pLine;
769 GX_COLOR *pTrans = image_reader -> gx_image_reader_png_trans;
770
771 pLine = image_reader -> gx_image_reader_getdata;
772 pLine += index * 6;
773
774 pixel -> gx_pixel_red = *pLine;
775 pLine += 2;
776 pixel -> gx_pixel_green = *pLine;
777 pLine += 2;
778 pixel -> gx_pixel_blue = *pLine;
779
780 if ((pTrans) &&
781 (pixel -> gx_pixel_red == (GX_UBYTE)pTrans[0]) &&
782 (pixel -> gx_pixel_green == (GX_UBYTE)pTrans[1]) &&
783 (pixel -> gx_pixel_blue == (GX_UBYTE)pTrans[2]))
784 {
785 pixel -> gx_pixel_alpha = 0;
786 }
787 else
788 {
789 pixel -> gx_pixel_alpha = 0xff;
790 }
791
792 return GX_SUCCESS;
793 }
794
795 /**************************************************************************/
796 /* */
797 /* FUNCTION RELEASE */
798 /* */
799 /* _gx_image_reader_64bit_pixel_read PORTABLE C */
800 /* 6.1 */
801 /* AUTHOR */
802 /* */
803 /* Kenneth Maxwell, Microsoft Corporation */
804 /* */
805 /* DESCRIPTION */
806 /* */
807 /* This function reads a pixel from input pixelmap data structure. */
808 /* */
809 /* INPUT */
810 /* */
811 /* image_reader Image reader control block */
812 /* index Row index. */
813 /* pixel Retrieved pixel. */
814 /* */
815 /* OUTPUT */
816 /* */
817 /* Completion Status */
818 /* */
819 /* CALLS */
820 /* */
821 /* None */
822 /* */
823 /* CALLED BY */
824 /* */
825 /* _gx_image_reader_pixel_read_callback_set */
826 /* */
827 /* RELEASE HISTORY */
828 /* */
829 /* DATE NAME DESCRIPTION */
830 /* */
831 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
832 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
833 /* resulting in version 6.1 */
834 /* */
835 /**************************************************************************/
_gx_image_reader_64bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)836 static UINT _gx_image_reader_64bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
837 {
838 GX_UBYTE *pLine;
839
840 pLine = image_reader -> gx_image_reader_getdata;
841 pLine += (index << 3);
842
843 pixel -> gx_pixel_red = *pLine;
844 pLine += 2;
845 pixel -> gx_pixel_green = *pLine;
846 pLine += 2;
847 pixel -> gx_pixel_blue = *pLine;
848 pLine += 2;
849 pixel -> gx_pixel_alpha = *pLine;
850
851 return GX_SUCCESS;
852 }
853
854 /**************************************************************************/
855 /* */
856 /* FUNCTION RELEASE */
857 /* */
858 /* _gx_image_reader_32argb_pixel_read PORTABLE C */
859 /* 6.1 */
860 /* AUTHOR */
861 /* */
862 /* Kenneth Maxwell, Microsoft Corporation */
863 /* */
864 /* DESCRIPTION */
865 /* */
866 /* This function reads a pixel from input pixelmap data structure. */
867 /* */
868 /* INPUT */
869 /* */
870 /* image_reader Image reader control block */
871 /* index Row index. */
872 /* pixel Retrieved pixel. */
873 /* */
874 /* OUTPUT */
875 /* */
876 /* Completion Status */
877 /* */
878 /* CALLS */
879 /* */
880 /* None */
881 /* */
882 /* CALLED BY */
883 /* */
884 /* _gx_image_reader_pixel_read_callback_set */
885 /* */
886 /* RELEASE HISTORY */
887 /* */
888 /* DATE NAME DESCRIPTION */
889 /* */
890 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
891 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
892 /* resulting in version 6.1 */
893 /* */
894 /**************************************************************************/
_gx_image_reader_32argb_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)895 static UINT _gx_image_reader_32argb_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
896 {
897 GX_COLOR *pLine;
898
899 pLine = (GX_COLOR *)image_reader -> gx_image_reader_getdata;
900 pLine += index;
901
902 pixel -> gx_pixel_alpha = (GX_UBYTE)((*pLine) >> 24);
903 pixel -> gx_pixel_red = (GX_UBYTE)((*pLine) >> 16);
904 pixel -> gx_pixel_green = (GX_UBYTE)((*pLine) >> 8);
905 pixel -> gx_pixel_blue = (GX_UBYTE)(*pLine);
906
907 return GX_SUCCESS;
908 }
909
910 /**************************************************************************/
911 /* */
912 /* FUNCTION RELEASE */
913 /* */
914 /* _gx_image_reader_32bit_pixel_read PORTABLE C */
915 /* 6.1 */
916 /* AUTHOR */
917 /* */
918 /* Kenneth Maxwell, Microsoft Corporation */
919 /* */
920 /* DESCRIPTION */
921 /* */
922 /* This function reads a pixel from input pixelmap data structure. */
923 /* */
924 /* INPUT */
925 /* */
926 /* image_reader Image reader control block */
927 /* index Row index. */
928 /* pixel Retrieved pixel. */
929 /* */
930 /* OUTPUT */
931 /* */
932 /* Completion Status */
933 /* */
934 /* CALLS */
935 /* */
936 /* None */
937 /* */
938 /* CALLED BY */
939 /* */
940 /* _gx_image_reader_pixel_read_callback_set */
941 /* */
942 /* RELEASE HISTORY */
943 /* */
944 /* DATE NAME DESCRIPTION */
945 /* */
946 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
947 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
948 /* resulting in version 6.1 */
949 /* */
950 /**************************************************************************/
_gx_image_reader_32bit_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)951 static UINT _gx_image_reader_32bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
952 {
953 GX_UBYTE *pget;
954
955 pget = (GX_UBYTE *)image_reader -> gx_image_reader_getdata;
956 pget += (index << 2);
957
958 pixel -> gx_pixel_red = *pget++;
959 pixel -> gx_pixel_green = *pget++;
960 pixel -> gx_pixel_blue = *pget++;
961 pixel -> gx_pixel_alpha = *pget++;
962
963 return GX_SUCCESS;
964 }
965
966 /**************************************************************************/
967 /* */
968 /* FUNCTION RELEASE */
969 /* */
970 /* _gx_image_reader_16bit_gray_read PORTABLE C */
971 /* 6.1 */
972 /* AUTHOR */
973 /* */
974 /* Kenneth Maxwell, Microsoft Corporation */
975 /* */
976 /* DESCRIPTION */
977 /* */
978 /* This function reads a pixel from input pixelmap data structure. */
979 /* */
980 /* INPUT */
981 /* */
982 /* image_reader Image reader control block */
983 /* index Row index. */
984 /* pixel Retrieved pixel. */
985 /* */
986 /* OUTPUT */
987 /* */
988 /* Completion Status */
989 /* */
990 /* CALLS */
991 /* */
992 /* None */
993 /* */
994 /* CALLED BY */
995 /* */
996 /* _gx_image_reader_pixel_read_callback_set */
997 /* */
998 /* RELEASE HISTORY */
999 /* */
1000 /* DATE NAME DESCRIPTION */
1001 /* */
1002 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1003 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1004 /* resulting in version 6.1 */
1005 /* */
1006 /**************************************************************************/
_gx_image_reader_16bit_gray_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1007 static UINT _gx_image_reader_16bit_gray_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1008 {
1009 GX_UBYTE *pget;
1010
1011 pget = (GX_UBYTE *)image_reader -> gx_image_reader_getdata;
1012 pget += (index << 1);
1013
1014 if ((image_reader -> gx_image_reader_png_trans) &&
1015 ((*pget) == (GX_UBYTE)image_reader -> gx_image_reader_png_trans[0]))
1016 {
1017 pixel -> gx_pixel_alpha = 0;
1018 pixel -> gx_pixel_red = 0;
1019 pixel -> gx_pixel_green = 0;
1020 pixel -> gx_pixel_blue = 0;
1021 }
1022 else
1023 {
1024 pixel -> gx_pixel_red = *pget;
1025 pixel -> gx_pixel_green = *pget;
1026 pixel -> gx_pixel_blue = *pget;
1027 pixel -> gx_pixel_alpha = 0xff;
1028 }
1029
1030 return GX_SUCCESS;
1031 }
1032
1033 /**************************************************************************/
1034 /* */
1035 /* FUNCTION RELEASE */
1036 /* */
1037 /* _gx_image_reader_565rgb_pixel_read PORTABLE C */
1038 /* 6.1 */
1039 /* AUTHOR */
1040 /* */
1041 /* Kenneth Maxwell, Microsoft Corporation */
1042 /* */
1043 /* DESCRIPTION */
1044 /* */
1045 /* This function reads a pixel from input pixelmap data structure. */
1046 /* */
1047 /* INPUT */
1048 /* */
1049 /* image_reader Image reader control block */
1050 /* index Row index. */
1051 /* pixel Retrieved pixel. */
1052 /* */
1053 /* OUTPUT */
1054 /* */
1055 /* Completion Status */
1056 /* */
1057 /* CALLS */
1058 /* */
1059 /* None */
1060 /* */
1061 /* CALLED BY */
1062 /* */
1063 /* _gx_image_reader_pixel_read_callback_set */
1064 /* */
1065 /* RELEASE HISTORY */
1066 /* */
1067 /* DATE NAME DESCRIPTION */
1068 /* */
1069 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1070 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1071 /* resulting in version 6.1 */
1072 /* */
1073 /**************************************************************************/
_gx_image_reader_565rgb_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1074 static UINT _gx_image_reader_565rgb_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1075 {
1076 USHORT *pLine;
1077 GX_UBYTE *pAlpha;
1078
1079 pLine = (USHORT *)image_reader -> gx_image_reader_getdata;
1080 pLine += index;
1081
1082 pixel -> gx_pixel_red = (GX_UBYTE)(((*pLine) & 0xf800) >> 8);
1083 pixel -> gx_pixel_green = (GX_UBYTE)(((*pLine) & 0x07e0) >> 3);
1084 pixel -> gx_pixel_blue = (GX_UBYTE)(((*pLine) & 0x001f) << 3);
1085
1086 if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA)
1087 {
1088 pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_getauxdata;
1089 pAlpha += index;
1090
1091 pixel -> gx_pixel_alpha = (*pAlpha);
1092 }
1093 else
1094 {
1095 pixel -> gx_pixel_alpha = 0;
1096 }
1097
1098 return GX_SUCCESS;
1099 }
1100
1101 /**************************************************************************/
1102 /* */
1103 /* FUNCTION RELEASE */
1104 /* */
1105 /* _gx_image_reader_1555xrgb_pixel_read PORTABLE C */
1106 /* 6.1 */
1107 /* AUTHOR */
1108 /* */
1109 /* Kenneth Maxwell, Microsoft Corporation */
1110 /* */
1111 /* DESCRIPTION */
1112 /* */
1113 /* This function reads an 1555xrgb format pixel from input pixelmap */
1114 /* data structure. */
1115 /* */
1116 /* INPUT */
1117 /* */
1118 /* image_reader Image reader control block */
1119 /* index Row index. */
1120 /* pixel Retrieved pixel. */
1121 /* */
1122 /* OUTPUT */
1123 /* */
1124 /* Completion Status */
1125 /* */
1126 /* CALLS */
1127 /* */
1128 /* None */
1129 /* */
1130 /* CALLED BY */
1131 /* */
1132 /* _gx_image_reader_pixel_read_callback_set */
1133 /* */
1134 /* RELEASE HISTORY */
1135 /* */
1136 /* DATE NAME DESCRIPTION */
1137 /* */
1138 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1139 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1140 /* resulting in version 6.1 */
1141 /* */
1142 /**************************************************************************/
_gx_image_reader_1555xrgb_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1143 static UINT _gx_image_reader_1555xrgb_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1144 {
1145 USHORT *pLine;
1146 GX_UBYTE *pAlpha;
1147
1148 pLine = (USHORT *)image_reader -> gx_image_reader_getdata;
1149 pLine += index;
1150
1151 pixel -> gx_pixel_red = (GX_UBYTE)(((*pLine) & 0x7c00) >> 7);
1152 pixel -> gx_pixel_green = (GX_UBYTE)(((*pLine) & 0x03e0) >> 2);
1153 pixel -> gx_pixel_blue = (GX_UBYTE)(((*pLine) & 0x001f) << 3);
1154
1155 if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA)
1156 {
1157 pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_getauxdata;
1158 pAlpha += index;
1159
1160 pixel -> gx_pixel_alpha = (*pAlpha);
1161 }
1162 else
1163 {
1164 pixel -> gx_pixel_alpha = 0;
1165 }
1166
1167 return GX_SUCCESS;
1168 }
1169
1170 /**************************************************************************/
1171 /* */
1172 /* FUNCTION RELEASE */
1173 /* */
1174 /* _gx_image_reader_4444argb_pixel_read PORTABLE C */
1175 /* 6.1 */
1176 /* AUTHOR */
1177 /* */
1178 /* Kenneth Maxwell, Microsoft Corporation */
1179 /* */
1180 /* DESCRIPTION */
1181 /* */
1182 /* This function reads an 4444argb format pixel from input pixelmap */
1183 /* data structure. */
1184 /* */
1185 /* INPUT */
1186 /* */
1187 /* image_reader Image reader control block */
1188 /* index Row index. */
1189 /* pixel Retrieved pixel. */
1190 /* */
1191 /* OUTPUT */
1192 /* */
1193 /* Completion Status */
1194 /* */
1195 /* CALLS */
1196 /* */
1197 /* None */
1198 /* */
1199 /* CALLED BY */
1200 /* */
1201 /* _gx_image_reader_pixel_read_callback_set */
1202 /* */
1203 /* RELEASE HISTORY */
1204 /* */
1205 /* DATE NAME DESCRIPTION */
1206 /* */
1207 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1208 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1209 /* resulting in version 6.1 */
1210 /* */
1211 /**************************************************************************/
_gx_image_reader_4444argb_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1212 static UINT _gx_image_reader_4444argb_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1213 {
1214 USHORT color;
1215 const USHORT *data = (USHORT *)(image_reader -> gx_image_reader_getdata);
1216
1217 color = *(data + index);
1218
1219 pixel -> gx_pixel_alpha = (GX_UBYTE)((color & 0xf000) >> 8);
1220 pixel -> gx_pixel_red = (GX_UBYTE)((color & 0xf00) >> 4);
1221 pixel -> gx_pixel_green = (GX_UBYTE)(color & 0xf0);
1222 pixel -> gx_pixel_blue = (GX_UBYTE)((color & 0xf) << 4);
1223
1224 return GX_SUCCESS;
1225 }
1226
1227 /**************************************************************************/
1228 /* */
1229 /* FUNCTION RELEASE */
1230 /* */
1231 /* _gx_image_reader_4bit_grayscale_pixel_read PORTABLE C */
1232 /* 6.1 */
1233 /* AUTHOR */
1234 /* */
1235 /* Kenneth Maxwell, Microsoft Corporation */
1236 /* */
1237 /* DESCRIPTION */
1238 /* */
1239 /* This function reads an 4bit grayscale format pixel (no transparency)*/
1240 /* from input pixelmap data structure. */
1241 /* */
1242 /* INPUT */
1243 /* */
1244 /* image_reader Image reader control block */
1245 /* index Row index. */
1246 /* pixel Retrieved pixel. */
1247 /* */
1248 /* OUTPUT */
1249 /* */
1250 /* Completion Status */
1251 /* */
1252 /* CALLS */
1253 /* */
1254 /* None */
1255 /* */
1256 /* CALLED BY */
1257 /* */
1258 /* _gx_image_reader_pixel_read_callback_set */
1259 /* */
1260 /* RELEASE HISTORY */
1261 /* */
1262 /* DATE NAME DESCRIPTION */
1263 /* */
1264 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1265 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1266 /* resulting in version 6.1 */
1267 /* */
1268 /**************************************************************************/
_gx_image_reader_4bit_grayscale_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1269 static UINT _gx_image_reader_4bit_grayscale_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1270 {
1271 GX_UBYTE color;
1272
1273 color = *(image_reader -> gx_image_reader_getdata + (index >> 1));
1274
1275 if (index & 1)
1276 {
1277 color &= 0x0f;
1278 }
1279 else
1280 {
1281 color &= 0xf0;
1282 color >>= 4;
1283 }
1284
1285 color |= (GX_UBYTE)(color << 4);
1286 pixel -> gx_pixel_red = color;
1287 pixel -> gx_pixel_green = color;
1288 pixel -> gx_pixel_blue = color;
1289 pixel -> gx_pixel_alpha = 0xff;
1290
1291 return GX_SUCCESS;
1292 }
1293
1294 /**************************************************************************/
1295 /* */
1296 /* FUNCTION RELEASE */
1297 /* */
1298 /* _gx_image_reader_4bit_grayscale_transparent_read PORTABLE C */
1299 /* 6.1 */
1300 /* AUTHOR */
1301 /* */
1302 /* Kenneth Maxwell, Microsoft Corporation */
1303 /* */
1304 /* DESCRIPTION */
1305 /* */
1306 /* This function reads an 4bit grayscale format pixel */
1307 /* (with transparency)from input pixelmap data structure. */
1308 /* */
1309 /* INPUT */
1310 /* */
1311 /* image_reader Image reader control block */
1312 /* index Row index. */
1313 /* pixel Retrieved pixel. */
1314 /* */
1315 /* OUTPUT */
1316 /* */
1317 /* Completion Status */
1318 /* */
1319 /* CALLS */
1320 /* */
1321 /* None */
1322 /* */
1323 /* CALLED BY */
1324 /* */
1325 /* _gx_image_reader_pixel_read_callback_set */
1326 /* */
1327 /* RELEASE HISTORY */
1328 /* */
1329 /* DATE NAME DESCRIPTION */
1330 /* */
1331 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1332 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1333 /* resulting in version 6.1 */
1334 /* */
1335 /**************************************************************************/
_gx_image_reader_4bit_grayscale_transparent_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1336 static UINT _gx_image_reader_4bit_grayscale_transparent_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1337 {
1338 const GX_UBYTE *data = image_reader -> gx_image_reader_getdata;
1339 const GX_UBYTE *auxdata = image_reader -> gx_image_reader_getauxdata;
1340 INT aux_index = (index >> 3);
1341 INT color_index = (index >> 1);
1342 GX_UBYTE color = *(data + color_index);
1343 GX_UBYTE transparency = *(auxdata + aux_index);
1344
1345 /* Get transparent mask. */
1346 transparency = (GX_UBYTE)(transparency >> (7 - (index & 0x07)));
1347
1348 if (transparency & 0x01)
1349 {
1350 color = 0;
1351 pixel -> gx_pixel_alpha = 0;
1352 }
1353 else
1354 {
1355 if (index & 1)
1356 {
1357 color &= 0xf;
1358 }
1359 else
1360 {
1361 color &= 0xf0;
1362 color >>= 4;
1363 }
1364 color = (GX_UBYTE)(color | color << 4);
1365 pixel -> gx_pixel_alpha = 0xff;
1366 }
1367
1368 pixel -> gx_pixel_red = color;
1369 pixel -> gx_pixel_green = color;
1370 pixel -> gx_pixel_blue = color;
1371
1372 return GX_SUCCESS;
1373 }
1374
1375 /**************************************************************************/
1376 /* */
1377 /* FUNCTION RELEASE */
1378 /* */
1379 /* _gx_image_reader_1bpp_pixel_read PORTABLE C */
1380 /* 6.1 */
1381 /* AUTHOR */
1382 /* */
1383 /* Kenneth Maxwell, Microsoft Corporation */
1384 /* */
1385 /* DESCRIPTION */
1386 /* */
1387 /* This function reads an 1bpp format pixel (no transparency) from */
1388 /* input pixelmap data structure. */
1389 /* */
1390 /* INPUT */
1391 /* */
1392 /* image_reader Image reader control block */
1393 /* index Row index. */
1394 /* pixel Retrieved pixel. */
1395 /* */
1396 /* OUTPUT */
1397 /* */
1398 /* Completion Status */
1399 /* */
1400 /* CALLS */
1401 /* */
1402 /* None */
1403 /* */
1404 /* CALLED BY */
1405 /* */
1406 /* _gx_image_reader_pixel_read_callback_set */
1407 /* */
1408 /* RELEASE HISTORY */
1409 /* */
1410 /* DATE NAME DESCRIPTION */
1411 /* */
1412 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1413 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1414 /* resulting in version 6.1 */
1415 /* */
1416 /**************************************************************************/
_gx_image_reader_1bpp_pixel_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1417 static UINT _gx_image_reader_1bpp_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1418 {
1419 GX_UBYTE color;
1420
1421 color = *(image_reader -> gx_image_reader_getdata + (index >> 3));
1422
1423 if (color & (0x80 >> (index & 0x07)))
1424 {
1425 pixel -> gx_pixel_red = 0xff;
1426 pixel -> gx_pixel_green = 0xff;
1427 pixel -> gx_pixel_blue = 0xff;
1428 }
1429 else
1430 {
1431 pixel -> gx_pixel_red = 0;
1432 pixel -> gx_pixel_green = 0;
1433 pixel -> gx_pixel_blue = 0;
1434 }
1435 pixel -> gx_pixel_alpha = 0xff;
1436
1437 return GX_SUCCESS;
1438 }
1439
1440 /**************************************************************************/
1441 /* */
1442 /* FUNCTION RELEASE */
1443 /* */
1444 /* _gx_image_reader_1bpp_transparent_read PORTABLE C */
1445 /* 6.1 */
1446 /* AUTHOR */
1447 /* */
1448 /* Kenneth Maxwell, Microsoft Corporation */
1449 /* */
1450 /* DESCRIPTION */
1451 /* */
1452 /* This function reads an 1bpp format pixel (no transparency) from */
1453 /* input pixelmap data structure. */
1454 /* */
1455 /* INPUT */
1456 /* */
1457 /* image_reader Image reader control block */
1458 /* index Row index. */
1459 /* pixel Retrieved pixel. */
1460 /* */
1461 /* OUTPUT */
1462 /* */
1463 /* Completion Status */
1464 /* */
1465 /* CALLS */
1466 /* */
1467 /* None */
1468 /* */
1469 /* CALLED BY */
1470 /* */
1471 /* _gx_image_reader_pixel_read_callback_set */
1472 /* */
1473 /* RELEASE HISTORY */
1474 /* */
1475 /* DATE NAME DESCRIPTION */
1476 /* */
1477 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1478 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1479 /* resulting in version 6.1 */
1480 /* */
1481 /**************************************************************************/
_gx_image_reader_1bpp_transparent_read(GX_IMAGE_READER * image_reader,INT index,GX_PIXEL * pixel)1482 static UINT _gx_image_reader_1bpp_transparent_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1483 {
1484 GX_UBYTE color;
1485
1486 color = *(image_reader -> gx_image_reader_getdata + (index >> 2));
1487
1488 if (color & (0x40 >> ((index & 0x03) << 1)))
1489 {
1490 if (color & (0x80 >> ((index & 0x03) << 1)))
1491 {
1492 pixel -> gx_pixel_red = 0xff;
1493 pixel -> gx_pixel_green = 0xff;
1494 pixel -> gx_pixel_blue = 0xff;
1495 }
1496 else
1497 {
1498 pixel -> gx_pixel_red = 0;
1499 pixel -> gx_pixel_green = 0;
1500 pixel -> gx_pixel_blue = 0;
1501 }
1502 pixel -> gx_pixel_alpha = 0xff;
1503 }
1504 else
1505 {
1506 pixel -> gx_pixel_red = 0;
1507 pixel -> gx_pixel_green = 0;
1508 pixel -> gx_pixel_blue = 0;
1509 pixel -> gx_pixel_alpha = 0;
1510 }
1511
1512 return GX_SUCCESS;
1513 }
1514
1515
1516 /**************************************************************************/
1517 /* */
1518 /* FUNCTION RELEASE */
1519 /* */
1520 /* _gx_image_reader_pixel_read_callback_set PORTABLE C */
1521 /* 6.1 */
1522 /* AUTHOR */
1523 /* */
1524 /* Kenneth Maxwell, Microsoft Corporation */
1525 /* */
1526 /* DESCRIPTION */
1527 /* */
1528 /* This function sets pixel read callback of the image reader. */
1529 /* */
1530 /* INPUT */
1531 /* */
1532 /* image_reader Image reader control block */
1533 /* inmap Input pixelmap */
1534 /* */
1535 /* OUTPUT */
1536 /* */
1537 /* Completion Status */
1538 /* */
1539 /* CALLS */
1540 /* */
1541 /* _gx_image_reader_1bit_pixel_read Read 1bit internal format */
1542 /* pixel */
1543 /* _gx_image_reader_2bit_pixel_read Read 2bit internal format */
1544 /* pixel */
1545 /* _gx_image_reader_4bit_pixel_read Read 4bit internal format */
1546 /* pixel */
1547 /* _gx_image_reader_8bit_pixel_read Read 8bit internal format */
1548 /* pixel */
1549 /* _gx_image_reader_16bit_gray_read Read 16bit internal format */
1550 /* pixel */
1551 /* _gx_image_reader_16bit_gray_alpha_read */
1552 /* Read 16bit gray:alpha internal*/
1553 /* format pixel */
1554 /* _gx_image_reader_32bit_gray_alpha_read */
1555 /* Read 32bit gray:alpha internal*/
1556 /* format pixel */
1557 /* _gx_image_reader_24bit_pixel_read Read 24bit internal format */
1558 /* pixel */
1559 /* _gx_image_reader_32bit_pixel_read Read 32bit internal format */
1560 /* pixel */
1561 /* _gx_image_reader_48bit_pixel_read Read 48bit internal format */
1562 /* pixel */
1563 /* _gx_image_reader_64bit_pixel_read Read 64bit internal format */
1564 /* pixel */
1565 /* _gx_image_reader_32argb_pixel_read Read 32argb guix format pixel */
1566 /* pixel */
1567 /* _gx_image_reader_565rgb_pixel_read Read 565rgb guix format pixel */
1568 /* _gx_image_reader_1555xrgb_pixel_read Read 1555xrgb guix format */
1569 /* pixel */
1570 /* _gx_image_reader_8bit_palette_pixel_read */
1571 /* Read 8bit palette guix format */
1572 /* pixel */
1573 /* _gx_image_reader_8bit_alpha_read Read 8bit alphamap guix format*/
1574 /* pixel */
1575 /* _gx_image_reader_4444argb_pixel_read Read 4444argb guix format */
1576 /* pixel */
1577 /* _gx_image_reader_4bit_grayscale_transparent_read */
1578 /* Read 4bit grayscale guix */
1579 /* format pixel with */
1580 /* transparency */
1581 /* _gx_image_reader_4bit_grayscale_pixel_read */
1582 /* Read 4bit grayscale guix */
1583 /* format pxiel */
1584 /* _gx_image_reader_1bpp_transparent_read */
1585 /* Read 1bpp guix format pixel */
1586 /* with transparency */
1587 /* _gx_image_reader_1bpp_pixel_read Read 1bpp guix format pixel */
1588 /* */
1589 /* CALLED BY */
1590 /* */
1591 /* gx_image_reader_colorspace_convert */
1592 /* */
1593 /* RELEASE HISTORY */
1594 /* */
1595 /* DATE NAME DESCRIPTION */
1596 /* */
1597 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
1598 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
1599 /* resulting in version 6.1 */
1600 /* */
1601 /**************************************************************************/
_gx_image_reader_pixel_read_callback_set(GX_IMAGE_READER * image_reader,GX_PIXELMAP * inmap)1602 UINT _gx_image_reader_pixel_read_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *inmap)
1603 {
1604
1605 switch (inmap -> gx_pixelmap_format)
1606 {
1607 case GX_IMAGE_FORMAT_1BPP:
1608 if (inmap -> gx_pixelmap_aux_data)
1609 {
1610 image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1611 image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1612 }
1613 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bit_pixel_read;
1614 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 3);
1615 break;
1616
1617 case GX_IMAGE_FORMAT_2BPP:
1618 if (inmap -> gx_pixelmap_aux_data)
1619 {
1620 image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1621 image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1622 }
1623 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_2bit_pixel_read;
1624 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 2);
1625 break;
1626
1627 case GX_IMAGE_FORMAT_4BPP:
1628 if (inmap -> gx_pixelmap_aux_data)
1629 {
1630 image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1631 image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1632 }
1633
1634 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_pixel_read;
1635 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 1);
1636 break;
1637
1638 case GX_IMAGE_FORMAT_8BPP:
1639 if (inmap -> gx_pixelmap_aux_data)
1640 {
1641 image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1642 image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1643 }
1644
1645 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_pixel_read;
1646 image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1647 break;
1648
1649 case GX_IMAGE_FORMAT_16BPP_GRAY:
1650 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_16bit_gray_read;
1651 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1652 break;
1653
1654 case GX_IMAGE_FORMAT_16BPP_GRAY_ALPHA: /* Internal format: gray: alpha byte stream. */
1655 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_16bit_gray_alpha_read;
1656 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1657 break;
1658
1659 case GX_IMAGE_FORMAT_32BPP_GRAY_ALPHA: /* Internal format: gray: alpha byte stream. */
1660 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32bit_gray_alpha_read;
1661 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1662 break;
1663
1664 case GX_IMAGE_FORMAT_24BPP: /* Internal format: r:g:b byte stream. */
1665 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_24bit_pixel_read;
1666 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width * 3);
1667 break;
1668
1669 case GX_IMAGE_FORMAT_32BPP: /* Internal format: r:g:b:a byte strem. */
1670 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32bit_pixel_read;
1671 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1672 break;
1673
1674 case GX_IMAGE_FORMAT_48BPP:
1675 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_48bit_pixel_read;
1676 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width * 6);
1677 break;
1678
1679 case GX_IMAGE_FORMAT_64BPP:
1680 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_64bit_pixel_read;
1681 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 3);
1682 break;
1683
1684 case GX_COLOR_FORMAT_32ARGB:
1685 case GX_COLOR_FORMAT_24XRGB:
1686 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32argb_pixel_read;
1687 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1688 break;
1689
1690 case GX_COLOR_FORMAT_565RGB:
1691 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_565rgb_pixel_read;
1692 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1693 break;
1694
1695 case GX_COLOR_FORMAT_1555XRGB:
1696 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1555xrgb_pixel_read;
1697 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1698 break;
1699
1700 case GX_COLOR_FORMAT_8BIT_PALETTE:
1701 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_palette_pixel_read;
1702 image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1703 break;
1704
1705 case GX_COLOR_FORMAT_8BIT_ALPHAMAP:
1706 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_alpha_read;
1707 image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1708 break;
1709
1710 case GX_COLOR_FORMAT_4444ARGB:
1711 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4444argb_pixel_read;
1712 image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1713 break;
1714
1715 case GX_COLOR_FORMAT_4BIT_GRAY:
1716 if (inmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1717 {
1718 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_grayscale_transparent_read;
1719 }
1720 else
1721 {
1722 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_grayscale_pixel_read;
1723 }
1724 image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 1) >> 1);
1725 break;
1726
1727 case GX_COLOR_FORMAT_MONOCHROME:
1728 if (inmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1729 {
1730 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bpp_transparent_read;
1731 image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 3) >> 2);
1732 }
1733 else
1734 {
1735 image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bpp_pixel_read;
1736 image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 7) >> 3);
1737 }
1738 break;
1739
1740 default:
1741 return GX_NOT_SUPPORTED;
1742 }
1743
1744 image_reader -> gx_image_reader_getdata = (GX_UBYTE *)inmap -> gx_pixelmap_data;
1745 image_reader -> gx_image_reader_getauxdata = (GX_UBYTE *)inmap -> gx_pixelmap_aux_data;
1746
1747 return GX_SUCCESS;
1748 }
1749 #endif
1750
1751