GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_1555xrgb_pixelmap_rotate.c Lines: 265 265 100.0 %
Date: 2026-03-06 19:21:09 Branches: 100 100 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 REDVAL(_c)   (GX_UBYTE)(((_c) >> 10) & 0x1f)
23
#define GREENVAL(_c) (GX_UBYTE)(((_c) >> 5) & 0x1f)
24
#define BLUEVAL(_c)  (GX_UBYTE)(((_c)) & 0x1f)
25
26
#define ASSEMBLECOLOR(_r, _g, _b)    \
27
    (USHORT)((((_r) & 0x1f) << 10) | \
28
             (((_g) & 0x1f) << 5) |  \
29
             ((_b) & 0x1f))
30
31
#define GX_SOURCE_CODE
32
33
34
/* Include necessary system files.  */
35
36
#include "gx_api.h"
37
#include "gx_display.h"
38
#include "gx_context.h"
39
#include "gx_utility.h"
40
#include "gx_system.h"
41
42
/**************************************************************************/
43
/*                                                                        */
44
/*  FUNCTION                                               RELEASE        */
45
/*                                                                        */
46
/*    _gx_utility_1555xrgb_pixelmap_raw_rotate            PORTABLE C      */
47
/*                                                           6.1          */
48
/*  AUTHOR                                                                */
49
/*                                                                        */
50
/*    Kenneth Maxwell, Microsoft Corporation                              */
51
/*                                                                        */
52
/*  DESCRIPTION                                                           */
53
/*                                                                        */
54
/*    Internal helper function that rotate an 1555xrgb format pixelmap    */
55
/*    without compression, without alpha.                                 */
56
/*                                                                        */
57
/*  INPUT                                                                 */
58
/*                                                                        */
59
/*    src                                   The pixelmap to be rotated    */
60
/*    angle                                 The angle to be rotated       */
61
/*    destination                           The rotated bitmap to be      */
62
/*                                            returned                    */
63
/*    rot_cx                                X coordinate of rotation      */
64
/*                                            center                      */
65
/*    rot_cy                                Y coordinate of rotation      */
66
/*                                            center                      */
67
/*                                                                        */
68
/*  OUTPUT                                                                */
69
/*                                                                        */
70
/*    status                                Completion status             */
71
/*                                                                        */
72
/*  CALLS                                                                 */
73
/*                                                                        */
74
/*    _gx_system_memory_allocator           Memory Allocation routine     */
75
/*    _gx_utility_math_cos                  Compute the cosine value      */
76
/*    _gx_utility_math_sin                  Compute the sine value        */
77
/*                                                                        */
78
/*  CALLED BY                                                             */
79
/*                                                                        */
80
/*    GUIX Internal Code                                                  */
81
/*                                                                        */
82
/**************************************************************************/
83
360
static UINT _gx_utility_1555xrgb_pixelmap_raw_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
84
{
85
USHORT   *put;
86
USHORT   *get;
87
GX_UBYTE *putalpha;
88
INT       srcxres;
89
INT       srcyres;
90
INT       cosv;
91
INT       sinv;
92
USHORT    red, green, blue;
93
INT       idxminx, idxmaxx, idxmaxy;
94
INT      *mx;
95
INT      *my;
96
INT       xres;
97
INT       yres;
98
INT       width, height;
99
INT       x, y;
100
INT       xx, yy;
101
USHORT    a, b, c, d;
102
INT       alpha;
103
INT       xdiff, ydiff;
104
105
360
    mx = _gx_system_scratchpad;
106
360
    my = mx + 4;
107
108
360
    mx[0] = mx[3] = -1;
109
360
    mx[1] = mx[2] = 1;
110
111
360
    my[0] = my[1] = 1;
112
360
    my[2] = my[3] = -1;
113
114
115
360
    idxminx = (angle / 90) & 0x3;
116
360
    idxmaxx = (idxminx + 2) & 0x3;
117
360
    idxmaxy = (idxminx + 1) & 0x3;
118
119
    /* Calculate the source x and y center. */
120
360
    srcxres = src -> gx_pixelmap_width >> 1;
121
360
    srcyres = src -> gx_pixelmap_height >> 1;
122
123
360
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
124
360
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
125
126
360
    xres = mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv;
127
360
    yres = my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv;
128
129
360
    xres = GX_FIXED_VAL_TO_INT(xres);
130
360
    yres = GX_FIXED_VAL_TO_INT(yres);
131
132
    /* Calculate destination width and height. */
133
360
    width = (xres << 1);
134
360
    height = (yres << 1);
135
136
    /* Calculate the new rotation axis. */
137

360
    if (rot_cx && rot_cy)
138
    {
139
356
        x = ((*rot_cx) - srcxres) * cosv - ((*rot_cy) - srcyres) * sinv;
140
356
        y = ((*rot_cy) - srcyres) * cosv + ((*rot_cx) - srcxres) * sinv;
141
142
356
        srcxres = (INT)*rot_cx;
143
356
        srcyres = (INT)*rot_cy;
144
145
356
        x = GX_FIXED_VAL_TO_INT(x) + xres;
146
356
        y = GX_FIXED_VAL_TO_INT(y) + yres;
147
148
356
        *rot_cx = x;
149
356
        *rot_cy = y;
150
151
356
        xres = *rot_cx;
152
356
        yres = *rot_cy;
153
    }
154
155
360
    destination -> gx_pixelmap_height = (GX_VALUE)height;
156
360
    destination -> gx_pixelmap_width = (GX_VALUE)width;
157
360
    destination -> gx_pixelmap_flags |= GX_PIXELMAP_ALPHA;
158
159
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
160
       overflow cannot occur. */
161
360
    destination -> gx_pixelmap_data_size = (UINT)(height * width) * sizeof(USHORT);
162
360
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
163
164
360
    if (destination -> gx_pixelmap_data == GX_NULL)
165
    {
166
2
        return GX_SYSTEM_MEMORY_ERROR;
167
    }
168
169
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
170
       overflow cannot occur. */
171
358
    destination -> gx_pixelmap_aux_data_size = (UINT)(height * width) * sizeof(GX_UBYTE);
172
358
    destination -> gx_pixelmap_aux_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_aux_data_size);
173
174
358
    if (destination -> gx_pixelmap_aux_data == GX_NULL)
175
    {
176
2
        _gx_system_memory_free((VOID *)destination -> gx_pixelmap_data);
177
178
2
        return GX_SYSTEM_MEMORY_ERROR;
179
    }
180
181
356
    put = (USHORT *)destination -> gx_pixelmap_data;
182
356
    putalpha = (GX_UBYTE *)destination -> gx_pixelmap_aux_data;
183
184
    /* Loop through the destination's pixels.  */
185
84748
    for (y = 0; y < height; y++)
186
    {
187
19864616
        for (x = 0; x < width; x++)
188
        {
189
19780224
            xx = (x - xres) * cosv + (y - yres) * sinv;
190
19780224
            yy = (y - yres) * cosv - (x - xres) * sinv;
191
192
19780224
            xdiff = GX_FIXED_VAL_TO_INT(xx << 8) & 0xff;
193
19780224
            ydiff = GX_FIXED_VAL_TO_INT(yy << 8) & 0xff;
194
195
19780224
            xx = GX_FIXED_VAL_TO_INT(xx);
196
19780224
            yy = GX_FIXED_VAL_TO_INT(yy);
197
198
19780224
            xx += srcxres;
199
19780224
            yy += srcyres;
200
201

19780224
            if ((xx >= -1) && (xx < src -> gx_pixelmap_width) &&
202
14425200
                (yy >= -1) && (yy < src -> gx_pixelmap_height))
203
            {
204

10943030
                if ((xx >= 0) && (xx < src -> gx_pixelmap_width - 1) &&
205
10767320
                    (yy >= 0) && (yy < src -> gx_pixelmap_height - 1))
206
                {
207
10681560
                    get = (USHORT *)src -> gx_pixelmap_data;
208
10681560
                    get += yy * src -> gx_pixelmap_width;
209
10681560
                    get += xx;
210
211
10681560
                    a = *get;
212
10681560
                    b = *(get + 1);
213
10681560
                    c = *(get + src -> gx_pixelmap_width);
214
10681560
                    d = *(get + src -> gx_pixelmap_width + 1);
215
216
10681560
                    alpha = 0xff;
217
                }
218
                else
219
                {
220
261470
                    get = (USHORT *)src -> gx_pixelmap_data;
221
222
261470
                    a = 0;
223
261470
                    b = 0;
224
261470
                    c = 0;
225
261470
                    d = 0;
226
261470
                    alpha = 0;
227
228
261470
                    if (xx == -1)
229
                    {
230
                        /* handle left edge.  */
231
45442
                        if (yy >= 0)
232
                        {
233
45132
                            b = *(get + yy * src -> gx_pixelmap_width);
234
45132
                            alpha += xdiff * (256 - ydiff);
235
                        }
236
237
45442
                        if (yy < src -> gx_pixelmap_height - 1)
238
                        {
239
45100
                            d = *(get + (yy + 1) * src -> gx_pixelmap_width);
240
45100
                            alpha += xdiff * ydiff;
241
                        }
242
                    }
243
216028
                    else if (yy == -1)
244
                    {
245
                        /* handle top edge.  */
246
85408
                        c = *(get + xx);
247
85408
                        alpha += ydiff * (256 - xdiff);
248
249
85408
                        if (xx < src -> gx_pixelmap_width - 1)
250
                        {
251
85054
                            d = *(get + xx + 1);
252
85054
                            alpha += xdiff * ydiff;
253
                        }
254
                    }
255
130620
                    else if (xx == src -> gx_pixelmap_width - 1)
256
                    {
257
                        /* handle right edget. */
258
44860
                        a = *(get + yy * src -> gx_pixelmap_width + xx);
259
44860
                        alpha += (256 - xdiff) * (256 - ydiff);
260
261
44860
                        if (yy < src -> gx_pixelmap_height - 1)
262
                        {
263
44496
                            c = *(get + (yy + 1) * src -> gx_pixelmap_width + xx);
264
44496
                            alpha += ydiff * (256 - xdiff);
265
                        }
266
                    }
267
                    else
268
                    {
269
                        /* handle bottom edge. */
270
85760
                        a = *(get + yy * src -> gx_pixelmap_width + xx);
271
85760
                        alpha += (256 - xdiff) * (256 - ydiff);
272
273
85760
                        b = *(get + yy * src -> gx_pixelmap_width + xx + 1);
274
85760
                        alpha += xdiff * (256 - ydiff);
275
                    }
276
277
261470
                    alpha >>= 8;
278
                }
279
280
10943030
                red = (USHORT)((REDVAL(a) * (256 - xdiff) * (256 - ydiff) + \
281
10943030
                                REDVAL(b) * xdiff * (256 - ydiff) +         \
282
10943030
                                REDVAL(c) * ydiff * (256 - xdiff) +         \
283
10943030
                                REDVAL(d) * xdiff * ydiff) >> 16);
284
285
10943030
                green = (USHORT)((GREENVAL(a) * (256 - xdiff) * (256 - ydiff) + \
286
10943030
                                  GREENVAL(b) * xdiff * (256 - ydiff) +         \
287
10943030
                                  GREENVAL(c) * ydiff * (256 - xdiff) +         \
288
10943030
                                  GREENVAL(d) * xdiff * ydiff) >> 16);
289
290
10943030
                blue = (USHORT)((BLUEVAL(a) * (256 - xdiff) * (256 - ydiff) + \
291
10943030
                                 BLUEVAL(b) * xdiff * (256 - ydiff) +         \
292
10943030
                                 BLUEVAL(c) * ydiff * (256 - xdiff) +         \
293
10943030
                                 BLUEVAL(d) * xdiff * ydiff) >> 16);
294
295

10943030
                if (alpha && (alpha < 0xff))
296
                {
297
259270
                    red = (USHORT)((red << 8) / alpha);
298
259270
                    green = (USHORT)((green << 8) / alpha);
299
259270
                    blue = (USHORT)((blue << 8) / alpha);
300
                }
301
302
10943030
                red = red > 31 ? 31 : red;
303
10943030
                green = green > 63 ? 63 : green;
304
10943030
                blue = blue > 31 ? 31 : blue;
305
10943030
                alpha = alpha > 255 ? 255 : alpha;
306
307
10943030
                *put++ = ASSEMBLECOLOR(red, green, blue);
308
10943030
                *putalpha++ = (GX_UBYTE)alpha;
309
            }
310
            else
311
            {
312
8837194
                put++;
313
8837194
                *putalpha++ = 0;
314
            }
315
        }
316
    }
317
318
356
    return GX_SUCCESS;
319
}
320
321
/**************************************************************************/
322
/*                                                                        */
323
/*  FUNCTION                                               RELEASE        */
324
/*                                                                        */
325
/*    _gx_utility_1555xrgb_pixelmap_alpha_rotate          PORTABLE C      */
326
/*                                                           6.1          */
327
/*  AUTHOR                                                                */
328
/*                                                                        */
329
/*    Kenneth Maxwell, Microsoft Corporation                              */
330
/*                                                                        */
331
/*  DESCRIPTION                                                           */
332
/*                                                                        */
333
/*    Internal helper function that rotate an 1555xrgb format pixelmap    */
334
/*    without compression, with alpha.                                    */
335
/*                                                                        */
336
/*  INPUT                                                                 */
337
/*                                                                        */
338
/*    src                                   The pixelmap to be rotated    */
339
/*    angle                                 The angle to be rotated       */
340
/*    destination                           The rotated bitmap to be      */
341
/*                                            returned                    */
342
/*    rot_cx                                X coordinate of rotation      */
343
/*                                            center                      */
344
/*    rot_cy                                Y coordinate of rotation      */
345
/*                                            center                      */
346
/*                                                                        */
347
/*  OUTPUT                                                                */
348
/*                                                                        */
349
/*    status                                Completion status             */
350
/*                                                                        */
351
/*  CALLS                                                                 */
352
/*                                                                        */
353
/*    _gx_system_memory_allocator           Memory Allocation routine     */
354
/*    _gx_utility_math_cos                  Compute the cosine value      */
355
/*    _gx_utility_math_sin                  Compute the sine value        */
356
/*                                                                        */
357
/*  CALLED BY                                                             */
358
/*                                                                        */
359
/*    GUIX Internal Code                                                  */
360
/*                                                                        */
361
/**************************************************************************/
362
628
static UINT _gx_utility_1555xrgb_pixelmap_alpha_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
363
{
364
USHORT   *put;
365
USHORT   *get;
366
GX_UBYTE *putalpha;
367
GX_UBYTE *getalpha;
368
INT       srcxres;
369
INT       srcyres;
370
INT       cosv;
371
INT       sinv;
372
USHORT    red, green, blue;
373
INT       idxminx, idxmaxx, idxmaxy;
374
INT      *mx;
375
INT      *my;
376
INT       xres;
377
INT       yres;
378
INT       width, height;
379
INT       x, y;
380
INT       xx, yy;
381
USHORT    a, b, c, d;
382
USHORT    alpha[4];
383
INT       xdiff, ydiff;
384
385
628
    idxminx = (angle / 90) & 0x3;
386
628
    idxmaxx = (idxminx + 2) & 0x3;
387
628
    idxmaxy = (idxminx + 1) & 0x3;
388
389
628
    mx = _gx_system_scratchpad;
390
628
    my = mx + 4;
391
392
628
    mx[0] = mx[3] = -1;
393
628
    mx[1] = mx[2] = 1;
394
395
628
    my[0] = my[1] = 1;
396
628
    my[2] = my[3] = -1;
397
398
    /* Calculate the source x and y center. */
399
628
    srcxres = src -> gx_pixelmap_width >> 1;
400
628
    srcyres = src -> gx_pixelmap_height >> 1;
401
402
628
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
403
628
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
404
405
628
    xres = mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv;
406
628
    yres = my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv;
407
408
628
    xres = GX_FIXED_VAL_TO_INT(xres);
409
628
    yres = GX_FIXED_VAL_TO_INT(yres);
410
411
    /* Calculate destination width and height. */
412
628
    width = (xres << 1);
413
628
    height = (yres << 1);
414
415
    /* Calculate the new rotation axis. */
416

628
    if (rot_cx && rot_cy)
417
    {
418
624
        x = ((*rot_cx) - srcxres) * cosv - ((*rot_cy) - srcyres) * sinv;
419
624
        y = ((*rot_cy) - srcyres) * cosv + ((*rot_cx) - srcxres) * sinv;
420
421
624
        srcxres = *rot_cx;
422
624
        srcyres = *rot_cy;
423
424
624
        x = GX_FIXED_VAL_TO_INT(x) + xres;
425
624
        y = GX_FIXED_VAL_TO_INT(y) + yres;
426
427
624
        *rot_cx = x;
428
624
        *rot_cy = y;
429
430
624
        xres = *rot_cx;
431
624
        yres = *rot_cy;
432
    }
433
434
628
    destination -> gx_pixelmap_height = (GX_VALUE)height;
435
628
    destination -> gx_pixelmap_width = (GX_VALUE)width;
436
628
    destination -> gx_pixelmap_flags |= GX_PIXELMAP_ALPHA;
437
438
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
439
       overflow cannot occur. */
440
628
    destination -> gx_pixelmap_data_size = (UINT)(height * width) * sizeof(USHORT);
441
628
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
442
443
628
    if (destination -> gx_pixelmap_data == GX_NULL)
444
    {
445
2
        return GX_SYSTEM_MEMORY_ERROR;
446
    }
447
448
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
449
       overflow cannot occur. */
450
626
    destination -> gx_pixelmap_aux_data_size = (UINT)(height * width) * sizeof(GX_UBYTE);
451
626
    destination -> gx_pixelmap_aux_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_aux_data_size);
452
453
626
    if (destination -> gx_pixelmap_aux_data == GX_NULL)
454
    {
455
2
        _gx_system_memory_free((VOID *)destination -> gx_pixelmap_data);
456
457
2
        return GX_SYSTEM_MEMORY_ERROR;
458
    }
459
460
624
    put = (USHORT *)destination -> gx_pixelmap_data;
461
624
    putalpha = (GX_UBYTE *)destination -> gx_pixelmap_aux_data;
462
463
    /* Loop through the destination's pixels.  */
464
165808
    for (y = 0; y < height; y++)
465
    {
466
45591232
        for (x = 0; x < width; x++)
467
        {
468
45426048
            xx = (x - xres) * cosv + (y - yres) * sinv;
469
45426048
            yy = (y - yres) * cosv - (x - xres) * sinv;
470
471
45426048
            xdiff = GX_FIXED_VAL_TO_INT(xx << 8) & 0xff;
472
45426048
            ydiff = GX_FIXED_VAL_TO_INT(yy << 8) & 0xff;
473
474
45426048
            xx = GX_FIXED_VAL_TO_INT(xx);
475
45426048
            yy = GX_FIXED_VAL_TO_INT(yy);
476
477
45426048
            xx += srcxres;
478
45426048
            yy += srcyres;
479
480

45426048
            if ((xx >= -1) && (xx < src -> gx_pixelmap_width) &&
481
30252029
                (yy >= -1) && (yy < src -> gx_pixelmap_height))
482
            {
483
484

26090648
                if ((xx >= 0) && (xx < src -> gx_pixelmap_width - 1) &&
485
25701980
                    (yy >= 0) && (yy < src -> gx_pixelmap_height - 1))
486
                {
487
25584900
                    get = (USHORT *)src -> gx_pixelmap_data;
488
25584900
                    get += yy * src -> gx_pixelmap_width;
489
25584900
                    get += xx;
490
491
25584900
                    getalpha = (GX_UBYTE *)src -> gx_pixelmap_aux_data;
492
25584900
                    getalpha += yy * src -> gx_pixelmap_width;
493
25584900
                    getalpha += xx;
494
495
25584900
                    a = *get;
496
25584900
                    alpha[0] = *getalpha;
497
498
25584900
                    b = *(get + 1);
499
25584900
                    alpha[1] = *(getalpha + 1);
500
501
25584900
                    c = *(get + src -> gx_pixelmap_width);
502
25584900
                    alpha[2] = *(getalpha + src -> gx_pixelmap_width);
503
504
25584900
                    d = *(get + src -> gx_pixelmap_width + 1);
505
25584900
                    alpha[3] = *(getalpha + src -> gx_pixelmap_width + 1);
506
                }
507
                else
508
                {
509
505748
                    get = (USHORT *)src -> gx_pixelmap_data;
510
505748
                    getalpha = (GX_UBYTE *)src -> gx_pixelmap_aux_data;
511
512
505748
                    a = 0;
513
505748
                    b = 0;
514
505748
                    c = 0;
515
505748
                    d = 0;
516
517
505748
                    if (xx == -1)
518
                    {
519
                        /* handle left edge.  */
520
135504
                        if (yy >= 0)
521
                        {
522
134948
                            b = *(get + yy * src -> gx_pixelmap_width);
523
134948
                            alpha[1] = *(getalpha + yy * src -> gx_pixelmap_width);
524
                        }
525
526
135504
                        if (yy < src -> gx_pixelmap_height - 1)
527
                        {
528
134952
                            d = *(get + (yy + 1) * src -> gx_pixelmap_width);
529
134952
                            alpha[3] = *(getalpha + (yy + 1) * src -> gx_pixelmap_width);
530
                        }
531
                    }
532
370244
                    else if (yy == -1)
533
                    {
534
                        /* handle top edge.  */
535
117716
                        c = *(get + xx);
536
117716
                        alpha[2] = *(getalpha + xx);
537
538
117716
                        if (xx < src -> gx_pixelmap_width - 1)
539
                        {
540
117160
                            d = *(get + xx + 1);
541
117160
                            alpha[3] = *(getalpha + xx + 1);
542
                        }
543
                    }
544
252528
                    else if (xx == src -> gx_pixelmap_width - 1)
545
                    {
546
                        /* handle right edget. */
547
135448
                        a = *(get + yy * src -> gx_pixelmap_width + xx);
548
135448
                        alpha[0] = *(getalpha + yy * src -> gx_pixelmap_width + xx);
549
550
135448
                        if (yy < src -> gx_pixelmap_height - 1)
551
                        {
552
134628
                            c = *(get + (yy + 1) * src -> gx_pixelmap_width + xx);
553
134628
                            alpha[2] = *(getalpha + (yy + 1) * src -> gx_pixelmap_width + xx);
554
                        }
555
                    }
556
                    else
557
                    {
558
                        /* handle bottom edge. */
559
117080
                        a = *(get + yy * src -> gx_pixelmap_width + xx);
560
117080
                        alpha[0] = *(getalpha + yy * src -> gx_pixelmap_width + xx);
561
562
117080
                        b = *(get + yy * src -> gx_pixelmap_width + xx + 1);
563
117080
                        alpha[1] = *(getalpha + yy * src -> gx_pixelmap_width + xx + 1);
564
                    }
565
566
505748
                    if (!a)
567
                    {
568
253220
                        alpha[0] = 0;
569
                    }
570
571
505748
                    if (!b)
572
                    {
573
253720
                        alpha[1] = 0;
574
                    }
575
576
505748
                    if (!c)
577
                    {
578
253404
                        alpha[2] = 0;
579
                    }
580
581
505748
                    if (!d)
582
                    {
583
253636
                        alpha[3] = 0;
584
                    }
585
                }
586
587
26090648
                red = (USHORT)((REDVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + \
588
26090648
                                REDVAL(b) * alpha[1] * xdiff * (256 - ydiff) +         \
589
26090648
                                REDVAL(c) * alpha[2] * ydiff * (256 - xdiff) +         \
590
26090648
                                REDVAL(d) * alpha[3] * xdiff * ydiff) >> 16);
591
592
26090648
                green = (USHORT)((GREENVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + \
593
26090648
                                  GREENVAL(b) * alpha[1] * xdiff * (256 - ydiff) +         \
594
26090648
                                  GREENVAL(c) * alpha[2] * ydiff * (256 - xdiff) +         \
595
26090648
                                  GREENVAL(d) * alpha[3] * xdiff * ydiff) >> 16);
596
597
26090648
                blue = (USHORT)((BLUEVAL(a) * alpha[0] * (256 - xdiff) * (256 - ydiff) + \
598
26090648
                                 BLUEVAL(b) * alpha[1] * xdiff * (256 - ydiff) +         \
599
26090648
                                 BLUEVAL(c) * alpha[2] * ydiff * (256 - xdiff) +         \
600
26090648
                                 BLUEVAL(d) * alpha[3] * xdiff * ydiff) >> 16);
601
602
26090648
                alpha[0] = (USHORT)((alpha[0] * (256 - xdiff) * (256 - ydiff) + \
603
26090648
                                     alpha[1] * xdiff * (256 - ydiff) +         \
604
26090648
                                     alpha[2] * ydiff * (256 - xdiff) +         \
605
26090648
                                     alpha[3] * xdiff * ydiff) >> 16);
606
607
26090648
                if (alpha[0])
608
                {
609
16453188
                    red /= alpha[0];
610
16453188
                    green /= alpha[0];
611
16453188
                    blue /= alpha[0];
612
                }
613
614
26090648
                red = red > 31 ? 31 : red;
615
26090648
                green = green > 63 ? 63 : green;
616
26090648
                blue = blue > 31 ? 31 : blue;
617
618
26090648
                *put++ = ASSEMBLECOLOR(red, green, blue);
619
26090648
                *putalpha++ = (GX_UBYTE)alpha[0];
620
            }
621
            else
622
            {
623
19335400
                put++;
624
19335400
                *putalpha++ = 0;
625
            }
626
        }
627
    }
628
629
624
    return GX_SUCCESS;
630
}
631
632
/**************************************************************************/
633
/*                                                                        */
634
/*  FUNCTION                                               RELEASE        */
635
/*                                                                        */
636
/*    _gx_utility_1555xrgb_pixelmap_rotate                PORTABLE C      */
637
/*                                                           6.1          */
638
/*  AUTHOR                                                                */
639
/*                                                                        */
640
/*    Kenneth Maxwell, Microsoft Corporation                              */
641
/*                                                                        */
642
/*  DESCRIPTION                                                           */
643
/*                                                                        */
644
/*    This function rotates an 1555xrgb format uncompressed pixelmap with */
645
/*    or without alpha channel.                                           */
646
/*                                                                        */
647
/*  INPUT                                                                 */
648
/*                                                                        */
649
/*    src                                   The pixelmap to be rotated    */
650
/*    angle                                 The angle to be rotated       */
651
/*    destination                           The rotated bitmap to be      */
652
/*                                            returned                    */
653
/*    rot_cx                                X coordinate of rotation      */
654
/*                                            center                      */
655
/*    rot_cy                                Y coordinate of rotation      */
656
/*                                            center                      */
657
/*                                                                        */
658
/*  OUTPUT                                                                */
659
/*                                                                        */
660
/*    status                                Completion status             */
661
/*                                                                        */
662
/*  CALLS                                                                 */
663
/*                                                                        */
664
/*     _gx_utility_1555xrgb_pixelmap_raw_rotate                           */
665
/*                                          Rotate 1555xrgb format        */
666
/*                                            pixlemap without alpha      */
667
/*     _gx_utility_1555xrgb_pixelmap_alpha_rotate                         */
668
/*                                          Rotate 1555xrgb format        */
669
/*                                            pixelmap with alpha         */
670
/*                                                                        */
671
/*  CALLED BY                                                             */
672
/*                                                                        */
673
/*    GUIX Internal Code                                                  */
674
/*                                                                        */
675
/**************************************************************************/
676
988
UINT _gx_utility_1555xrgb_pixelmap_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
677
{
678
UINT status;
679
680
988
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
681
    {
682
        /* alpha, no compression */
683
628
        status = _gx_utility_1555xrgb_pixelmap_alpha_rotate(src, angle, destination, rot_cx, rot_cy);
684
    }
685
    else
686
    {
687
        /* no compression or alpha */
688
360
        status = _gx_utility_1555xrgb_pixelmap_raw_rotate(src, angle, destination, rot_cx, rot_cy);
689
    }
690
691
988
    return status;
692
}
693