GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_1bpp_pixelmap_rotate.c Lines: 265 265 100.0 %
Date: 2026-03-06 19:21:09 Branches: 126 126 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_display.h"
29
#include "gx_context.h"
30
#include "gx_utility.h"
31
#include "gx_system.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_utility_1bpp_pixelmap_rotate                    PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    1bpp pixelmap rotation function that handles uncompress, with or    */
46
/*    without alpha channel.                                              */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    src                                   The pixelmap to be rotated    */
51
/*    angle                                 The angle to be rotated       */
52
/*    destination                           The rotated bitmap to be      */
53
/*                                            returned                    */
54
/*    rot_cx                                X coordinate of rotation      */
55
/*                                            center                      */
56
/*    rot_cy                                Y coordinate of rotation      */
57
/*                                            center                      */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*    None                                                                */
62
/*                                                                        */
63
/*  CALLS                                                                 */
64
/*                                                                        */
65
/*    _gx_system_memory_allocator           Memory Allocation routine     */
66
/*    _gx_utility_math_cos                  Compute the cosine value      */
67
/*    _gx_utility_math_sin                  Compute the sine value        */
68
/*                                                                        */
69
/*  CALLED BY                                                             */
70
/*                                                                        */
71
/*    Application Code                                                    */
72
/*                                                                        */
73
/**************************************************************************/
74
720
UINT _gx_utility_1bpp_pixelmap_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
75
{
76
GX_UBYTE *putrow;
77
GX_UBYTE *put;
78
GX_UBYTE *get;
79
INT       srcxres;
80
INT       srcyres;
81
INT       cosv;
82
INT       sinv;
83
INT       idxminx, idxmaxx, idxmaxy;
84
720
INT       mx[] = {-1, 1, 1, -1};
85
720
INT       my[] = {1, 1, -1, -1};
86
INT       xres;
87
INT       yres;
88
INT       width, height;
89
INT       x, y;
90
INT       xx, yy;
91
INT       putstride;
92
INT       getstride;
93
GX_UBYTE  putmask;
94
GX_UBYTE  putTransmask;
95
GX_UBYTE  getTransmask;
96
GX_UBYTE  getmask;
97
720
GX_BOOL   InputAlpha = GX_FALSE;
98
99
720
    idxminx = (angle / 90) & 0x3;
100
720
    idxmaxx = (idxminx + 2) & 0x3;
101
720
    idxmaxy = (idxminx + 1) & 0x3;
102
103
    /* Calculate the source x and y center. */
104
720
    srcxres = src -> gx_pixelmap_width >> 1;
105
720
    srcyres = src -> gx_pixelmap_height >> 1;
106
107
720
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
108
720
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
109
110
720
    xres = GX_FIXED_VAL_TO_INT((mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv));
111
720
    yres = GX_FIXED_VAL_TO_INT((my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv));
112
113
    /* Calculate destination width and height. */
114
720
    width = (xres << 1);
115
720
    height = (yres << 1);
116
117

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

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

3
        if (rot_cx && rot_cy)
336
        {
337
1
            x = *rot_cx;
338
1
            y = *rot_cy;
339
340
1
            *rot_cx = (width - 1 - y);
341
1
            *rot_cy = x;
342
        }
343
    }
344
6
    else if (angle == 180)
345
    {
346
347
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
348
349
381
        for (y = 0; y < height; y++)
350
        {
351
378
            put = putrow;
352
378
            putmask = 0x80;
353
91098
            for (x = 0; x < width; x++)
354
            {
355
90720
                getmask = (GX_UBYTE)(0x80 >> ((width - 1 - x) & 0x07));
356
357
90720
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
358
90720
                get += (height - 1 - y) * getstride;
359
90720
                get += (width - 1 - x) >> 3;
360
361
90720
                if (*get & getmask)
362
                {
363
39192
                    *put |= putmask;
364
                }
365
                else
366
                {
367
51528
                    *put &= (GX_UBYTE)(~putmask);
368
                }
369
90720
                putmask >>= 1;
370
90720
                if (putmask == 0)
371
                {
372
11340
                    put++;
373
11340
                    putmask = 0x80;
374
                }
375
            }
376
378
            putrow += putstride;
377
        }
378

3
        if (rot_cx && rot_cy)
379
        {
380
1
            x = *rot_cx;
381
1
            y = *rot_cy;
382
383
1
            *rot_cx = (width - 1 - x);
384
1
            *rot_cy = (height - 1 - y);
385
        }
386
    }
387
    else
388
    {
389
        /* angle = 270. */
390
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
391
392
723
        for (y = 0; y < height; y++)
393
        {
394
720
            put = putrow;
395
720
            putmask = 0x80;
396
397
91440
            for (x = 0; x < width; x++)
398
            {
399
90720
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
400
90720
                get += x * getstride;
401
90720
                get += (height - 1 - y) >> 3;
402
403
90720
                getmask = (GX_UBYTE)(0x80 >> ((height - 1 - y) & 0x07));
404
405
90720
                if (getmask & (*get))
406
                {
407
39192
                    *put |= putmask;
408
                }
409
                else
410
                {
411
51528
                    *put &= (GX_UBYTE)(~putmask);
412
                }
413
90720
                putmask >>= 1;
414
90720
                if (putmask == 0)
415
                {
416
10800
                    put++;
417
10800
                    putmask = 0x80;
418
                }
419
            }
420
720
            putrow += putstride;
421
        }
422
423

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

3
        if (rot_cx && rot_cy)
558
        {
559
1
            x = *rot_cx;
560
1
            y = *rot_cy;
561
562
1
            *rot_cx = (width - 1 - y);
563
1
            *rot_cy = x;
564
        }
565
    }
566
6
    else if (angle == 180)
567
    {
568
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
569
570
568
        for (y = 0; y < height; y++)
571
        {
572
565
            put = putrow;
573
565
            putmask = 0x80;
574
565
            puttransmask = 0x40;
575
106270
            for (x = 0; x < width; x++)
576
            {
577
                /* set bits first. */
578
105705
                *put &= (GX_UBYTE)(~putmask);
579
105705
                *put &= (GX_UBYTE)(~puttransmask);
580
581
105705
                gettransmask = (GX_UBYTE)(0x40 >> (((width - 1 - x) & 0x03) << 1));
582
583
105705
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
584
105705
                get += (height - 1 - y) * getstride;
585
105705
                get += (width - 1 - x) >> 2;
586
587
105705
                if (*get & gettransmask)
588
                {
589
57216
                    *put |= puttransmask;
590
57216
                    getmask = (GX_UBYTE)(gettransmask << 1);
591
57216
                    if (*get & getmask)
592
                    {
593
16750
                        *put |= putmask;
594
                    }
595
                }
596
597
105705
                putmask >>= 2;
598
105705
                puttransmask >>= 2;
599
105705
                if (puttransmask == 0)
600
                {
601
26226
                    put++;
602
26226
                    putmask = 0x80;
603
26226
                    puttransmask = 0x40;
604
                }
605
            }
606
565
            putrow += putstride;
607
        }
608

3
        if (rot_cx && rot_cy)
609
        {
610
1
            x = *rot_cx;
611
1
            y = *rot_cy;
612
613
1
            *rot_cx = (width - 1 - x);
614
1
            *rot_cy = (height - 1 - y);
615
        }
616
    }
617
    else
618
    {
619
        /* angle = 270. */
620
3
        putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
621
622
558
        for (y = 0; y < height; y++)
623
        {
624
555
            put = putrow;
625
555
            putmask = 0x80;
626
555
            puttransmask = 0x40;
627
628
106260
            for (x = 0; x < width; x++)
629
            {
630
                /* set bits first. */
631
105705
                *put &= (GX_UBYTE)(~putmask);
632
105705
                *put &= (GX_UBYTE)(~puttransmask);
633
634
105705
                get = (GX_UBYTE *)src -> gx_pixelmap_data;
635
105705
                get += x * getstride;
636
105705
                get += (height - 1 - y) >> 2;
637
638
105705
                gettransmask = (GX_UBYTE)(0x40 >> (((height - 1 - y) & 0x03) << 1));
639
105705
                if (gettransmask & (*get))
640
                {
641
57216
                    *put |= puttransmask;
642
57216
                    getmask = (GX_UBYTE)(gettransmask << 1);
643
57216
                    if (getmask & (*get))
644
                    {
645
16750
                        *put |= putmask;
646
                    }
647
                }
648
649
105705
                putmask >>= 2;
650
105705
                puttransmask >>= 2;
651
105705
                if (puttransmask == 0)
652
                {
653
26190
                    put++;
654
26190
                    putmask = 0x80;
655
26190
                    puttransmask = 0x40;
656
                }
657
            }
658
555
            putrow += putstride;
659
        }
660
661

3
        if (rot_cx && rot_cy)
662
        {
663
1
            x = *rot_cx;
664
1
            y = *rot_cy;
665
666
1
            *rot_cx = y;
667
1
            *rot_cy = (height - 1 - x);
668
        }
669
    }
670
671
9
    destination -> gx_pixelmap_height = (GX_VALUE)height;
672
9
    destination -> gx_pixelmap_width = (GX_VALUE)width;
673
674
9
    return GX_SUCCESS;
675
}
676
/**************************************************************************/
677
/*                                                                        */
678
/*  FUNCTION                                               RELEASE        */
679
/*                                                                        */
680
/*    _gx_utility_1bpp_pixelmap_simple_rotate             PORTABLE C      */
681
/*                                                           6.1          */
682
/*  AUTHOR                                                                */
683
/*                                                                        */
684
/*    Kenneth Maxwell, Microsoft Corporation                              */
685
/*                                                                        */
686
/*  DESCRIPTION                                                           */
687
/*                                                                        */
688
/*    Internal helper function that handles 90, 180 and 270 degree        */
689
/*      rotation of an uncompressed pixelmap with or wihout alpha.        */
690
/*                                                                        */
691
/*  INPUT                                                                 */
692
/*                                                                        */
693
/*    src                                   The pixelmap to be rotated    */
694
/*    angle                                 The angle to be rotated       */
695
/*    destination                           The rotated bitmap to be      */
696
/*                                            returned                    */
697
/*    rot_cx                                X coordinate of rotation      */
698
/*                                            center                      */
699
/*    rot_cy                                Y coordinate of rotation      */
700
/*                                            center                      */
701
/*                                                                        */
702
/*  OUTPUT                                                                */
703
/*                                                                        */
704
/*    None                                                                */
705
/*                                                                        */
706
/*  CALLS                                                                 */
707
/*                                                                        */
708
/*    _gx_utility_1bpp_pixelmap_simple_transparent_rotate                 */
709
/*                                          Real pixelmap rotate function */
710
/*    _gx_utility_1bpp_pixelmap_simple_raw_rotate                         */
711
/*                                          Real pixelmap rotate function */
712
/*                                                                        */
713
/*  CALLED BY                                                             */
714
/*                                                                        */
715
/*    Application Code                                                    */
716
/*                                                                        */
717
/**************************************************************************/
718
30
UINT _gx_utility_1bpp_pixelmap_simple_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
719
{
720
UINT status;
721
722
30
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
723
    {
724
        /* with transparent, no compression */
725
15
        status = _gx_utility_1bpp_pixelmap_simple_transparent_rotate(src, angle, destination, rot_cx, rot_cy);
726
    }
727
    else
728
    {
729
        /* no compression or transparent */
730
15
        status = _gx_utility_1bpp_pixelmap_simple_raw_rotate(src, angle, destination, rot_cx, rot_cy);
731
    }
732
733
30
    return status;
734
}
735