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_context.h" |
28 |
|
|
#include "gx_system.h" |
29 |
|
|
#include "gx_utility.h" |
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_utility_pixelmap_simple_rotation PORTABLE C */ |
36 |
|
|
/* 6.1 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This service rotate a pixelmap by 90, 180 or 270 degree. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* src The pixelmap to rotate */ |
48 |
|
|
/* angle The angle to rotate */ |
49 |
|
|
/* destination Destination buffer for */ |
50 |
|
|
/* rotated pixelmap. */ |
51 |
|
|
/* rot_cx X coordinate of rotation */ |
52 |
|
|
/* center */ |
53 |
|
|
/* rot_cy Y coordinate of rotation */ |
54 |
|
|
/* center */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* status Completion status */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* _gx_utility_32argb_pixelmap_simple_rotate */ |
63 |
|
|
/* Rotate 32bpp pixelmap with */ |
64 |
|
|
/* simple case */ |
65 |
|
|
/* _gx_utility_565rgb_pixelmap_simple_rotate */ |
66 |
|
|
/* Rotate 565rgb pixelmap with */ |
67 |
|
|
/* simple case */ |
68 |
|
|
/* _gx_utility_4444argb_pixelmap_simple_rotate */ |
69 |
|
|
/* Rotate 4444argb pixelmap with */ |
70 |
|
|
/* simple case */ |
71 |
|
|
/* _gx_utility_8bpp_pixelmap_simple_rotate */ |
72 |
|
|
/* Rotate 8bit palette pixelmap */ |
73 |
|
|
/* with simple case */ |
74 |
|
|
/* _gx_utility_332rgb_pixelmap_simple_rotate */ |
75 |
|
|
/* Rotate 332rgb pixelmap with */ |
76 |
|
|
/* simple case */ |
77 |
|
|
/* _gx_utility_4bpp_pixelmap_simple_rotate */ |
78 |
|
|
/* Rotate 4bpp pixelmap with */ |
79 |
|
|
/* simple case */ |
80 |
|
|
/* _gx_utility_1bpp_pixelmap_simple_rotate */ |
81 |
|
|
/* Rotate 1bpp pixelmap with */ |
82 |
|
|
/* simple case */ |
83 |
|
|
/* */ |
84 |
|
|
/* CALLED BY */ |
85 |
|
|
/* */ |
86 |
|
|
/* Application Code */ |
87 |
|
|
/* GUIX Internal Code */ |
88 |
|
|
/* */ |
89 |
|
|
/* RELEASE HISTORY */ |
90 |
|
|
/* */ |
91 |
|
|
/* DATE NAME DESCRIPTION */ |
92 |
|
|
/* */ |
93 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
94 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
95 |
|
|
/* added 565bgr format support,*/ |
96 |
|
|
/* resulting in version 6.1 */ |
97 |
|
|
/* */ |
98 |
|
|
/**************************************************************************/ |
99 |
|
451 |
UINT _gx_utility_pixelmap_simple_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy) |
100 |
|
|
{ |
101 |
|
451 |
angle = angle % 360; |
102 |
|
|
|
103 |
✓✓✓✓
|
451 |
if ((angle == 0) || (angle % 90)) |
104 |
|
|
{ |
105 |
|
2 |
return GX_INVALID_VALUE; |
106 |
|
|
} |
107 |
✓✓ |
449 |
else if (angle < 0) |
108 |
|
|
{ |
109 |
|
8 |
angle += 360; |
110 |
|
|
} |
111 |
|
|
|
112 |
✓✓✓✓
|
449 |
if ((_gx_system_memory_allocator == GX_NULL) || (_gx_system_memory_free == GX_NULL)) |
113 |
|
|
{ |
114 |
|
2 |
return GX_SYSTEM_MEMORY_ERROR; |
115 |
|
|
} |
116 |
|
|
|
117 |
✓✓ |
447 |
if (src -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) |
118 |
|
|
{ |
119 |
|
2 |
return GX_INVALID_FORMAT; |
120 |
|
|
} |
121 |
|
|
|
122 |
|
445 |
memset(destination, 0, sizeof(GX_PIXELMAP)); |
123 |
|
445 |
destination -> gx_pixelmap_format = src -> gx_pixelmap_format; |
124 |
|
445 |
destination -> gx_pixelmap_version_major = src -> gx_pixelmap_version_major; |
125 |
|
445 |
destination -> gx_pixelmap_version_minor = src -> gx_pixelmap_version_major; |
126 |
|
445 |
destination -> gx_pixelmap_flags = src -> gx_pixelmap_flags; |
127 |
|
|
|
128 |
✓✓✓✓ ✓✓✓✓
|
445 |
switch (src -> gx_pixelmap_format) |
129 |
|
|
{ |
130 |
|
86 |
case GX_COLOR_FORMAT_32ARGB: |
131 |
|
|
case GX_COLOR_FORMAT_24XRGB: |
132 |
|
|
/* Call 32argb pixelmap rotate. */ |
133 |
|
86 |
_gx_utility_32argb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
134 |
|
86 |
break; |
135 |
|
|
|
136 |
|
96 |
case GX_COLOR_FORMAT_565RGB: |
137 |
|
|
case GX_COLOR_FORMAT_565BGR: |
138 |
|
|
case GX_COLOR_FORMAT_1555XRGB: |
139 |
|
|
/* Call 565rgb pixelmap rotate. */ |
140 |
|
96 |
_gx_utility_565rgb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
141 |
|
96 |
break; |
142 |
|
|
|
143 |
|
30 |
case GX_COLOR_FORMAT_4444ARGB: |
144 |
|
30 |
_gx_utility_4444argb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
145 |
|
30 |
break; |
146 |
|
|
|
147 |
|
60 |
case GX_COLOR_FORMAT_8BIT_PACKED_PIXEL: |
148 |
|
|
/* Call 332rgb pixelmap rotate. */ |
149 |
|
60 |
_gx_utility_332rgb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
150 |
|
60 |
break; |
151 |
|
|
|
152 |
|
81 |
case GX_COLOR_FORMAT_8BIT_PALETTE: |
153 |
|
|
case GX_COLOR_FORMAT_8BIT_ALPHAMAP: |
154 |
|
|
/* Call 8bpp pixelmap rotate. */ |
155 |
|
81 |
_gx_utility_8bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
156 |
|
81 |
break; |
157 |
|
|
|
158 |
|
60 |
case GX_COLOR_FORMAT_4BIT_GRAY: |
159 |
|
60 |
_gx_utility_4bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
160 |
|
60 |
break; |
161 |
|
|
|
162 |
|
30 |
case GX_COLOR_FORMAT_MONOCHROME: |
163 |
|
30 |
_gx_utility_1bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy); |
164 |
|
30 |
break; |
165 |
|
|
|
166 |
|
2 |
default: |
167 |
|
2 |
return GX_INVALID_FORMAT; |
168 |
|
|
} |
169 |
✓✓ |
443 |
if (destination -> gx_pixelmap_data) |
170 |
|
|
{ |
171 |
|
317 |
return GX_SUCCESS; |
172 |
|
|
} |
173 |
|
126 |
return GX_FAILURE; |
174 |
|
|
} |
175 |
|
|
|