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

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_utility.h"
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_utility_pixelmap_resize                         PORTABLE C      */
35
/*                                                           6.1.3        */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This service resize a pixelmap and return the resized pixelmap.     */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    src                                   The source pixelmap           */
47
/*    destination                           The resized pixelmap to be    */
48
/*                                            returned                    */
49
/*    width                                 New width                     */
50
/*    height                                New height                    */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_utility_32argb_pixelmap_resize    Resize 32bpp pixelmap         */
59
/*    _gx_utility_16bpp_pixelmap_resize     Resize 565rgb pixelmap        */
60
/*    _gx_utility_1555xrgb_pixelmap_resize  Resize 1555xrgb pixelmap      */
61
/*    _gx_utility_4444argb_pixelmap_resize  Resize 4444argb pixelmap      */
62
/*    _gx_utility_8bpp_pixelmap_resize      Resize 8bpp pixelmap          */
63
/*    _gx_utility_8bit_alphamap_resize      Resize 8bit alphamap          */
64
/*    _gx_utility_4bpp_pixelmap_resize      Resize 4bpp pixelmap          */
65
/*    _gx_utility_1bpp_pixelmap_resize      Resize 1bpp pixelmap          */
66
/*                                                                        */
67
/*  CALLED BY                                                             */
68
/*                                                                        */
69
/*    Application Code                                                    */
70
/*    GUIX Internal Code                                                  */
71
/*                                                                        */
72
/**************************************************************************/
73
7409
UINT _gx_utility_pixelmap_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height)
74
{
75
7409
UINT        status = GX_SUCCESS;
76
GX_PIXELMAP rotated_src;
77
78
7409
    memset(destination, 0, sizeof(GX_PIXELMAP));
79
80
    /* Limited pixelmap width to 14 bits. */
81
7409
    if (src -> gx_pixelmap_width > GX_MAX_PIXELMAP_RESOLUTION)
82
    {
83
1
        return GX_INVALID_WIDTH;
84
    }
85
86
    /* Limited pixelmap height to 14 bits. */
87
7408
    if (src -> gx_pixelmap_height > GX_MAX_PIXELMAP_RESOLUTION)
88
    {
89
1
        return GX_INVALID_HEIGHT;
90
    }
91
92
7407
    if ((src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_90) ||
93
6487
        (src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_270))
94
    {
95
1616
        rotated_src = (*src);
96
1616
        GX_SWAP_VALS(rotated_src.gx_pixelmap_width, rotated_src.gx_pixelmap_height);
97
1616
        GX_SWAP_VALS(width, height);
98
99
1616
        src = &rotated_src;
100
    }
101
102


7407
    switch (src -> gx_pixelmap_format)
103
    {
104
697
    case GX_COLOR_FORMAT_32ARGB:
105
    case GX_COLOR_FORMAT_24XRGB:
106
107
        /* Call 32argb pixelmap resize.  */
108
697
        status = _gx_utility_32argb_pixelmap_resize(src, destination, width, height);
109
697
        break;
110
896
    case GX_COLOR_FORMAT_565RGB:
111
    case GX_COLOR_FORMAT_565BGR:
112
        /* Call 16bpp pixelmap resize.  */
113
896
        status = _gx_utility_16bpp_pixelmap_resize(src, destination, width, height);
114
896
        break;
115
116
206
    case GX_COLOR_FORMAT_1555XRGB:
117
206
        status = _gx_utility_1555xrgb_pixelmap_resize(src, destination, width, height);
118
206
        break;
119
120
204
    case GX_COLOR_FORMAT_4444ARGB:
121
204
        status = _gx_utility_4444argb_pixelmap_resize(src, destination, width, height);
122
204
        break;
123
124
647
    case GX_COLOR_FORMAT_8BIT_PACKED_PIXEL:
125
    case GX_COLOR_FORMAT_8BIT_PALETTE:
126
        /* Call 8bpp pixelmap resize.  */
127
647
        status = _gx_utility_8bpp_pixelmap_resize(src, destination, width, height);
128
647
        break;
129
130
3885
    case GX_COLOR_FORMAT_8BIT_ALPHAMAP:
131
3885
        status = _gx_utility_8bit_alphamap_resize(src, destination, width, height);
132
3885
        break;
133
134
442
    case GX_COLOR_FORMAT_4BIT_GRAY:
135
442
        status = _gx_utility_4bpp_pixelmap_resize(src, destination, width, height);
136
442
        break;
137
138
429
    case GX_COLOR_FORMAT_MONOCHROME:
139
429
        status = _gx_utility_1bpp_pixelmap_resize(src, destination, width, height);
140
429
        break;
141
142
1
    default:
143
1
        status = GX_NOT_SUPPORTED;
144
1
        break;
145
    }
146
147
7407
    if ((src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_90) ||
148
6487
        (src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_270))
149
    {
150
1616
        GX_SWAP_VALS(destination -> gx_pixelmap_width, destination -> gx_pixelmap_height);
151
    }
152
153
7407
    return status;
154
}
155