GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_8bpp_pixelmap_resize.c Lines: 161 161 100.0 %
Date: 2026-03-06 19:21:09 Branches: 44 44 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
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_utility.h"
28
#include "gx_system.h"
29
30
#define REDVAL_332(_c)   (((_c) >> 5) & 0x07)
31
#define GREENVAL_332(_c) (((_c) >> 2) & 0x07)
32
#define BLUEVAL_332(_c)  ((_c) & 0x03)
33
34
#define ASSEMBLECOLOR_332(_r, _g, _b)        \
35
    ((((_r) & 0x07) << 5)                  | \
36
     (((_g) & 0x07) << 2)                  | \
37
     ((_b) & 0x03))
38
39
40
/**************************************************************************/
41
/*                                                                        */
42
/*  FUNCTION                                               RELEASE        */
43
/*                                                                        */
44
/*    _gx_utility_8bpp_pixelmap_raw_resize                PORTABLE C      */
45
/*                                                           6.1.7        */
46
/*  AUTHOR                                                                */
47
/*                                                                        */
48
/*    Kenneth Maxwell, Microsoft Corporation                              */
49
/*                                                                        */
50
/*  DESCRIPTION                                                           */
51
/*                                                                        */
52
/*    Internal helper function that resize 8bpp format uncompressed       */
53
/*    pixelmap with or without transparent channel.                       */
54
/*                                                                        */
55
/*  INPUT                                                                 */
56
/*                                                                        */
57
/*    src                                   The source pixelmap           */
58
/*    destination                           The resized pixelmap to be    */
59
/*                                            returned                    */
60
/*    width                                 New width                     */
61
/*    height                                New height                    */
62
/*                                                                        */
63
/*  OUTPUT                                                                */
64
/*                                                                        */
65
/*    status                                Completion status             */
66
/*                                                                        */
67
/*  CALLS                                                                 */
68
/*                                                                        */
69
/*    _gx_system_memory_allocator           Application defined memory    */
70
/*                                            allocation function         */
71
/*                                                                        */
72
/*  CALLED BY                                                             */
73
/*                                                                        */
74
/*    GUIX Internal Code                                                  */
75
/*                                                                        */
76
/**************************************************************************/
77
539
static UINT _gx_utility_8bpp_pixelmap_raw_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height)
78
{
79
/* The pixelmap resize function is implemented from nearest neighbor
80
   image scaling algorithm.  */
81
82
GX_UBYTE *get;
83
GX_UBYTE *put;
84
INT       xradio;
85
INT       yradio;
86
INT       x;
87
INT       y;
88
INT       xx;
89
INT       yy;
90
91
    /* Calculate scale ratio and enlarge it by 256 times to keep precision.  */
92
539
    xradio = ((src -> gx_pixelmap_width) << 8) / width;
93
539
    yradio = ((src -> gx_pixelmap_height) << 8) / height;
94
95
    /* Fill property values into destination pixelmap structure. */
96
539
    destination -> gx_pixelmap_flags = src -> gx_pixelmap_flags;
97
539
    destination -> gx_pixelmap_format = src -> gx_pixelmap_format;
98
539
    destination -> gx_pixelmap_transparent_color = src -> gx_pixelmap_transparent_color;
99
539
    destination -> gx_pixelmap_version_major = src -> gx_pixelmap_version_major;
100
539
    destination -> gx_pixelmap_version_minor = src -> gx_pixelmap_version_minor;
101
102
539
    destination -> gx_pixelmap_height = (GX_VALUE)height;
103
539
    destination -> gx_pixelmap_width = (GX_VALUE)width;
104
105
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
106
       overflow cannot occur. */
107
539
    destination -> gx_pixelmap_data_size = (UINT)(height * width) * sizeof(GX_UBYTE);
108
109
    /* Allocate memory to load pixelmap data. */
110
539
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
111
112
539
    if (destination -> gx_pixelmap_data == GX_NULL)
113
    {
114
2
        return GX_SYSTEM_MEMORY_ERROR;
115
    }
116
117
537
    put = (GX_UBYTE *)destination -> gx_pixelmap_data;
118
119
    /* Loop through destination's pixel and fill each pixel with the nearest neighbor.  */
120
100323
    for (y = 0; y < height; y++)
121
    {
122
16008791
        for (x = 0; x < width; x++)
123
        {
124
15909005
            xx = (xradio * x) >> 8;
125
15909005
            yy = (yradio * y) >> 8;
126
127
15909005
            get = (GX_UBYTE *)src -> gx_pixelmap_data;
128
15909005
            get += yy * src -> gx_pixelmap_width;
129
15909005
            get += xx;
130
131
15909005
            *put++ = *get;
132
        }
133
    }
134
135
537
    return GX_SUCCESS;
136
}
137
138
/**************************************************************************/
139
/*                                                                        */
140
/*  FUNCTION                                               RELEASE        */
141
/*                                                                        */
142
/*    _gx_utility_8bpp_pixelmap_alpha_resize              PORTABLE C      */
143
/*                                                           6.1.7        */
144
/*  AUTHOR                                                                */
145
/*                                                                        */
146
/*    Kenneth Maxwell, Microsoft Corporation                              */
147
/*                                                                        */
148
/*  DESCRIPTION                                                           */
149
/*                                                                        */
150
/*    Internal helper function that resize an 8bpp format uncompressed    */
151
/*    pixelmap with transparent channel.                                  */
152
/*                                                                        */
153
/*  INPUT                                                                 */
154
/*                                                                        */
155
/*    src                                   The source pixelmap           */
156
/*    destination                           The resized pixelmap to be    */
157
/*                                            returned                    */
158
/*    width                                 New width                     */
159
/*    height                                New height                    */
160
/*                                                                        */
161
/*  OUTPUT                                                                */
162
/*                                                                        */
163
/*    status                                Completion status             */
164
/*                                                                        */
165
/*  CALLS                                                                 */
166
/*                                                                        */
167
/*    _gx_system_memory_allocator           Application defined memory    */
168
/*                                            allocation function         */
169
/*                                                                        */
170
/*  CALLED BY                                                             */
171
/*                                                                        */
172
/*    GUIX Internal Code                                                  */
173
/*                                                                        */
174
/**************************************************************************/
175
108
static UINT _gx_utility_8bpp_pixelmap_alpha_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height)
176
{
177
/* The pixelmap resize function is implemented from bilinear interpolation
178
   image scaling algorithm.  */
179
GX_UBYTE *get;
180
GX_UBYTE *put;
181
GX_UBYTE *getalpha;
182
GX_UBYTE *putalpha;
183
INT       xdiff;
184
INT       ydiff;
185
INT       xradio;
186
INT       yradio;
187
INT       x;
188
INT       y;
189
INT       xx;
190
INT       yy;
191
GX_UBYTE  neighbor_pixels[2][2];
192
GX_COLOR  alpha[4];
193
GX_COLOR  red;
194
GX_COLOR  green;
195
GX_COLOR  blue;
196
197
    /* Calculate scale ratio and enlarge it by 256 times to keep precision.  */
198
108
    xradio = ((src -> gx_pixelmap_width) << 8) / width;
199
108
    yradio = ((src -> gx_pixelmap_height) << 8) / height;
200
201
    /* Fill property values into destination pixelmap structure. */
202
108
    destination -> gx_pixelmap_flags = src -> gx_pixelmap_flags;
203
108
    destination -> gx_pixelmap_format = src -> gx_pixelmap_format;
204
205
108
    destination -> gx_pixelmap_height = (GX_VALUE)height;
206
108
    destination -> gx_pixelmap_width = (GX_VALUE)width;
207
208
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
209
       overflow cannot occur. */
210
108
    destination -> gx_pixelmap_data_size = (UINT)(height * width) * sizeof(GX_UBYTE);
211
212
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
213
       overflow cannot occur. */
214
108
    destination -> gx_pixelmap_aux_data_size = (UINT)(height * width) * sizeof(GX_UBYTE);
215
216
    /* Allocate memory to load pixelmap data. */
217
108
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
218
219
108
    if (destination -> gx_pixelmap_data == GX_NULL)
220
    {
221
1
        return GX_SYSTEM_MEMORY_ERROR;
222
    }
223
224
107
    destination -> gx_pixelmap_aux_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_aux_data_size);
225
226
107
    if (destination -> gx_pixelmap_aux_data == GX_NULL)
227
    {
228
1
        _gx_system_memory_free((void *)destination -> gx_pixelmap_data);
229
1
        return GX_SYSTEM_MEMORY_ERROR;
230
    }
231
232
106
    put = (GX_UBYTE *)destination -> gx_pixelmap_data;
233
106
    putalpha = (GX_UBYTE *)destination -> gx_pixelmap_aux_data;
234
235
    /* Loop through destination's pixel and fill each pixel with
236
       the interpolation of 4 nearest neighboring pixels.*/
237
15309
    for (y = 0; y < height; y++)
238
    {
239
2648183
        for (x = 0; x < width; x++)
240
        {
241
            /* Find the original source pixel that the destination pixel conrespond to. */
242
2632980
            xx = (xradio * x) >> 8;
243
2632980
            yy = (yradio * y) >> 8;
244
245
            /* The coordinates of the original source pixel are truncate value,
246
               calucate their distance between the mathematical coordinates. */
247
2632980
            xdiff = (xradio * x) & 0xff;
248
2632980
            ydiff = (yradio * y) & 0xff;
249
250
2632980
            get = (GX_UBYTE *)src -> gx_pixelmap_data;
251
2632980
            get += yy * src -> gx_pixelmap_width;
252
2632980
            get += xx;
253
254
2632980
            getalpha = (GX_UBYTE *)src -> gx_pixelmap_aux_data;
255
2632980
            getalpha += yy * src -> gx_pixelmap_width;
256
2632980
            getalpha += xx;
257
258
259
            /* Calculate 4 nearest neighboring pixels around the mathematical point of original pixel. */
260
2632980
            neighbor_pixels[0][0] = *get;
261
2632980
            alpha[0] = *getalpha;
262
263

2632980
            if ((xx < src -> gx_pixelmap_width - 1) && (yy < src -> gx_pixelmap_height - 1))
264
            {
265
2626839
                neighbor_pixels[0][1] = *(get + 1);
266
2626839
                neighbor_pixels[1][0] = *(get + src -> gx_pixelmap_width);
267
2626839
                neighbor_pixels[1][1] = *(get + src -> gx_pixelmap_width + 1);
268
269
2626839
                alpha[1] = *(getalpha + 1);
270
2626839
                alpha[2] = *(getalpha + src -> gx_pixelmap_width);
271
2626839
                alpha[3] = *(getalpha + src -> gx_pixelmap_width + 1);
272
            }
273
            else
274
            {
275
276
6141
                if ((xx == src -> gx_pixelmap_width - 1) &&
277
2007
                    (yy == src -> gx_pixelmap_height - 1))
278
                {
279
                    /* Handle right bottom corder pixel.  */
280
6
                    neighbor_pixels[0][1] = neighbor_pixels[0][0];
281
6
                    neighbor_pixels[1][0] = neighbor_pixels[0][0];
282
6
                    neighbor_pixels[1][1] = neighbor_pixels[0][0];
283
284
6
                    alpha[1] = alpha[0];
285
6
                    alpha[2] = alpha[0];
286
6
                    alpha[3] = alpha[0];
287
                }
288
6135
                else if (xx == src -> gx_pixelmap_width - 1)
289
                {
290
                    /* Handle pixels in right edge.  */
291
2001
                    neighbor_pixels[0][1] = neighbor_pixels[0][0];
292
2001
                    neighbor_pixels[1][0] = *(get + src -> gx_pixelmap_width);
293
2001
                    neighbor_pixels[1][1] = neighbor_pixels[1][0];
294
295
2001
                    alpha[1] = alpha[0];
296
2001
                    alpha[2] = *(getalpha + src -> gx_pixelmap_width);
297
2001
                    alpha[3] = alpha[2];
298
                }
299
                else
300
                {
301
                    /* Handle pixels in bottom edge.  */
302
4134
                    neighbor_pixels[0][1] = *(get + 1);
303
4134
                    neighbor_pixels[1][0] = neighbor_pixels[0][0];
304
4134
                    neighbor_pixels[1][1] = neighbor_pixels[0][1];
305
306
4134
                    alpha[1] = *(getalpha + 1);
307
4134
                    alpha[2] = alpha[0];
308
4134
                    alpha[3] = alpha[1];
309
                }
310
            }
311
312
            /* Calulate pixel values by interpolating 4 neighboring pixels. */
313
2632980
            red = (REDVAL_332(neighbor_pixels[0][0]) * (alpha[0]) * (256 - (GX_COLOR)xdiff) * (256 - (GX_COLOR)ydiff) + \
314
2632980
                   REDVAL_332(neighbor_pixels[0][1]) * (alpha[1]) * (GX_COLOR)xdiff * (256 - (GX_COLOR)ydiff) +         \
315
2632980
                   REDVAL_332(neighbor_pixels[1][0]) * (alpha[2]) * (GX_COLOR)ydiff * (256 - (GX_COLOR)xdiff) +         \
316
2632980
                   REDVAL_332(neighbor_pixels[1][1]) * (alpha[3]) * (GX_COLOR)xdiff * (GX_COLOR)ydiff) >> 16;
317
318
2632980
            green = (GREENVAL_332(neighbor_pixels[0][0]) * (alpha[0]) * (256 - (GX_COLOR)xdiff) * (256 - (GX_COLOR)ydiff) + \
319
2632980
                     GREENVAL_332(neighbor_pixels[0][1]) * (alpha[1]) * (GX_COLOR)xdiff * (256 - (GX_COLOR)ydiff) +         \
320
2632980
                     GREENVAL_332(neighbor_pixels[1][0]) * (alpha[2]) * (GX_COLOR)ydiff * (256 - (GX_COLOR)xdiff) +         \
321
2632980
                     GREENVAL_332(neighbor_pixels[1][1]) * (alpha[3]) * (GX_COLOR)xdiff * (GX_COLOR)ydiff) >> 16;
322
323
2632980
            blue = (BLUEVAL_332(neighbor_pixels[0][0]) * (alpha[0]) * (256 - (GX_COLOR)xdiff) * (256 - (GX_COLOR)ydiff) + \
324
2632980
                    BLUEVAL_332(neighbor_pixels[0][1]) * (alpha[1]) * (GX_COLOR)xdiff * (256 - (GX_COLOR)ydiff) +         \
325
2632980
                    BLUEVAL_332(neighbor_pixels[1][0]) * (alpha[2]) * (GX_COLOR)ydiff * (256 - (GX_COLOR)xdiff) +         \
326
2632980
                    BLUEVAL_332(neighbor_pixels[1][1]) * (alpha[3]) * (GX_COLOR)xdiff * (GX_COLOR)ydiff) >> 16;
327
328
2632980
            alpha[0] = ((alpha[0]) * (256 - (GX_COLOR)xdiff) * (256 - (GX_COLOR)ydiff) + \
329
2632980
                        (alpha[1]) * (GX_COLOR)xdiff * (256 - (GX_COLOR)ydiff) +         \
330
2632980
                        (alpha[2]) * (GX_COLOR)ydiff * (256 - (GX_COLOR)xdiff) +         \
331
2632980
                        (alpha[3]) * (GX_COLOR)xdiff * (GX_COLOR)ydiff) >> 16;
332
333
2632980
            if (alpha[0])
334
            {
335
1161470
                red /= alpha[0];
336
1161470
                green /= alpha[0];
337
1161470
                blue /= alpha[0];
338
            }
339
340
2632980
            alpha[0] = alpha[0] > 255 ? 255 : alpha[0];
341
2632980
            red = red > 7 ? 7 : red;
342
2632980
            green = green > 7 ? 7 : green;
343
2632980
            blue = blue > 3 ? 3 : blue;
344
345
2632980
            *put++ = (GX_UBYTE)ASSEMBLECOLOR_332(red, green, blue);
346
2632980
            *putalpha++ = (GX_UBYTE)alpha[0];
347
        }
348
    }
349
350
106
    return GX_SUCCESS;
351
}
352
/**************************************************************************/
353
/*                                                                        */
354
/*  FUNCTION                                               RELEASE        */
355
/*                                                                        */
356
/*    _gx_utility_8bpp_pixelmap_resize                    PORTABLE C      */
357
/*                                                           6.1          */
358
/*  AUTHOR                                                                */
359
/*                                                                        */
360
/*    Kenneth Maxwell, Microsoft Corporation                              */
361
/*                                                                        */
362
/*  DESCRIPTION                                                           */
363
/*                                                                        */
364
/*    This function resize an 8bpp format uncompressed pixelmap with or   */
365
/*    without transparent channel.                                        */
366
/*                                                                        */
367
/*  INPUT                                                                 */
368
/*                                                                        */
369
/*    src                                   The source pixelmap           */
370
/*    destination                           The resized pixelmap to be    */
371
/*                                            returned                    */
372
/*    width                                 New width                     */
373
/*    height                                New height                    */
374
/*                                                                        */
375
/*  OUTPUT                                                                */
376
/*                                                                        */
377
/*    status                                Completion status             */
378
/*                                                                        */
379
/*  CALLS                                                                 */
380
/*                                                                        */
381
/*     _gx_system_memory_allocator          Application defined memory    */
382
/*                                            allocation function         */
383
/*                                                                        */
384
/*  CALLED BY                                                             */
385
/*                                                                        */
386
/*    GUIX Internal Code                                                  */
387
/*                                                                        */
388
/**************************************************************************/
389
647
UINT _gx_utility_8bpp_pixelmap_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height)
390
{
391
UINT status;
392
393
647
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA)
394
    {
395
        /* alpha, no compression */
396
108
        status = _gx_utility_8bpp_pixelmap_alpha_resize(src, destination, width, height);
397
    }
398
    else
399
    {
400
        /* no compression or transparent channel */
401
539
        status = _gx_utility_8bpp_pixelmap_raw_resize(src, destination, width, height);
402
    }
403
404
647
    return status;
405
}
406
407
/**************************************************************************/
408
/*                                                                        */
409
/*  FUNCTION                                               RELEASE        */
410
/*                                                                        */
411
/*    _gx_utility_8bit_alphamap_resize                    PORTABLE C      */
412
/*                                                           6.1.7        */
413
/*  AUTHOR                                                                */
414
/*                                                                        */
415
/*    Kenneth Maxwell, Microsoft Corporation                              */
416
/*                                                                        */
417
/*  DESCRIPTION                                                           */
418
/*                                                                        */
419
/*    This function resize an 8bit uncompressed alphamap.                 */
420
/*                                                                        */
421
/*  INPUT                                                                 */
422
/*                                                                        */
423
/*    src                                   The source pixelmap           */
424
/*    destination                           The resized pixelmap to be    */
425
/*                                            returned                    */
426
/*    width                                 New width                     */
427
/*    height                                New height                    */
428
/*                                                                        */
429
/*  OUTPUT                                                                */
430
/*                                                                        */
431
/*    status                                Completion status             */
432
/*                                                                        */
433
/*  CALLS                                                                 */
434
/*                                                                        */
435
/*    _gx_system_memory_allocator           Application defined memory    */
436
/*                                            allocation function         */
437
/*                                                                        */
438
/*  CALLED BY                                                             */
439
/*                                                                        */
440
/*    GUIX Internal Code                                                  */
441
/*                                                                        */
442
/**************************************************************************/
443
3885
UINT _gx_utility_8bit_alphamap_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height)
444
{
445
/* The pixelmap resize function is implemented from bilinear interpolation
446
   image scaling algorithm.  */
447
448
GX_UBYTE *get;
449
GX_UBYTE *put;
450
INT       xdiff;
451
INT       ydiff;
452
INT       xradio;
453
INT       yradio;
454
INT       x;
455
INT       y;
456
INT       xx;
457
INT       yy;
458
3885
GX_UBYTE  neighbor_pixels[2][2] = {{0, 0}, {0, 0}};
459
INT       alpha;
460
461
    /* Calculate scale ratio and enlarge it by 256 times to keep precision.  */
462
3885
    xradio = ((src -> gx_pixelmap_width) << 8) / width;
463
3885
    yradio = ((src -> gx_pixelmap_height) << 8) / height;
464
465
    /* Fill property values into destination pixelmap structure. */
466
3885
    destination -> gx_pixelmap_flags = src -> gx_pixelmap_flags;
467
3885
    destination -> gx_pixelmap_format = src -> gx_pixelmap_format;
468
469
3885
    destination -> gx_pixelmap_height = (GX_VALUE)height;
470
3885
    destination -> gx_pixelmap_width = (GX_VALUE)width;
471
472
    /* Safe int math is not required here, calling function limits max width, height to 14 bits so
473
       overflow cannot occur. */
474
3885
    destination -> gx_pixelmap_data_size = (UINT)(height * width) * sizeof(GX_COLOR);
475
476
    /* Allocate memory to load pixelmap data. */
477
3885
    destination -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(destination -> gx_pixelmap_data_size);
478
479
3885
    if (destination -> gx_pixelmap_data == GX_NULL)
480
    {
481
2
        return GX_SYSTEM_MEMORY_ERROR;
482
    }
483
484
3883
    put = (GX_UBYTE *)destination -> gx_pixelmap_data;
485
486
    /* Loop through destination's pixel and fill each pixel with
487
       the interpolation of 4 nearest neighboring pixels.*/
488
91320
    for (y = 0; y < height; y++)
489
    {
490
4805866
        for (x = 0; x < width; x++)
491
        {
492
            /* Find the original source pixel that the destination pixel conrespond to. */
493
4718429
            xx = (xradio * x) >> 8;
494
4718429
            yy = (yradio * y) >> 8;
495
496
            /* The coordinates of the original source pixel are truncate value,
497
               calucate their distance between the mathematical coordinates. */
498
4718429
            xdiff = xradio * x - (xx << 8);
499
4718429
            ydiff = yradio * y - (yy << 8);
500
501
4718429
            get = (GX_UBYTE *)src -> gx_pixelmap_data;
502
4718429
            get += yy * src -> gx_pixelmap_width;
503
4718429
            get += xx;
504
505
            /* Calculate 4 nearest neighboring pixels around the mathematical point of original pixel. */
506
4718429
            neighbor_pixels[0][0] = *get;
507
508

4718429
            if ((xx < src -> gx_pixelmap_width - 1) && (yy < src -> gx_pixelmap_height - 1))
509
            {
510
4691188
                neighbor_pixels[0][1] = *(get + 1);
511
4691188
                neighbor_pixels[1][0] = *(get + src -> gx_pixelmap_width);
512
4691188
                neighbor_pixels[1][1] = *(get + src -> gx_pixelmap_width + 1);
513
            }
514
            else
515
            {
516
517
27241
                if ((xx == src -> gx_pixelmap_width - 1) &&
518
9197
                    (yy == src -> gx_pixelmap_height - 1))
519
                {
520
                    /* Hanle pixels in right bottom corner. */
521
36
                    neighbor_pixels[0][1] = neighbor_pixels[0][0];
522
36
                    neighbor_pixels[1][0] = neighbor_pixels[0][0];
523
36
                    neighbor_pixels[1][1] = neighbor_pixels[0][0];
524
                }
525
27205
                else if (xx == src -> gx_pixelmap_width - 1)
526
                {
527
                    /* Handle pixels in right edge. */
528
9161
                    neighbor_pixels[0][1] = neighbor_pixels[0][0];
529
9161
                    neighbor_pixels[1][0] = *(get + src -> gx_pixelmap_width);
530
9161
                    neighbor_pixels[1][1] = neighbor_pixels[1][0];
531
                }
532
                else
533
                {
534
                    /* Handle pixels in bottom edge.  */
535
18044
                    neighbor_pixels[0][1] = *(get + 1);
536
18044
                    neighbor_pixels[1][0] = neighbor_pixels[0][0];
537
18044
                    neighbor_pixels[1][1] = neighbor_pixels[0][1];
538
                }
539
            }
540
541
            /* Calulate alpha values by interpolating 4 neighboring pixels. */
542
4718429
            alpha = (INT)(((neighbor_pixels[0][0]) * (256 - (ULONG)xdiff) * (256 - (ULONG)ydiff) + \
543
4718429
                           (neighbor_pixels[0][1]) * (ULONG)xdiff * (256 - (ULONG)ydiff) +         \
544
4718429
                           (neighbor_pixels[1][0]) * (ULONG)ydiff * (256 - (ULONG)xdiff) +         \
545
4718429
                           (neighbor_pixels[1][1]) * (ULONG)xdiff * (ULONG)ydiff) >> 16);
546
547
4718429
            *put++ = (GX_UBYTE)alpha;
548
        }
549
    }
550
551
3883
    return GX_SUCCESS;
552
}
553