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_utility.h" |
28 |
|
|
|
29 |
|
|
/**************************************************************************/ |
30 |
|
|
/* */ |
31 |
|
|
/* FUNCTION RELEASE */ |
32 |
|
|
/* */ |
33 |
|
|
/* _gx_utility_pixelmap_resize PORTABLE C */ |
34 |
|
|
/* 6.1.3 */ |
35 |
|
|
/* AUTHOR */ |
36 |
|
|
/* */ |
37 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
38 |
|
|
/* */ |
39 |
|
|
/* DESCRIPTION */ |
40 |
|
|
/* */ |
41 |
|
|
/* This service resize a pixelmap and return the resized pixelmap. */ |
42 |
|
|
/* */ |
43 |
|
|
/* INPUT */ |
44 |
|
|
/* */ |
45 |
|
|
/* src The source pixelmap */ |
46 |
|
|
/* destination The resized pixelmap to be */ |
47 |
|
|
/* returned */ |
48 |
|
|
/* width New width */ |
49 |
|
|
/* height New height */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* status Completion status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _gx_utility_32argb_pixelmap_resize Resize 32bpp pixelmap */ |
58 |
|
|
/* _gx_utility_16bpp_pixelmap_resize Resize 565rgb pixelmap */ |
59 |
|
|
/* _gx_utility_1555xrgb_pixelmap_resize Resize 1555xrgb pixelmap */ |
60 |
|
|
/* _gx_utility_4444argb_pixelmap_resize Resize 4444argb pixelmap */ |
61 |
|
|
/* _gx_utility_8bpp_pixelmap_resize Resize 8bpp pixelmap */ |
62 |
|
|
/* _gx_utility_8bit_alphamap_resize Resize 8bit alphamap */ |
63 |
|
|
/* _gx_utility_4bpp_pixelmap_resize Resize 4bpp pixelmap */ |
64 |
|
|
/* _gx_utility_1bpp_pixelmap_resize Resize 1bpp pixelmap */ |
65 |
|
|
/* */ |
66 |
|
|
/* CALLED BY */ |
67 |
|
|
/* */ |
68 |
|
|
/* Application Code */ |
69 |
|
|
/* GUIX Internal Code */ |
70 |
|
|
/* */ |
71 |
|
|
/* RELEASE HISTORY */ |
72 |
|
|
/* */ |
73 |
|
|
/* DATE NAME DESCRIPTION */ |
74 |
|
|
/* */ |
75 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
76 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
77 |
|
|
/* added 565bgr format support,*/ |
78 |
|
|
/* resulting in version 6.1 */ |
79 |
|
|
/* 12-31-2020 Kenneth Maxwell Modified comment(s), added */ |
80 |
|
|
/* display rotation support, */ |
81 |
|
|
/* resulting in version 6.1.3 */ |
82 |
|
|
/* */ |
83 |
|
|
/**************************************************************************/ |
84 |
|
7406 |
UINT _gx_utility_pixelmap_resize(GX_PIXELMAP *src, GX_PIXELMAP *destination, INT width, INT height) |
85 |
|
|
{ |
86 |
|
7406 |
UINT status = GX_SUCCESS; |
87 |
|
|
GX_PIXELMAP rotated_src; |
88 |
|
|
|
89 |
|
7406 |
memset(destination, 0, sizeof(GX_PIXELMAP)); |
90 |
|
|
|
91 |
|
|
/* Limited pixelmap width to 14 bits. */ |
92 |
✓✓ |
7406 |
if (src -> gx_pixelmap_width > GX_MAX_PIXELMAP_RESOLUTION) |
93 |
|
|
{ |
94 |
|
1 |
return GX_INVALID_WIDTH; |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
/* Limited pixelmap height to 14 bits. */ |
98 |
✓✓ |
7405 |
if (src -> gx_pixelmap_height > GX_MAX_PIXELMAP_RESOLUTION) |
99 |
|
|
{ |
100 |
|
1 |
return GX_INVALID_HEIGHT; |
101 |
|
|
} |
102 |
|
|
|
103 |
✓✓ |
7404 |
if ((src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_90) || |
104 |
✓✓ |
6484 |
(src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_270)) |
105 |
|
|
{ |
106 |
|
1616 |
rotated_src = (*src); |
107 |
|
1616 |
GX_SWAP_VALS(rotated_src.gx_pixelmap_width, rotated_src.gx_pixelmap_height); |
108 |
|
1616 |
GX_SWAP_VALS(width, height); |
109 |
|
|
|
110 |
|
1616 |
src = &rotated_src; |
111 |
|
|
} |
112 |
|
|
|
113 |
✓✓✓✓ ✓✓✓✓ ✓ |
7404 |
switch (src -> gx_pixelmap_format) |
114 |
|
|
{ |
115 |
|
694 |
case GX_COLOR_FORMAT_32ARGB: |
116 |
|
|
case GX_COLOR_FORMAT_24XRGB: |
117 |
|
|
|
118 |
|
|
/* Call 32argb pixelmap resize. */ |
119 |
|
694 |
status = _gx_utility_32argb_pixelmap_resize(src, destination, width, height); |
120 |
|
694 |
break; |
121 |
|
896 |
case GX_COLOR_FORMAT_565RGB: |
122 |
|
|
case GX_COLOR_FORMAT_565BGR: |
123 |
|
|
/* Call 16bpp pixelmap resize. */ |
124 |
|
896 |
status = _gx_utility_16bpp_pixelmap_resize(src, destination, width, height); |
125 |
|
896 |
break; |
126 |
|
|
|
127 |
|
206 |
case GX_COLOR_FORMAT_1555XRGB: |
128 |
|
206 |
status = _gx_utility_1555xrgb_pixelmap_resize(src, destination, width, height); |
129 |
|
206 |
break; |
130 |
|
|
|
131 |
|
204 |
case GX_COLOR_FORMAT_4444ARGB: |
132 |
|
204 |
status = _gx_utility_4444argb_pixelmap_resize(src, destination, width, height); |
133 |
|
204 |
break; |
134 |
|
|
|
135 |
|
647 |
case GX_COLOR_FORMAT_8BIT_PACKED_PIXEL: |
136 |
|
|
case GX_COLOR_FORMAT_8BIT_PALETTE: |
137 |
|
|
/* Call 8bpp pixelmap resize. */ |
138 |
|
647 |
status = _gx_utility_8bpp_pixelmap_resize(src, destination, width, height); |
139 |
|
647 |
break; |
140 |
|
|
|
141 |
|
3885 |
case GX_COLOR_FORMAT_8BIT_ALPHAMAP: |
142 |
|
3885 |
status = _gx_utility_8bit_alphamap_resize(src, destination, width, height); |
143 |
|
3885 |
break; |
144 |
|
|
|
145 |
|
442 |
case GX_COLOR_FORMAT_4BIT_GRAY: |
146 |
|
442 |
status = _gx_utility_4bpp_pixelmap_resize(src, destination, width, height); |
147 |
|
442 |
break; |
148 |
|
|
|
149 |
|
429 |
case GX_COLOR_FORMAT_MONOCHROME: |
150 |
|
429 |
status = _gx_utility_1bpp_pixelmap_resize(src, destination, width, height); |
151 |
|
429 |
break; |
152 |
|
|
|
153 |
|
1 |
default: |
154 |
|
1 |
status = GX_NOT_SUPPORTED; |
155 |
|
1 |
break; |
156 |
|
|
} |
157 |
|
|
|
158 |
✓✓ |
7404 |
if ((src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_90) || |
159 |
✓✓ |
6484 |
(src -> gx_pixelmap_flags & GX_PIXELMAP_ROTATED_270)) |
160 |
|
|
{ |
161 |
|
1616 |
GX_SWAP_VALS(destination -> gx_pixelmap_width, destination -> gx_pixelmap_height); |
162 |
|
|
} |
163 |
|
|
|
164 |
|
7404 |
return status; |
165 |
|
|
} |
166 |
|
|
|