GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_1bpp_pixelmap_rotate.c Lines: 265 265 100.0 %
Date: 2024-12-05 08:52:37 Branches: 126 126 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
/**   Utility (Utility)                                                   */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
#include "gx_context.h"
29
#include "gx_utility.h"
30
#include "gx_system.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_utility_1bpp_pixelmap_rotate                    PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    1bpp pixelmap rotation function that handles uncompress, with or    */
45
/*    without alpha channel.                                              */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    src                                   The pixelmap to be rotated    */
50
/*    angle                                 The angle to be rotated       */
51
/*    destination                           The rotated bitmap to be      */
52
/*                                            returned                    */
53
/*    rot_cx                                X coordinate of rotation      */
54
/*                                            center                      */
55
/*    rot_cy                                Y coordinate of rotation      */
56
/*                                            center                      */
57
/*                                                                        */
58
/*  OUTPUT                                                                */
59
/*                                                                        */
60
/*    None                                                                */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _gx_system_memory_allocator           Memory Allocation routine     */
65
/*    _gx_utility_math_cos                  Compute the cosine value      */
66
/*    _gx_utility_math_sin                  Compute the sine value        */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    Application Code                                                    */
71
/*                                                                        */
72
/*  RELEASE HISTORY                                                       */
73
/*                                                                        */
74
/*    DATE              NAME                      DESCRIPTION             */
75
/*                                                                        */
76
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
77
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
78
/*                                            resulting in version 6.1    */
79
/*                                                                        */
80
/**************************************************************************/
81
720
UINT _gx_utility_1bpp_pixelmap_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
82
{
83
GX_UBYTE *putrow;
84
GX_UBYTE *put;
85
GX_UBYTE *get;
86
INT       srcxres;
87
INT       srcyres;
88
INT       cosv;
89
INT       sinv;
90
INT       idxminx, idxmaxx, idxmaxy;
91
720
INT       mx[] = {-1, 1, 1, -1};
92
720
INT       my[] = {1, 1, -1, -1};
93
INT       xres;
94
INT       yres;
95
INT       width, height;
96
INT       x, y;
97
INT       xx, yy;
98
INT       putstride;
99
INT       getstride;
100
GX_UBYTE  putmask;
101
GX_UBYTE  putTransmask;
102
GX_UBYTE  getTransmask;
103
GX_UBYTE  getmask;
104
720
GX_BOOL   InputAlpha = GX_FALSE;
105
106
720
    idxminx = (angle / 90) & 0x3;
107
720
    idxmaxx = (idxminx + 2) & 0x3;
108
720
    idxmaxy = (idxminx + 1) & 0x3;
109
110
    /* Calculate the source x and y center. */
111
720
    srcxres = src -> gx_pixelmap_width >> 1;
112
720
    srcyres = src -> gx_pixelmap_height >> 1;
113
114
720
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
115
720
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
116
117
720
    xres = GX_FIXED_VAL_TO_INT((mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv));
118
720
    yres = GX_FIXED_VAL_TO_INT((my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv));
119
120
    /* Calculate destination width and height. */
121
720
    width = (xres << 1);
122
720
    height = (yres << 1);
123
124

720
    if (rot_cx && rot_cy)
125
    {
126
        /* Calculate the new rotation axis. */
127
712
        x = ((*rot_cx) - srcxres) * cosv - ((*rot_cy) - srcyres) * sinv;
128
712
        y = ((*rot_cy) - srcyres) * cosv + ((*rot_cx) - srcxres) * sinv;
129
130
712
        x = GX_FIXED_VAL_TO_INT(x) + xres;
131
712
        y = GX_FIXED_VAL_TO_INT(y) + yres;
132
133
712
        srcxres = *rot_cx;
134
712
        srcyres = *rot_cy;
135
136
712
        *rot_cx = x;
137
712
        *rot_cy = y;
138
139
712
        xres = *rot_cx;
140
712
        yres = *rot_cy;
141
    }
142
143
    /* Set width and height of destination pixelmap.  */
144
720
    destination -> gx_pixelmap_width = (GX_VALUE)width;
145
720
    destination -> gx_pixelmap_height = (GX_VALUE)height;
146
720
    destination -> gx_pixelmap_flags |= GX_PIXELMAP_TRANSPARENT;
147
720
    putstride = (width + 3) >> 2;
148
149
720
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
150
    {
151
360
        getstride = (src -> gx_pixelmap_width + 3) >> 2;
152
360
        InputAlpha = GX_TRUE;
153
    }
154
    else
155
    {
156
360
        getstride = (src -> gx_pixelmap_width + 7) >> 3;
157
    }
158
159
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
160
       overflow cannot occur. */
161
720
    destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
162
    /* Allocate memory for destination pixelmap to load pixel information.  */
163
720
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
164
165
720
    if (destination -> gx_pixelmap_data == GX_NULL)
166
    {
167
4
        return GX_SYSTEM_MEMORY_ERROR;
168
    }
169
170
716
    putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
171
172
    /* For every pixel in destination bitmap, find its position in source bitmap,
173
       and set the pixel with the value in source bitmap.  */
174
191708
    for (y = 0; y < height; y++)
175
    {
176
190992
        put = putrow;
177
190992
        putmask = 0x80;
178
190992
        putTransmask = 0x40;
179
180
51707328
        for (x = 0; x < width; x++)
181
        {
182
51516336
            xx = (x - xres) * cosv + (y - yres) * sinv;
183
51516336
            yy = (y - yres) * cosv - (x - xres) * sinv;
184
185
51516336
            xx = GX_FIXED_VAL_TO_INT(xx) + srcxres;
186
51516336
            yy = GX_FIXED_VAL_TO_INT(yy) + srcyres;
187
188
51516336
            *put = (GX_UBYTE)(*put & (~putTransmask));
189
51516336
            *put = (GX_UBYTE)(*put & (~putmask));
190

51516336
            if ((xx >= 0) && (xx < src -> gx_pixelmap_width) &&
191
35280875
                (yy >= 0) && (yy < src -> gx_pixelmap_height))
192
            {
193
29542202
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
194
29542202
                get += yy * getstride;
195
29542202
                if (InputAlpha)
196
                {
197
18669260
                    get += xx >> 2;
198
18669260
                    getTransmask = (GX_UBYTE)(0x40 >> ((xx & 0x03) << 1));
199
18669260
                    if (*get & getTransmask)
200
                    {
201
12970250
                        *put |= putTransmask;
202
12970250
                        getmask = (GX_UBYTE)(getTransmask << 1);
203
12970250
                        if (*get & getmask)
204
                        {
205
5988038
                            *put |= putmask;
206
                        }
207
                    }
208
                }
209
                else
210
                {
211
10872942
                    *put |= putTransmask;
212
10872942
                    get += xx >> 3;
213
10872942
                    getmask = (GX_UBYTE)(0x80 >> (xx & 0x07));
214
10872942
                    if (*get & getmask)
215
                    {
216
4697144
                        *put |= putmask;
217
                    }
218
                }
219
            }
220
221
51516336
            putTransmask >>= 2;
222
51516336
            putmask >>= 2;
223
224
51516336
            if (putTransmask == 0)
225
            {
226
12833624
                put++;
227
12833624
                putTransmask = 0x40;
228
12833624
                putmask = 0x80;
229
            }
230
        }
231
190992
        putrow += putstride;
232
    }
233
234
716
    return GX_SUCCESS;
235
}
236
/**************************************************************************/
237
/*                                                                        */
238
/*  FUNCTION                                               RELEASE        */
239
/*                                                                        */
240
/*    _gx_utility_1bpp_pixelmap_simple_raw_rotate         PORTABLE C      */
241
/*                                                           6.1          */
242
/*  AUTHOR                                                                */
243
/*                                                                        */
244
/*    Kenneth Maxwell, Microsoft Corporation                              */
245
/*                                                                        */
246
/*  DESCRIPTION                                                           */
247
/*                                                                        */
248
/*    Internal helper function that handles 90, 180 and 270 degree        */
249
/*      rotation of an uncompressed pixelmap with or wihout alpha.        */
250
/*                                                                        */
251
/*  INPUT                                                                 */
252
/*                                                                        */
253
/*    src                                   The pixelmap to be rotated    */
254
/*    angle                                 The angle to be rotated       */
255
/*    destination                           The rotated bitmap to be      */
256
/*                                            returned                    */
257
/*    rot_cx                                X coordinate of rotation      */
258
/*                                            center                      */
259
/*    rot_cy                                Y coordinate of rotation      */
260
/*                                            center                      */
261
/*                                                                        */
262
/*  OUTPUT                                                                */
263
/*                                                                        */
264
/*    None                                                                */
265
/*                                                                        */
266
/*  CALLS                                                                 */
267
/*                                                                        */
268
/*    _gx_system_memory_allocator           Memory Allocation routine     */
269
/*                                                                        */
270
/*  CALLED BY                                                             */
271
/*                                                                        */
272
/*    _gx_utility_1bpp_pixelmap_simple_rotate                             */
273
/*                                                                        */
274
/*  RELEASE HISTORY                                                       */
275
/*                                                                        */
276
/*    DATE              NAME                      DESCRIPTION             */
277
/*                                                                        */
278
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
279
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
280
/*                                            resulting in version 6.1    */
281
/*                                                                        */
282
/**************************************************************************/
283
15
static UINT _gx_utility_1bpp_pixelmap_simple_raw_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
284
{
285
GX_UBYTE *put;
286
GX_UBYTE *putrow;
287
GX_UBYTE *get;
288
INT       width, height;
289
INT       x, y;
290
INT       putstride;
291
GX_UBYTE  getmask;
292
GX_UBYTE  putmask;
293
INT       getstride;
294
295
15
    getstride = (src -> gx_pixelmap_width + 7) >> 3;
296
297
15
    width = src -> gx_pixelmap_height;
298
15
    height = src -> gx_pixelmap_width;
299
300
15
    if (angle == 180)
301
    {
302
5
        GX_SWAP_VALS(width, height);
303
    }
304
305
15
    putstride = (width + 7) >> 3;
306
307
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
308
       overflow cannot occur. */
309
15
    destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
310
15
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
311
312
15
    if (destination -> gx_pixelmap_data == GX_NULL)
313
    {
314
6
        return GX_SYSTEM_MEMORY_ERROR;
315
    }
316
317
9
    if (angle == 90)
318
    {
319
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
320
321
723
        for (y = 0; y < height; y++)
322
        {
323
720
            put = putrow;
324
720
            putmask = 0x80;
325
91440
            for (x = 0; x < width; x++)
326
            {
327
90720
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
328
90720
                get += (width - 1 - x) * getstride;
329
90720
                get += y >> 3;
330
90720
                getmask = (GX_UBYTE)(0x80 >> (y & 0x07));
331
332
90720
                if (*get & getmask)
333
                {
334
39192
                    *put |= putmask;
335
                }
336
                else
337
                {
338
51528
                    *put &= (GX_UBYTE)(~putmask);
339
                }
340
90720
                putmask >>= 1;
341
90720
                if (putmask == 0)
342
                {
343
10800
                    put++;
344
10800
                    putmask = 0x80;
345
                }
346
            }
347
720
            putrow += putstride;
348
        }
349
350

3
        if (rot_cx && rot_cy)
351
        {
352
1
            x = *rot_cx;
353
1
            y = *rot_cy;
354
355
1
            *rot_cx = (width - 1 - y);
356
1
            *rot_cy = x;
357
        }
358
    }
359
6
    else if (angle == 180)
360
    {
361
362
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
363
364
381
        for (y = 0; y < height; y++)
365
        {
366
378
            put = putrow;
367
378
            putmask = 0x80;
368
91098
            for (x = 0; x < width; x++)
369
            {
370
90720
                getmask = (GX_UBYTE)(0x80 >> ((width - 1 - x) & 0x07));
371
372
90720
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
373
90720
                get += (height - 1 - y) * getstride;
374
90720
                get += (width - 1 - x) >> 3;
375
376
90720
                if (*get & getmask)
377
                {
378
39192
                    *put |= putmask;
379
                }
380
                else
381
                {
382
51528
                    *put &= (GX_UBYTE)(~putmask);
383
                }
384
90720
                putmask >>= 1;
385
90720
                if (putmask == 0)
386
                {
387
11340
                    put++;
388
11340
                    putmask = 0x80;
389
                }
390
            }
391
378
            putrow += putstride;
392
        }
393

3
        if (rot_cx && rot_cy)
394
        {
395
1
            x = *rot_cx;
396
1
            y = *rot_cy;
397
398
1
            *rot_cx = (width - 1 - x);
399
1
            *rot_cy = (height - 1 - y);
400
        }
401
    }
402
    else
403
    {
404
        /* angle = 270. */
405
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
406
407
723
        for (y = 0; y < height; y++)
408
        {
409
720
            put = putrow;
410
720
            putmask = 0x80;
411
412
91440
            for (x = 0; x < width; x++)
413
            {
414
90720
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
415
90720
                get += x * getstride;
416
90720
                get += (height - 1 - y) >> 3;
417
418
90720
                getmask = (GX_UBYTE)(0x80 >> ((height - 1 - y) & 0x07));
419
420
90720
                if (getmask & (*get))
421
                {
422
39192
                    *put |= putmask;
423
                }
424
                else
425
                {
426
51528
                    *put &= (GX_UBYTE)(~putmask);
427
                }
428
90720
                putmask >>= 1;
429
90720
                if (putmask == 0)
430
                {
431
10800
                    put++;
432
10800
                    putmask = 0x80;
433
                }
434
            }
435
720
            putrow += putstride;
436
        }
437
438

3
        if (rot_cx && rot_cy)
439
        {
440
1
            x = *rot_cx;
441
1
            y = *rot_cy;
442
443
1
            *rot_cx = y;
444
1
            *rot_cy = (height - 1 - x);
445
        }
446
    }
447
448
9
    destination -> gx_pixelmap_height = (GX_VALUE)height;
449
9
    destination -> gx_pixelmap_width = (GX_VALUE)width;
450
451
9
    return GX_SUCCESS;
452
}
453
454
/**************************************************************************/
455
/*                                                                        */
456
/*  FUNCTION                                               RELEASE        */
457
/*                                                                        */
458
/*    _gx_utility_1bpp_pixelmap_simple_transparent_rotate PORTABLE C      */
459
/*                                                           6.1          */
460
/*  AUTHOR                                                                */
461
/*                                                                        */
462
/*    Kenneth Maxwell, Microsoft Corporation                              */
463
/*                                                                        */
464
/*  DESCRIPTION                                                           */
465
/*                                                                        */
466
/*    Internal helper function that handles 90, 180 and 270 degree        */
467
/*      rotation of an uncompressed pixelmap with or wihout alpha.        */
468
/*                                                                        */
469
/*  INPUT                                                                 */
470
/*                                                                        */
471
/*    src                                   The pixelmap to be rotated    */
472
/*    angle                                 The angle to be rotated       */
473
/*    destination                           The rotated bitmap to be      */
474
/*                                            returned                    */
475
/*    rot_cx                                X coordinate of rotation      */
476
/*                                            center                      */
477
/*    rot_cy                                Y coordinate of rotation      */
478
/*                                            center                      */
479
/*                                                                        */
480
/*  OUTPUT                                                                */
481
/*                                                                        */
482
/*    None                                                                */
483
/*                                                                        */
484
/*  CALLS                                                                 */
485
/*                                                                        */
486
/*    _gx_system_memory_allocator           Memory Allocation routine     */
487
/*                                                                        */
488
/*  CALLED BY                                                             */
489
/*                                                                        */
490
/*    _gx_utility_1bpp_pixelmap_simple_rotate                             */
491
/*                                                                        */
492
/*  RELEASE HISTORY                                                       */
493
/*                                                                        */
494
/*    DATE              NAME                      DESCRIPTION             */
495
/*                                                                        */
496
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
497
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
498
/*                                            resulting in version 6.1    */
499
/*                                                                        */
500
/**************************************************************************/
501
15
static UINT _gx_utility_1bpp_pixelmap_simple_transparent_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
502
{
503
GX_UBYTE *put;
504
GX_UBYTE *putrow;
505
GX_UBYTE *get;
506
INT       width, height;
507
INT       x, y;
508
INT       putstride;
509
GX_UBYTE  getmask;
510
GX_UBYTE  putmask;
511
GX_UBYTE  puttransmask;
512
GX_UBYTE  gettransmask;
513
INT       getstride;
514
515
15
    getstride = (src -> gx_pixelmap_width + 3) >> 2;
516
517
15
    width = src -> gx_pixelmap_height;
518
15
    height = src -> gx_pixelmap_width;
519
520
15
    if (angle == 180)
521
    {
522
5
        GX_SWAP_VALS(width, height);
523
    }
524
525
15
    putstride = (width + 3) >> 2;
526
527
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
528
       overflow cannot occur. */
529
15
    destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
530
15
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
531
532
15
    if (destination -> gx_pixelmap_data == GX_NULL)
533
    {
534
6
        return GX_SYSTEM_MEMORY_ERROR;
535
    }
536
537
9
    if (angle == 90)
538
    {
539
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
540
541
558
        for (y = 0; y < height; y++)
542
        {
543
555
            put = putrow;
544
555
            puttransmask = 0x40;
545
555
            putmask = 0x80;
546
547
555
            getmask = (GX_UBYTE)(0x80 >> ((y & 0x03) << 1));
548
555
            gettransmask = (getmask >> 1);
549
550
106260
            for (x = 0; x < width; x++)
551
            {
552
105705
                *put &= (GX_UBYTE)(~puttransmask);
553
105705
                *put &= (GX_UBYTE)(~putmask);
554
555
105705
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
556
105705
                get += (width - 1 - x) * getstride;
557
105705
                get += y >> 2;
558
559
105705
                if (*get & gettransmask)
560
                {
561
57216
                    *put |= puttransmask;
562
563
57216
                    if (*get & getmask)
564
                    {
565
16750
                        *put |= putmask;
566
                    }
567
                }
568
105705
                puttransmask >>= 2;
569
105705
                putmask >>= 2;
570
105705
                if (puttransmask == 0)
571
                {
572
26190
                    put++;
573
26190
                    putmask = 0x80;
574
26190
                    puttransmask = 0x40;
575
                }
576
            }
577
555
            putrow += putstride;
578
        }
579
580

3
        if (rot_cx && rot_cy)
581
        {
582
1
            x = *rot_cx;
583
1
            y = *rot_cy;
584
585
1
            *rot_cx = (width - 1 - y);
586
1
            *rot_cy = x;
587
        }
588
    }
589
6
    else if (angle == 180)
590
    {
591
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
592
593
568
        for (y = 0; y < height; y++)
594
        {
595
565
            put = putrow;
596
565
            putmask = 0x80;
597
565
            puttransmask = 0x40;
598
106270
            for (x = 0; x < width; x++)
599
            {
600
                /* set bits first. */
601
105705
                *put &= (GX_UBYTE)(~putmask);
602
105705
                *put &= (GX_UBYTE)(~puttransmask);
603
604
105705
                gettransmask = (GX_UBYTE)(0x40 >> (((width - 1 - x) & 0x03) << 1));
605
606
105705
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
607
105705
                get += (height - 1 - y) * getstride;
608
105705
                get += (width - 1 - x) >> 2;
609
610
105705
                if (*get & gettransmask)
611
                {
612
57216
                    *put |= puttransmask;
613
57216
                    getmask = (GX_UBYTE)(gettransmask << 1);
614
57216
                    if (*get & getmask)
615
                    {
616
16750
                        *put |= putmask;
617
                    }
618
                }
619
620
105705
                putmask >>= 2;
621
105705
                puttransmask >>= 2;
622
105705
                if (puttransmask == 0)
623
                {
624
26226
                    put++;
625
26226
                    putmask = 0x80;
626
26226
                    puttransmask = 0x40;
627
                }
628
            }
629
565
            putrow += putstride;
630
        }
631

3
        if (rot_cx && rot_cy)
632
        {
633
1
            x = *rot_cx;
634
1
            y = *rot_cy;
635
636
1
            *rot_cx = (width - 1 - x);
637
1
            *rot_cy = (height - 1 - y);
638
        }
639
    }
640
    else
641
    {
642
        /* angle = 270. */
643
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
644
645
558
        for (y = 0; y < height; y++)
646
        {
647
555
            put = putrow;
648
555
            putmask = 0x80;
649
555
            puttransmask = 0x40;
650
651
106260
            for (x = 0; x < width; x++)
652
            {
653
                /* set bits first. */
654
105705
                *put &= (GX_UBYTE)(~putmask);
655
105705
                *put &= (GX_UBYTE)(~puttransmask);
656
657
105705
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
658
105705
                get += x * getstride;
659
105705
                get += (height - 1 - y) >> 2;
660
661
105705
                gettransmask = (GX_UBYTE)(0x40 >> (((height - 1 - y) & 0x03) << 1));
662
105705
                if (gettransmask & (*get))
663
                {
664
57216
                    *put |= puttransmask;
665
57216
                    getmask = (GX_UBYTE)(gettransmask << 1);
666
57216
                    if (getmask & (*get))
667
                    {
668
16750
                        *put |= putmask;
669
                    }
670
                }
671
672
105705
                putmask >>= 2;
673
105705
                puttransmask >>= 2;
674
105705
                if (puttransmask == 0)
675
                {
676
26190
                    put++;
677
26190
                    putmask = 0x80;
678
26190
                    puttransmask = 0x40;
679
                }
680
            }
681
555
            putrow += putstride;
682
        }
683
684

3
        if (rot_cx && rot_cy)
685
        {
686
1
            x = *rot_cx;
687
1
            y = *rot_cy;
688
689
1
            *rot_cx = y;
690
1
            *rot_cy = (height - 1 - x);
691
        }
692
    }
693
694
9
    destination -> gx_pixelmap_height = (GX_VALUE)height;
695
9
    destination -> gx_pixelmap_width = (GX_VALUE)width;
696
697
9
    return GX_SUCCESS;
698
}
699
/**************************************************************************/
700
/*                                                                        */
701
/*  FUNCTION                                               RELEASE        */
702
/*                                                                        */
703
/*    _gx_utility_1bpp_pixelmap_simple_rotate             PORTABLE C      */
704
/*                                                           6.1          */
705
/*  AUTHOR                                                                */
706
/*                                                                        */
707
/*    Kenneth Maxwell, Microsoft Corporation                              */
708
/*                                                                        */
709
/*  DESCRIPTION                                                           */
710
/*                                                                        */
711
/*    Internal helper function that handles 90, 180 and 270 degree        */
712
/*      rotation of an uncompressed pixelmap with or wihout alpha.        */
713
/*                                                                        */
714
/*  INPUT                                                                 */
715
/*                                                                        */
716
/*    src                                   The pixelmap to be rotated    */
717
/*    angle                                 The angle to be rotated       */
718
/*    destination                           The rotated bitmap to be      */
719
/*                                            returned                    */
720
/*    rot_cx                                X coordinate of rotation      */
721
/*                                            center                      */
722
/*    rot_cy                                Y coordinate of rotation      */
723
/*                                            center                      */
724
/*                                                                        */
725
/*  OUTPUT                                                                */
726
/*                                                                        */
727
/*    None                                                                */
728
/*                                                                        */
729
/*  CALLS                                                                 */
730
/*                                                                        */
731
/*    _gx_utility_1bpp_pixelmap_simple_transparent_rotate                 */
732
/*                                          Real pixelmap rotate function */
733
/*    _gx_utility_1bpp_pixelmap_simple_raw_rotate                         */
734
/*                                          Real pixelmap rotate function */
735
/*                                                                        */
736
/*  CALLED BY                                                             */
737
/*                                                                        */
738
/*    Application Code                                                    */
739
/*                                                                        */
740
/*  RELEASE HISTORY                                                       */
741
/*                                                                        */
742
/*    DATE              NAME                      DESCRIPTION             */
743
/*                                                                        */
744
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
745
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
746
/*                                            resulting in version 6.1    */
747
/*                                                                        */
748
/**************************************************************************/
749
30
UINT _gx_utility_1bpp_pixelmap_simple_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
750
{
751
UINT status;
752
753
30
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
754
    {
755
        /* with transparent, no compression */
756
15
        status = _gx_utility_1bpp_pixelmap_simple_transparent_rotate(src, angle, destination, rot_cx, rot_cy);
757
    }
758
    else
759
    {
760
        /* no compression or transparent */
761
15
        status = _gx_utility_1bpp_pixelmap_simple_raw_rotate(src, angle, destination, rot_cx, rot_cy);
762
    }
763
764
30
    return status;
765
}
766