GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_image_reader_pixel_read_callback_set.c Lines: 403 403 100.0 %
Date: 2024-12-05 08:52:37 Branches: 108 108 100.0 %

Line Branch Exec Source
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
/**************************************************************************/
72
10273056
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
10273056
    pLine = image_reader -> gx_image_reader_getdata;
77
10273056
    pLine += index;
78
79
10273056
    pixel -> gx_pixel_red = 0;
80
10273056
    pixel -> gx_pixel_green = 0;
81
10273056
    pixel -> gx_pixel_blue = 0;
82
10273056
    pixel -> gx_pixel_alpha = *pLine;
83
84
10273056
    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
/**************************************************************************/
128
13312
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
13312
    pLine = image_reader -> gx_image_reader_getdata;
135
13312
    pLine += (index >> 3);
136
137
13312
    palindex = *pLine;
138
13312
    palindex >>= (7 - (index & 0x7));
139
13312
    palindex &= 0x01;
140
141
13312
    if ((image_reader -> gx_image_reader_png_trans) &&
142
3072
        (palindex == image_reader -> gx_image_reader_png_trans[0]))
143
    {
144
        /* Transparent */
145
1572
        pixel -> gx_pixel_alpha = 0;
146
1572
        pixel -> gx_pixel_red = 0;
147
1572
        pixel -> gx_pixel_green = 0;
148
1572
        pixel -> gx_pixel_blue = 0;
149
    }
150
    else
151
    {
152
11740
        pal = (GX_COLOR *)image_reader -> gx_image_reader_png_palette;
153
154
11740
        if (pal)
155
        {
156
            /* Palette */
157
6144
            if (palindex < image_reader -> gx_image_reader_png_palette_size)
158
            {
159
5120
                pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
160
5120
                pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
161
5120
                pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
162
5120
                pixel -> gx_pixel_alpha = 0xff;
163
            }
164
            else
165
            {
166
1024
                memset(pixel, 0, sizeof(GX_PIXEL));
167
            }
168
        }
169
        else
170
        {
171
            /* Gray */
172
5596
            palindex *= 255;
173
5596
            pixel -> gx_pixel_red = (GX_UBYTE)palindex;
174
5596
            pixel -> gx_pixel_green = (GX_UBYTE)palindex;
175
5596
            pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
176
5596
            pixel -> gx_pixel_alpha = 0xff;
177
        }
178
    }
179
180
13312
    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
/**************************************************************************/
224
12288
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
12288
    pLine = image_reader -> gx_image_reader_getdata;
231
12288
    pLine += (index >> 2);
232
233
12288
    palindex = *pLine;
234
12288
    palindex >>= (3 - (index & 0x3)) * 2;
235
12288
    palindex &= 0x03;
236
237
12288
    if ((image_reader -> gx_image_reader_png_trans) &&
238
2048
        (palindex == image_reader -> gx_image_reader_png_trans[0]))
239
    {
240
        /* Transparent */
241
512
        pixel -> gx_pixel_alpha = 0;
242
512
        pixel -> gx_pixel_red = 0;
243
512
        pixel -> gx_pixel_green = 0;
244
512
        pixel -> gx_pixel_blue = 0;
245
    }
246
    else
247
    {
248
11776
        pal = image_reader -> gx_image_reader_png_palette;
249
250
11776
        if (pal)
251
        {
252
            /* Palette */
253
6144
            if (palindex < image_reader -> gx_image_reader_png_palette_size)
254
            {
255
5632
                pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
256
5632
                pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
257
5632
                pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
258
5632
                pixel -> gx_pixel_alpha = 0xff;
259
            }
260
            else
261
            {
262
512
                memset(pixel, 0, sizeof(GX_PIXEL));
263
            }
264
        }
265
        else
266
        {
267
            /* Gray */
268
5632
            palindex = palindex * 255 / 3;
269
5632
            pixel -> gx_pixel_red = (GX_UBYTE)palindex;
270
5632
            pixel -> gx_pixel_green = (GX_UBYTE)palindex;
271
5632
            pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
272
5632
            pixel -> gx_pixel_alpha = 0xff;
273
        }
274
    }
275
276
12288
    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
/**************************************************************************/
321
18432
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
18432
    pLine = image_reader -> gx_image_reader_getdata;
328
18432
    pLine += (index >> 1);
329
330
18432
    palindex = *pLine;
331
18432
    palindex >>= (1 - (index & 0x01)) * 4;
332
18432
    palindex &= 0x0f;
333
334
18432
    if ((image_reader -> gx_image_reader_png_trans) &&
335
4096
        (palindex == image_reader -> gx_image_reader_png_trans[0]))
336
    {
337
        /* Transparent */
338
2064
        pixel -> gx_pixel_alpha = 0;
339
2064
        pixel -> gx_pixel_red = 0;
340
2064
        pixel -> gx_pixel_green = 0;
341
2064
        pixel -> gx_pixel_blue = 0;
342
    }
343
    else
344
    {
345
16368
        pal = image_reader -> gx_image_reader_png_palette;
346
347
16368
        if (pal)
348
        {
349
            /* Pixel */
350
10240
            if (palindex < image_reader -> gx_image_reader_png_palette_size)
351
            {
352
10016
                pixel -> gx_pixel_red = (GX_UBYTE)(pal[palindex] >> 16);
353
10016
                pixel -> gx_pixel_green = (GX_UBYTE)(pal[palindex] >> 8);
354
10016
                pixel -> gx_pixel_blue = (GX_UBYTE)pal[palindex];
355
10016
                pixel -> gx_pixel_alpha = 0xff;
356
            }
357
            else
358
            {
359
224
                memset(pixel, 0, sizeof(GX_PIXEL));
360
            }
361
        }
362
        else
363
        {
364
            /* Gray */
365
6128
            palindex = palindex * 255 / 15;
366
6128
            pixel -> gx_pixel_red = (GX_UBYTE)palindex;
367
6128
            pixel -> gx_pixel_green = (GX_UBYTE)palindex;
368
6128
            pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
369
6128
            pixel -> gx_pixel_alpha = 0xff;
370
        }
371
    }
372
373
18432
    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
/**************************************************************************/
417
47104
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
47104
    palindex = *(image_reader -> gx_image_reader_getdata + index);
424
425
47104
    if ((image_reader -> gx_image_reader_png_trans) &&
426
16384
        (palindex == image_reader -> gx_image_reader_png_trans[0]))
427
    {
428
        /* Transparent */
429
8048
        pixel -> gx_pixel_alpha = 0;
430
8048
        pixel -> gx_pixel_red = 0;
431
8048
        pixel -> gx_pixel_green = 0;
432
8048
        pixel -> gx_pixel_blue = 0;
433
    }
434
    else
435
    {
436
39056
        palette = image_reader -> gx_image_reader_png_palette;
437
39056
        palsize = image_reader -> gx_image_reader_png_palette_size;
438
439
39056
        if (palette)
440
        {
441
            /* Palette */
442
22672
            if (palindex < palsize)
443
            {
444
22664
                pixel -> gx_pixel_red = (GX_UBYTE)(palette[palindex] >> 16);
445
22664
                pixel -> gx_pixel_green = (GX_UBYTE)(palette[palindex] >> 8);
446
22664
                pixel -> gx_pixel_blue = (GX_UBYTE)palette[palindex];
447
22664
                pixel -> gx_pixel_alpha = 0xff;
448
            }
449
            else
450
            {
451
8
                memset(pixel, 0, sizeof(GX_PIXEL));
452
            }
453
        }
454
        else
455
        {
456
            /* Gray */
457
16384
            pixel -> gx_pixel_red = (GX_UBYTE)palindex;
458
16384
            pixel -> gx_pixel_green = (GX_UBYTE)palindex;
459
16384
            pixel -> gx_pixel_blue = (GX_UBYTE)palindex;
460
16384
            pixel -> gx_pixel_alpha = 0xff;
461
        }
462
    }
463
464
47104
    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
/**************************************************************************/
508
6854362
static UINT _gx_image_reader_8bit_palette_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
509
{
510
6854362
GX_COLOR *palette = image_reader -> gx_image_reader_palette;
511
UINT      palindex;
512
513
6854362
    palindex = *(image_reader -> gx_image_reader_getdata + index);
514
515
6854362
    if (palette)
516
    {
517
        /* Palette */
518

6713386
        if ((image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) &&
519
            (GX_TRANSPARENT_COLOR == palindex))
520
        {
521
168056
            pixel -> gx_pixel_alpha = 0;
522
168056
            pixel -> gx_pixel_red = 0;
523
168056
            pixel -> gx_pixel_green = 0;
524
168056
            pixel -> gx_pixel_blue = 0;
525
        }
526
        else
527
        {
528
6545330
            pixel -> gx_pixel_red = (GX_UBYTE)(palette[palindex] >> 16);
529
6545330
            pixel -> gx_pixel_green = (GX_UBYTE)(palette[palindex] >> 8);
530
6545330
            pixel -> gx_pixel_blue = (GX_UBYTE)palette[palindex];
531
6545330
            pixel -> gx_pixel_alpha = 0xff;
532
        }
533
    }
534
    else
535
    {
536
140976
        memset(pixel, 0, sizeof(GX_PIXEL));
537
    }
538
539
6854362
    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
/**************************************************************************/
583
48448
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
48448
    pLine = image_reader -> gx_image_reader_getdata;
588
48448
    pLine += (index << 1);
589
590
    /* Trans is prohibited for this color types, since a full alpha channel is already present. */
591
48448
    pixel -> gx_pixel_red = *pLine;
592
48448
    pixel -> gx_pixel_green = *pLine;
593
48448
    pixel -> gx_pixel_blue = *pLine++;
594
48448
    pixel -> gx_pixel_alpha = *pLine;
595
596
48448
    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
/**************************************************************************/
641
4096
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
4096
    pLine = image_reader -> gx_image_reader_getdata;
646
4096
    pLine += (index << 2);
647
648
4096
    pixel -> gx_pixel_red = *pLine;
649
4096
    pixel -> gx_pixel_green = pixel -> gx_pixel_red;
650
4096
    pixel -> gx_pixel_blue = pixel -> gx_pixel_red;
651
4096
    pLine += 2;
652
4096
    pixel -> gx_pixel_alpha = (GX_UBYTE)*pLine;
653
654
4096
    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
/**************************************************************************/
698
8603020
static UINT _gx_image_reader_24bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
699
{
700
GX_UBYTE *pLine;
701
8603020
GX_COLOR *pTrans = image_reader -> gx_image_reader_png_trans;
702
703
8603020
    pLine = image_reader -> gx_image_reader_getdata;
704
8603020
    pLine += index * 3;
705
706
8603020
    pixel -> gx_pixel_red = *pLine++;
707
8603020
    pixel -> gx_pixel_green = *pLine++;
708
8603020
    pixel -> gx_pixel_blue = *pLine;
709
710
8603020
    if ((pTrans) &&
711
10240
        (pixel -> gx_pixel_red == pTrans[0]) &&
712
5052
        (pixel -> gx_pixel_green == pTrans[1]) &&
713
4542
        (pixel -> gx_pixel_blue == pTrans[2]))
714
    {
715
4032
        pixel -> gx_pixel_alpha = 0;
716
    }
717
    else
718
    {
719
8598988
        pixel -> gx_pixel_alpha = 0xff;
720
    }
721
722
8603020
    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
/**************************************************************************/
766
34816
static UINT _gx_image_reader_48bit_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
767
{
768
GX_UBYTE *pLine;
769
34816
GX_COLOR *pTrans = image_reader -> gx_image_reader_png_trans;
770
771
34816
    pLine = image_reader -> gx_image_reader_getdata;
772
34816
    pLine += index * 6;
773
774
34816
    pixel -> gx_pixel_red = *pLine;
775
34816
    pLine += 2;
776
34816
    pixel -> gx_pixel_green = *pLine;
777
34816
    pLine += 2;
778
34816
    pixel -> gx_pixel_blue = *pLine;
779
780
34816
    if ((pTrans) &&
781
10240
        (pixel -> gx_pixel_red == (GX_UBYTE)pTrans[0]) &&
782
4088
        (pixel -> gx_pixel_green == (GX_UBYTE)pTrans[1]) &&
783
4026
        (pixel -> gx_pixel_blue == (GX_UBYTE)pTrans[2]))
784
    {
785
4024
        pixel -> gx_pixel_alpha = 0;
786
    }
787
    else
788
    {
789
30792
        pixel -> gx_pixel_alpha = 0xff;
790
    }
791
792
34816
    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
/**************************************************************************/
836
4096
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
4096
    pLine = image_reader -> gx_image_reader_getdata;
841
4096
    pLine += (index << 3);
842
843
4096
    pixel -> gx_pixel_red = *pLine;
844
4096
    pLine += 2;
845
4096
    pixel -> gx_pixel_green = *pLine;
846
4096
    pLine += 2;
847
4096
    pixel -> gx_pixel_blue = *pLine;
848
4096
    pLine += 2;
849
4096
    pixel -> gx_pixel_alpha = *pLine;
850
851
4096
    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
/**************************************************************************/
895
5003064
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
5003064
    pLine = (GX_COLOR *)image_reader -> gx_image_reader_getdata;
900
5003064
    pLine += index;
901
902
5003064
    pixel -> gx_pixel_alpha = (GX_UBYTE)((*pLine) >> 24);
903
5003064
    pixel -> gx_pixel_red = (GX_UBYTE)((*pLine) >> 16);
904
5003064
    pixel -> gx_pixel_green = (GX_UBYTE)((*pLine) >> 8);
905
5003064
    pixel -> gx_pixel_blue = (GX_UBYTE)(*pLine);
906
907
5003064
    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
/**************************************************************************/
951
13849630
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
13849630
    pget = (GX_UBYTE *)image_reader -> gx_image_reader_getdata;
956
13849630
    pget += (index << 2);
957
958
13849630
    pixel -> gx_pixel_red = *pget++;
959
13849630
    pixel -> gx_pixel_green = *pget++;
960
13849630
    pixel -> gx_pixel_blue = *pget++;
961
13849630
    pixel -> gx_pixel_alpha = *pget++;
962
963
13849630
    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
/**************************************************************************/
1007
16384
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
16384
    pget = (GX_UBYTE *)image_reader -> gx_image_reader_getdata;
1012
16384
    pget += (index << 1);
1013
1014
16384
    if ((image_reader -> gx_image_reader_png_trans) &&
1015
4096
        ((*pget) == (GX_UBYTE)image_reader -> gx_image_reader_png_trans[0]))
1016
    {
1017
2012
        pixel -> gx_pixel_alpha = 0;
1018
2012
        pixel -> gx_pixel_red = 0;
1019
2012
        pixel -> gx_pixel_green = 0;
1020
2012
        pixel -> gx_pixel_blue = 0;
1021
    }
1022
    else
1023
    {
1024
14372
        pixel -> gx_pixel_red = *pget;
1025
14372
        pixel -> gx_pixel_green = *pget;
1026
14372
        pixel -> gx_pixel_blue = *pget;
1027
14372
        pixel -> gx_pixel_alpha = 0xff;
1028
    }
1029
1030
16384
    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
/**************************************************************************/
1074
9296783
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
9296783
    pLine = (USHORT *)image_reader -> gx_image_reader_getdata;
1080
9296783
    pLine += index;
1081
1082
9296783
    pixel -> gx_pixel_red = (GX_UBYTE)(((*pLine) & 0xf800) >> 8);
1083
9296783
    pixel -> gx_pixel_green = (GX_UBYTE)(((*pLine) & 0x07e0) >> 3);
1084
9296783
    pixel -> gx_pixel_blue = (GX_UBYTE)(((*pLine) & 0x001f) << 3);
1085
1086
9296783
    if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA)
1087
    {
1088
1777547
        pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_getauxdata;
1089
1777547
        pAlpha += index;
1090
1091
1777547
        pixel -> gx_pixel_alpha = (*pAlpha);
1092
    }
1093
    else
1094
    {
1095
7519236
        pixel -> gx_pixel_alpha = 0;
1096
    }
1097
1098
9296783
    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
/**************************************************************************/
1143
2672758
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
2672758
    pLine = (USHORT *)image_reader -> gx_image_reader_getdata;
1149
2672758
    pLine += index;
1150
1151
2672758
    pixel -> gx_pixel_red = (GX_UBYTE)(((*pLine) & 0x7c00) >> 7);
1152
2672758
    pixel -> gx_pixel_green = (GX_UBYTE)(((*pLine) & 0x03e0) >> 2);
1153
2672758
    pixel -> gx_pixel_blue = (GX_UBYTE)(((*pLine) & 0x001f) << 3);
1154
1155
2672758
    if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA)
1156
    {
1157
1448126
        pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_getauxdata;
1158
1448126
        pAlpha += index;
1159
1160
1448126
        pixel -> gx_pixel_alpha = (*pAlpha);
1161
    }
1162
    else
1163
    {
1164
1224632
        pixel -> gx_pixel_alpha = 0;
1165
    }
1166
1167
2672758
    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
/**************************************************************************/
1212
1505626
static UINT _gx_image_reader_4444argb_pixel_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1213
{
1214
USHORT        color;
1215
1505626
const USHORT *data = (USHORT *)(image_reader -> gx_image_reader_getdata);
1216
1217
1505626
    color = *(data + index);
1218
1219
1505626
    pixel -> gx_pixel_alpha = (GX_UBYTE)((color & 0xf000) >> 8);
1220
1505626
    pixel -> gx_pixel_red = (GX_UBYTE)((color & 0xf00) >> 4);
1221
1505626
    pixel -> gx_pixel_green = (GX_UBYTE)(color & 0xf0);
1222
1505626
    pixel -> gx_pixel_blue = (GX_UBYTE)((color & 0xf) << 4);
1223
1224
1505626
    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
/**************************************************************************/
1269
833722
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
833722
    color = *(image_reader -> gx_image_reader_getdata + (index >> 1));
1274
1275
833722
    if (index & 1)
1276
    {
1277
414352
        color &= 0x0f;
1278
    }
1279
    else
1280
    {
1281
419370
        color &= 0xf0;
1282
419370
        color >>= 4;
1283
    }
1284
1285
833722
    color |= (GX_UBYTE)(color << 4);
1286
833722
    pixel -> gx_pixel_red = color;
1287
833722
    pixel -> gx_pixel_green = color;
1288
833722
    pixel -> gx_pixel_blue = color;
1289
833722
    pixel -> gx_pixel_alpha = 0xff;
1290
1291
833722
    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
/**************************************************************************/
1336
588752
static UINT _gx_image_reader_4bit_grayscale_transparent_read(GX_IMAGE_READER *image_reader, INT index, GX_PIXEL *pixel)
1337
{
1338
588752
const GX_UBYTE *data = image_reader -> gx_image_reader_getdata;
1339
588752
const GX_UBYTE *auxdata = image_reader -> gx_image_reader_getauxdata;
1340
588752
INT             aux_index = (index >> 3);
1341
588752
INT             color_index = (index >> 1);
1342
588752
GX_UBYTE        color = *(data + color_index);
1343
588752
GX_UBYTE        transparency = *(auxdata + aux_index);
1344
1345
    /* Get transparent mask. */
1346
588752
    transparency = (GX_UBYTE)(transparency >> (7 - (index & 0x07)));
1347
1348
588752
    if (transparency & 0x01)
1349
    {
1350
134620
        color = 0;
1351
134620
        pixel -> gx_pixel_alpha = 0;
1352
    }
1353
    else
1354
    {
1355
454132
        if (index & 1)
1356
        {
1357
227466
            color &= 0xf;
1358
        }
1359
        else
1360
        {
1361
226666
            color &= 0xf0;
1362
226666
            color >>= 4;
1363
        }
1364
454132
        color = (GX_UBYTE)(color | color << 4);
1365
454132
        pixel -> gx_pixel_alpha = 0xff;
1366
    }
1367
1368
588752
    pixel -> gx_pixel_red = color;
1369
588752
    pixel -> gx_pixel_green = color;
1370
588752
    pixel -> gx_pixel_blue = color;
1371
1372
588752
    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
/**************************************************************************/
1417
617554
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
617554
    color = *(image_reader -> gx_image_reader_getdata + (index >> 3));
1422
1423
617554
    if (color & (0x80 >> (index & 0x07)))
1424
    {
1425
386380
        pixel -> gx_pixel_red = 0xff;
1426
386380
        pixel -> gx_pixel_green = 0xff;
1427
386380
        pixel -> gx_pixel_blue = 0xff;
1428
    }
1429
    else
1430
    {
1431
231174
        pixel -> gx_pixel_red = 0;
1432
231174
        pixel -> gx_pixel_green = 0;
1433
231174
        pixel -> gx_pixel_blue = 0;
1434
    }
1435
617554
    pixel -> gx_pixel_alpha = 0xff;
1436
1437
617554
    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
/**************************************************************************/
1482
648696
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
648696
    color = *(image_reader -> gx_image_reader_getdata + (index >> 2));
1487
1488
648696
    if (color & (0x40 >> ((index & 0x03) << 1)))
1489
    {
1490
495628
        if (color & (0x80 >> ((index & 0x03) << 1)))
1491
        {
1492
224414
            pixel -> gx_pixel_red = 0xff;
1493
224414
            pixel -> gx_pixel_green = 0xff;
1494
224414
            pixel -> gx_pixel_blue = 0xff;
1495
        }
1496
        else
1497
        {
1498
271214
            pixel -> gx_pixel_red = 0;
1499
271214
            pixel -> gx_pixel_green = 0;
1500
271214
            pixel -> gx_pixel_blue = 0;
1501
        }
1502
495628
        pixel -> gx_pixel_alpha = 0xff;
1503
    }
1504
    else
1505
    {
1506
153068
        pixel -> gx_pixel_red = 0;
1507
153068
        pixel -> gx_pixel_green = 0;
1508
153068
        pixel -> gx_pixel_blue = 0;
1509
153068
        pixel -> gx_pixel_alpha = 0;
1510
    }
1511
1512
648696
    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
/**************************************************************************/
1602
1176
UINT _gx_image_reader_pixel_read_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *inmap)
1603
{
1604
1605





1176
    switch (inmap -> gx_pixelmap_format)
1606
    {
1607
13
    case GX_IMAGE_FORMAT_1BPP:
1608
13
        if (inmap -> gx_pixelmap_aux_data)
1609
        {
1610
6
            image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1611
6
            image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1612
        }
1613
13
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bit_pixel_read;
1614
13
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 3);
1615
13
        break;
1616
1617
12
    case GX_IMAGE_FORMAT_2BPP:
1618
12
        if (inmap -> gx_pixelmap_aux_data)
1619
        {
1620
6
            image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1621
6
            image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1622
        }
1623
12
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_2bit_pixel_read;
1624
12
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 2);
1625
12
        break;
1626
1627
18
    case GX_IMAGE_FORMAT_4BPP:
1628
18
        if (inmap -> gx_pixelmap_aux_data)
1629
        {
1630
10
            image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1631
10
            image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1632
        }
1633
1634
18
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_pixel_read;
1635
18
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width >> 1);
1636
18
        break;
1637
1638
46
    case GX_IMAGE_FORMAT_8BPP:
1639
46
        if (inmap -> gx_pixelmap_aux_data)
1640
        {
1641
30
            image_reader -> gx_image_reader_png_palette = (GX_COLOR *)inmap -> gx_pixelmap_aux_data;
1642
30
            image_reader -> gx_image_reader_png_palette_size = inmap -> gx_pixelmap_aux_data_size / sizeof(GX_COLOR);
1643
        }
1644
1645
46
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_pixel_read;
1646
46
        image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1647
46
        break;
1648
1649
16
    case GX_IMAGE_FORMAT_16BPP_GRAY:
1650
16
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_16bit_gray_read;
1651
16
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1652
16
        break;
1653
1654
8
    case GX_IMAGE_FORMAT_16BPP_GRAY_ALPHA: /* Internal format: gray: alpha byte stream. */
1655
8
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_16bit_gray_alpha_read;
1656
8
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1657
8
        break;
1658
1659
4
    case GX_IMAGE_FORMAT_32BPP_GRAY_ALPHA: /* Internal format: gray: alpha byte stream. */
1660
4
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32bit_gray_alpha_read;
1661
4
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1662
4
        break;
1663
1664
318
    case GX_IMAGE_FORMAT_24BPP: /* Internal format: r:g:b byte stream. */
1665
318
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_24bit_pixel_read;
1666
318
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width * 3);
1667
318
        break;
1668
1669
321
    case GX_IMAGE_FORMAT_32BPP: /* Internal format: r:g:b:a byte strem. */
1670
321
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32bit_pixel_read;
1671
321
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1672
321
        break;
1673
1674
34
    case GX_IMAGE_FORMAT_48BPP:
1675
34
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_48bit_pixel_read;
1676
34
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width * 6);
1677
34
        break;
1678
1679
4
    case GX_IMAGE_FORMAT_64BPP:
1680
4
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_64bit_pixel_read;
1681
4
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 3);
1682
4
        break;
1683
1684
37
    case GX_COLOR_FORMAT_32ARGB:
1685
    case GX_COLOR_FORMAT_24XRGB:
1686
37
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_32argb_pixel_read;
1687
37
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 2);
1688
37
        break;
1689
1690
63
    case GX_COLOR_FORMAT_565RGB:
1691
63
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_565rgb_pixel_read;
1692
63
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1693
63
        break;
1694
1695
32
    case GX_COLOR_FORMAT_1555XRGB:
1696
32
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1555xrgb_pixel_read;
1697
32
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1698
32
        break;
1699
1700
56
    case GX_COLOR_FORMAT_8BIT_PALETTE:
1701
56
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_palette_pixel_read;
1702
56
        image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1703
56
        break;
1704
1705
124
    case GX_COLOR_FORMAT_8BIT_ALPHAMAP:
1706
124
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_8bit_alpha_read;
1707
124
        image_reader -> gx_image_reader_input_stride = (UINT)inmap -> gx_pixelmap_width;
1708
124
        break;
1709
1710
20
    case GX_COLOR_FORMAT_4444ARGB:
1711
20
        image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4444argb_pixel_read;
1712
20
        image_reader -> gx_image_reader_input_stride = (UINT)(inmap -> gx_pixelmap_width << 1);
1713
20
        break;
1714
1715
24
    case GX_COLOR_FORMAT_4BIT_GRAY:
1716
24
        if (inmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1717
        {
1718
8
            image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_grayscale_transparent_read;
1719
        }
1720
        else
1721
        {
1722
16
            image_reader -> gx_image_reader_pixel_read = _gx_image_reader_4bit_grayscale_pixel_read;
1723
        }
1724
24
        image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 1) >> 1);
1725
24
        break;
1726
1727
25
    case GX_COLOR_FORMAT_MONOCHROME:
1728
25
        if (inmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
1729
        {
1730
12
            image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bpp_transparent_read;
1731
12
            image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 3) >> 2);
1732
        }
1733
        else
1734
        {
1735
13
            image_reader -> gx_image_reader_pixel_read = _gx_image_reader_1bpp_pixel_read;
1736
13
            image_reader -> gx_image_reader_input_stride = (UINT)((inmap -> gx_pixelmap_width + 7) >> 3);
1737
        }
1738
25
        break;
1739
1740
1
    default:
1741
1
        return GX_NOT_SUPPORTED;
1742
    }
1743
1744
1175
    image_reader -> gx_image_reader_getdata = (GX_UBYTE *)inmap -> gx_pixelmap_data;
1745
1175
    image_reader -> gx_image_reader_getauxdata = (GX_UBYTE *)inmap -> gx_pixelmap_aux_data;
1746
1747
1175
    return GX_SUCCESS;
1748
}
1749
#endif
1750