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 /**************************************************************************/
_gx_utility_1bpp_pixelmap_rotate(GX_PIXELMAP * src,INT angle,GX_PIXELMAP * destination,INT * rot_cx,INT * rot_cy)81 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 INT       mx[] = {-1, 1, 1, -1};
92 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 GX_BOOL   InputAlpha = GX_FALSE;
105 
106     idxminx = (angle / 90) & 0x3;
107     idxmaxx = (idxminx + 2) & 0x3;
108     idxmaxy = (idxminx + 1) & 0x3;
109 
110     /* Calculate the source x and y center. */
111     srcxres = src -> gx_pixelmap_width >> 1;
112     srcyres = src -> gx_pixelmap_height >> 1;
113 
114     cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
115     sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
116 
117     xres = GX_FIXED_VAL_TO_INT((mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv));
118     yres = GX_FIXED_VAL_TO_INT((my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv));
119 
120     /* Calculate destination width and height. */
121     width = (xres << 1);
122     height = (yres << 1);
123 
124     if (rot_cx && rot_cy)
125     {
126         /* Calculate the new rotation axis. */
127         x = ((*rot_cx) - srcxres) * cosv - ((*rot_cy) - srcyres) * sinv;
128         y = ((*rot_cy) - srcyres) * cosv + ((*rot_cx) - srcxres) * sinv;
129 
130         x = GX_FIXED_VAL_TO_INT(x) + xres;
131         y = GX_FIXED_VAL_TO_INT(y) + yres;
132 
133         srcxres = *rot_cx;
134         srcyres = *rot_cy;
135 
136         *rot_cx = x;
137         *rot_cy = y;
138 
139         xres = *rot_cx;
140         yres = *rot_cy;
141     }
142 
143     /* Set width and height of destination pixelmap.  */
144     destination -> gx_pixelmap_width = (GX_VALUE)width;
145     destination -> gx_pixelmap_height = (GX_VALUE)height;
146     destination -> gx_pixelmap_flags |= GX_PIXELMAP_TRANSPARENT;
147     putstride = (width + 3) >> 2;
148 
149     if (src -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
150     {
151         getstride = (src -> gx_pixelmap_width + 3) >> 2;
152         InputAlpha = GX_TRUE;
153     }
154     else
155     {
156         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     destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
162     /* Allocate memory for destination pixelmap to load pixel information.  */
163     destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
164 
165     if (destination -> gx_pixelmap_data == GX_NULL)
166     {
167         return GX_SYSTEM_MEMORY_ERROR;
168     }
169 
170     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     for (y = 0; y < height; y++)
175     {
176         put = putrow;
177         putmask = 0x80;
178         putTransmask = 0x40;
179 
180         for (x = 0; x < width; x++)
181         {
182             xx = (x - xres) * cosv + (y - yres) * sinv;
183             yy = (y - yres) * cosv - (x - xres) * sinv;
184 
185             xx = GX_FIXED_VAL_TO_INT(xx) + srcxres;
186             yy = GX_FIXED_VAL_TO_INT(yy) + srcyres;
187 
188             *put = (GX_UBYTE)(*put & (~putTransmask));
189             *put = (GX_UBYTE)(*put & (~putmask));
190             if ((xx >= 0) && (xx < src -> gx_pixelmap_width) &&
191                 (yy >= 0) && (yy < src -> gx_pixelmap_height))
192             {
193                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
194                 get += yy * getstride;
195                 if (InputAlpha)
196                 {
197                     get += xx >> 2;
198                     getTransmask = (GX_UBYTE)(0x40 >> ((xx & 0x03) << 1));
199                     if (*get & getTransmask)
200                     {
201                         *put |= putTransmask;
202                         getmask = (GX_UBYTE)(getTransmask << 1);
203                         if (*get & getmask)
204                         {
205                             *put |= putmask;
206                         }
207                     }
208                 }
209                 else
210                 {
211                     *put |= putTransmask;
212                     get += xx >> 3;
213                     getmask = (GX_UBYTE)(0x80 >> (xx & 0x07));
214                     if (*get & getmask)
215                     {
216                         *put |= putmask;
217                     }
218                 }
219             }
220 
221             putTransmask >>= 2;
222             putmask >>= 2;
223 
224             if (putTransmask == 0)
225             {
226                 put++;
227                 putTransmask = 0x40;
228                 putmask = 0x80;
229             }
230         }
231         putrow += putstride;
232     }
233 
234     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 /**************************************************************************/
_gx_utility_1bpp_pixelmap_simple_raw_rotate(GX_PIXELMAP * src,INT angle,GX_PIXELMAP * destination,INT * rot_cx,INT * rot_cy)283 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     getstride = (src -> gx_pixelmap_width + 7) >> 3;
296 
297     width = src -> gx_pixelmap_height;
298     height = src -> gx_pixelmap_width;
299 
300     if (angle == 180)
301     {
302         GX_SWAP_VALS(width, height);
303     }
304 
305     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     destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
310     destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
311 
312     if (destination -> gx_pixelmap_data == GX_NULL)
313     {
314         return GX_SYSTEM_MEMORY_ERROR;
315     }
316 
317     if (angle == 90)
318     {
319         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
320 
321         for (y = 0; y < height; y++)
322         {
323             put = putrow;
324             putmask = 0x80;
325             for (x = 0; x < width; x++)
326             {
327                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
328                 get += (width - 1 - x) * getstride;
329                 get += y >> 3;
330                 getmask = (GX_UBYTE)(0x80 >> (y & 0x07));
331 
332                 if (*get & getmask)
333                 {
334                     *put |= putmask;
335                 }
336                 else
337                 {
338                     *put &= (GX_UBYTE)(~putmask);
339                 }
340                 putmask >>= 1;
341                 if (putmask == 0)
342                 {
343                     put++;
344                     putmask = 0x80;
345                 }
346             }
347             putrow += putstride;
348         }
349 
350         if (rot_cx && rot_cy)
351         {
352             x = *rot_cx;
353             y = *rot_cy;
354 
355             *rot_cx = (width - 1 - y);
356             *rot_cy = x;
357         }
358     }
359     else if (angle == 180)
360     {
361 
362         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
363 
364         for (y = 0; y < height; y++)
365         {
366             put = putrow;
367             putmask = 0x80;
368             for (x = 0; x < width; x++)
369             {
370                 getmask = (GX_UBYTE)(0x80 >> ((width - 1 - x) & 0x07));
371 
372                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
373                 get += (height - 1 - y) * getstride;
374                 get += (width - 1 - x) >> 3;
375 
376                 if (*get & getmask)
377                 {
378                     *put |= putmask;
379                 }
380                 else
381                 {
382                     *put &= (GX_UBYTE)(~putmask);
383                 }
384                 putmask >>= 1;
385                 if (putmask == 0)
386                 {
387                     put++;
388                     putmask = 0x80;
389                 }
390             }
391             putrow += putstride;
392         }
393         if (rot_cx && rot_cy)
394         {
395             x = *rot_cx;
396             y = *rot_cy;
397 
398             *rot_cx = (width - 1 - x);
399             *rot_cy = (height - 1 - y);
400         }
401     }
402     else
403     {
404         /* angle = 270. */
405         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
406 
407         for (y = 0; y < height; y++)
408         {
409             put = putrow;
410             putmask = 0x80;
411 
412             for (x = 0; x < width; x++)
413             {
414                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
415                 get += x * getstride;
416                 get += (height - 1 - y) >> 3;
417 
418                 getmask = (GX_UBYTE)(0x80 >> ((height - 1 - y) & 0x07));
419 
420                 if (getmask & (*get))
421                 {
422                     *put |= putmask;
423                 }
424                 else
425                 {
426                     *put &= (GX_UBYTE)(~putmask);
427                 }
428                 putmask >>= 1;
429                 if (putmask == 0)
430                 {
431                     put++;
432                     putmask = 0x80;
433                 }
434             }
435             putrow += putstride;
436         }
437 
438         if (rot_cx && rot_cy)
439         {
440             x = *rot_cx;
441             y = *rot_cy;
442 
443             *rot_cx = y;
444             *rot_cy = (height - 1 - x);
445         }
446     }
447 
448     destination -> gx_pixelmap_height = (GX_VALUE)height;
449     destination -> gx_pixelmap_width = (GX_VALUE)width;
450 
451     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 /**************************************************************************/
_gx_utility_1bpp_pixelmap_simple_transparent_rotate(GX_PIXELMAP * src,INT angle,GX_PIXELMAP * destination,INT * rot_cx,INT * rot_cy)501 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     getstride = (src -> gx_pixelmap_width + 3) >> 2;
516 
517     width = src -> gx_pixelmap_height;
518     height = src -> gx_pixelmap_width;
519 
520     if (angle == 180)
521     {
522         GX_SWAP_VALS(width, height);
523     }
524 
525     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     destination -> gx_pixelmap_data_size = (UINT)(putstride * height) * sizeof(GX_UBYTE);
530     destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
531 
532     if (destination -> gx_pixelmap_data == GX_NULL)
533     {
534         return GX_SYSTEM_MEMORY_ERROR;
535     }
536 
537     if (angle == 90)
538     {
539         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
540 
541         for (y = 0; y < height; y++)
542         {
543             put = putrow;
544             puttransmask = 0x40;
545             putmask = 0x80;
546 
547             getmask = (GX_UBYTE)(0x80 >> ((y & 0x03) << 1));
548             gettransmask = (getmask >> 1);
549 
550             for (x = 0; x < width; x++)
551             {
552                 *put &= (GX_UBYTE)(~puttransmask);
553                 *put &= (GX_UBYTE)(~putmask);
554 
555                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
556                 get += (width - 1 - x) * getstride;
557                 get += y >> 2;
558 
559                 if (*get & gettransmask)
560                 {
561                     *put |= puttransmask;
562 
563                     if (*get & getmask)
564                     {
565                         *put |= putmask;
566                     }
567                 }
568                 puttransmask >>= 2;
569                 putmask >>= 2;
570                 if (puttransmask == 0)
571                 {
572                     put++;
573                     putmask = 0x80;
574                     puttransmask = 0x40;
575                 }
576             }
577             putrow += putstride;
578         }
579 
580         if (rot_cx && rot_cy)
581         {
582             x = *rot_cx;
583             y = *rot_cy;
584 
585             *rot_cx = (width - 1 - y);
586             *rot_cy = x;
587         }
588     }
589     else if (angle == 180)
590     {
591         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
592 
593         for (y = 0; y < height; y++)
594         {
595             put = putrow;
596             putmask = 0x80;
597             puttransmask = 0x40;
598             for (x = 0; x < width; x++)
599             {
600                 /* set bits first. */
601                 *put &= (GX_UBYTE)(~putmask);
602                 *put &= (GX_UBYTE)(~puttransmask);
603 
604                 gettransmask = (GX_UBYTE)(0x40 >> (((width - 1 - x) & 0x03) << 1));
605 
606                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
607                 get += (height - 1 - y) * getstride;
608                 get += (width - 1 - x) >> 2;
609 
610                 if (*get & gettransmask)
611                 {
612                     *put |= puttransmask;
613                     getmask = (GX_UBYTE)(gettransmask << 1);
614                     if (*get & getmask)
615                     {
616                         *put |= putmask;
617                     }
618                 }
619 
620                 putmask >>= 2;
621                 puttransmask >>= 2;
622                 if (puttransmask == 0)
623                 {
624                     put++;
625                     putmask = 0x80;
626                     puttransmask = 0x40;
627                 }
628             }
629             putrow += putstride;
630         }
631         if (rot_cx && rot_cy)
632         {
633             x = *rot_cx;
634             y = *rot_cy;
635 
636             *rot_cx = (width - 1 - x);
637             *rot_cy = (height - 1 - y);
638         }
639     }
640     else
641     {
642         /* angle = 270. */
643         putrow = (GX_UBYTE *)destination -> gx_pixelmap_data;
644 
645         for (y = 0; y < height; y++)
646         {
647             put = putrow;
648             putmask = 0x80;
649             puttransmask = 0x40;
650 
651             for (x = 0; x < width; x++)
652             {
653                 /* set bits first. */
654                 *put &= (GX_UBYTE)(~putmask);
655                 *put &= (GX_UBYTE)(~puttransmask);
656 
657                 get = (GX_UBYTE *)src -> gx_pixelmap_data;
658                 get += x * getstride;
659                 get += (height - 1 - y) >> 2;
660 
661                 gettransmask = (GX_UBYTE)(0x40 >> (((height - 1 - y) & 0x03) << 1));
662                 if (gettransmask & (*get))
663                 {
664                     *put |= puttransmask;
665                     getmask = (GX_UBYTE)(gettransmask << 1);
666                     if (getmask & (*get))
667                     {
668                         *put |= putmask;
669                     }
670                 }
671 
672                 putmask >>= 2;
673                 puttransmask >>= 2;
674                 if (puttransmask == 0)
675                 {
676                     put++;
677                     putmask = 0x80;
678                     puttransmask = 0x40;
679                 }
680             }
681             putrow += putstride;
682         }
683 
684         if (rot_cx && rot_cy)
685         {
686             x = *rot_cx;
687             y = *rot_cy;
688 
689             *rot_cx = y;
690             *rot_cy = (height - 1 - x);
691         }
692     }
693 
694     destination -> gx_pixelmap_height = (GX_VALUE)height;
695     destination -> gx_pixelmap_width = (GX_VALUE)width;
696 
697     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 /**************************************************************************/
_gx_utility_1bpp_pixelmap_simple_rotate(GX_PIXELMAP * src,INT angle,GX_PIXELMAP * destination,INT * rot_cx,INT * rot_cy)749 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     if (src -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
754     {
755         /* with transparent, no compression */
756         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         status = _gx_utility_1bpp_pixelmap_simple_raw_rotate(src, angle, destination, rot_cx, rot_cy);
762     }
763 
764     return status;
765 }
766 
767