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 |
|
|
/** Image Reader Management (Image Reader) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
#include "gx_image_reader.h" |
30 |
|
|
|
31 |
|
|
#if defined(GX_SOFTWARE_DECODER_SUPPORT) |
32 |
|
|
|
33 |
|
|
extern VOID _gx_image_reader_rgb2gray(GX_PIXEL *pixel, GX_UBYTE *gray); |
34 |
|
|
/**************************************************************************/ |
35 |
|
|
/* */ |
36 |
|
|
/* FUNCTION RELEASE */ |
37 |
|
|
/* */ |
38 |
|
|
/* _gx_image_reader_8bit_alpha_write PORTABLE C */ |
39 |
|
|
/* 6.1 */ |
40 |
|
|
/* AUTHOR */ |
41 |
|
|
/* */ |
42 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
43 |
|
|
/* */ |
44 |
|
|
/* DESCRIPTION */ |
45 |
|
|
/* */ |
46 |
|
|
/* This function writes a pixel to output pixemap data structure. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* image_reader Image reader control block. */ |
51 |
|
|
/* pixel Pixel to write. */ |
52 |
|
|
/* */ |
53 |
|
|
/* OUTPUT */ |
54 |
|
|
/* */ |
55 |
|
|
/* Completion Status */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLS */ |
58 |
|
|
/* */ |
59 |
|
|
/* None */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLED BY */ |
62 |
|
|
/* */ |
63 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
64 |
|
|
/* */ |
65 |
|
|
/* RELEASE HISTORY */ |
66 |
|
|
/* */ |
67 |
|
|
/* DATE NAME DESCRIPTION */ |
68 |
|
|
/* */ |
69 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
70 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
71 |
|
|
/* resulting in version 6.1 */ |
72 |
|
|
/* */ |
73 |
|
|
/**************************************************************************/ |
74 |
|
6502078 |
static UINT _gx_image_reader_8bit_alpha_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
75 |
|
|
{ |
76 |
|
|
GX_UBYTE *palpha; |
77 |
|
|
|
78 |
✓✓ |
6502078 |
if (!image_reader -> gx_image_reader_size_testing) |
79 |
|
|
{ |
80 |
|
6423506 |
palpha = (GX_UBYTE *)image_reader -> gx_image_reader_putdata; |
81 |
|
|
|
82 |
|
6423506 |
*palpha = pixel -> gx_pixel_alpha; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
6502078 |
image_reader -> gx_image_reader_putdata += 1; |
86 |
|
|
|
87 |
|
6502078 |
return GX_SUCCESS; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
/**************************************************************************/ |
91 |
|
|
/* */ |
92 |
|
|
/* FUNCTION RELEASE */ |
93 |
|
|
/* */ |
94 |
|
|
/* _gx_image_reader_8bit_palette_write PORTABLE C */ |
95 |
|
|
/* 6.1 */ |
96 |
|
|
/* AUTHOR */ |
97 |
|
|
/* */ |
98 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
99 |
|
|
/* */ |
100 |
|
|
/* DESCRIPTION */ |
101 |
|
|
/* */ |
102 |
|
|
/* This function writes a palette index to output pixemap data */ |
103 |
|
|
/* structure. */ |
104 |
|
|
/* */ |
105 |
|
|
/* INPUT */ |
106 |
|
|
/* */ |
107 |
|
|
/* image_reader Image reader control block. */ |
108 |
|
|
/* pixel Pixel to write. */ |
109 |
|
|
/* */ |
110 |
|
|
/* OUTPUT */ |
111 |
|
|
/* */ |
112 |
|
|
/* None */ |
113 |
|
|
/* */ |
114 |
|
|
/* CALLS */ |
115 |
|
|
/* */ |
116 |
|
|
/* None */ |
117 |
|
|
/* */ |
118 |
|
|
/* CALLED BY */ |
119 |
|
|
/* */ |
120 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
121 |
|
|
/* */ |
122 |
|
|
/* RELEASE HISTORY */ |
123 |
|
|
/* */ |
124 |
|
|
/* DATE NAME DESCRIPTION */ |
125 |
|
|
/* */ |
126 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
127 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
128 |
|
|
/* resulting in version 6.1 */ |
129 |
|
|
/* */ |
130 |
|
|
/**************************************************************************/ |
131 |
|
4670178 |
static UINT _gx_image_reader_8bit_palette_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
132 |
|
|
{ |
133 |
|
|
GX_UBYTE *pLine; |
134 |
|
|
INT palindex; |
135 |
|
|
|
136 |
✓✓ |
4670178 |
if (!image_reader -> gx_image_reader_size_testing) |
137 |
|
|
{ |
138 |
|
3805479 |
pLine = (GX_UBYTE *)image_reader -> gx_image_reader_putdata; |
139 |
|
|
|
140 |
✓✓✓✓
|
3805479 |
if ((image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) && (pixel -> gx_pixel_alpha < 128)) |
141 |
|
|
{ |
142 |
|
130195 |
*pLine = GX_TRANSPARENT_COLOR; |
143 |
|
|
} |
144 |
|
|
else |
145 |
|
|
{ |
146 |
|
|
/* Find the palette color that is nearest to the wanted color. */ |
147 |
|
3675284 |
_gx_image_reader_nearest_palette_color_get(image_reader, pixel, &palindex); |
148 |
|
|
|
149 |
|
3675284 |
*pLine = (GX_UBYTE)palindex; |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
|
153 |
|
4670178 |
image_reader -> gx_image_reader_putdata += 1; |
154 |
|
|
|
155 |
|
4670178 |
return GX_SUCCESS; |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
/**************************************************************************/ |
159 |
|
|
/* */ |
160 |
|
|
/* FUNCTION RELEASE */ |
161 |
|
|
/* */ |
162 |
|
|
/* _gx_image_reader_24xrgb_pixel_write PORTABLE C */ |
163 |
|
|
/* 6.1 */ |
164 |
|
|
/* AUTHOR */ |
165 |
|
|
/* */ |
166 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
167 |
|
|
/* */ |
168 |
|
|
/* DESCRIPTION */ |
169 |
|
|
/* */ |
170 |
|
|
/* This function writes a pixel to output pixelmap data structure. */ |
171 |
|
|
/* */ |
172 |
|
|
/* INPUT */ |
173 |
|
|
/* */ |
174 |
|
|
/* image_reader Image reader control block. */ |
175 |
|
|
/* pixel Pixel to write. */ |
176 |
|
|
/* */ |
177 |
|
|
/* OUTPUT */ |
178 |
|
|
/* */ |
179 |
|
|
/* Completion Status */ |
180 |
|
|
/* */ |
181 |
|
|
/* CALLS */ |
182 |
|
|
/* */ |
183 |
|
|
/* None */ |
184 |
|
|
/* */ |
185 |
|
|
/* CALLED BY */ |
186 |
|
|
/* */ |
187 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
188 |
|
|
/* */ |
189 |
|
|
/* RELEASE HISTORY */ |
190 |
|
|
/* */ |
191 |
|
|
/* DATE NAME DESCRIPTION */ |
192 |
|
|
/* */ |
193 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
194 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
195 |
|
|
/* resulting in version 6.1 */ |
196 |
|
|
/* */ |
197 |
|
|
/**************************************************************************/ |
198 |
|
1394370 |
static UINT _gx_image_reader_24xrgb_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
199 |
|
|
{ |
200 |
|
|
GX_COLOR *pLine; |
201 |
|
|
|
202 |
✓✓ |
1394370 |
if (!image_reader -> gx_image_reader_size_testing) |
203 |
|
|
{ |
204 |
|
818726 |
pLine = (GX_COLOR *)image_reader -> gx_image_reader_putdata; |
205 |
|
|
|
206 |
|
818726 |
(*pLine) = (GX_COLOR)((pixel -> gx_pixel_red << 16)); |
207 |
|
818726 |
(*pLine) = (GX_COLOR)((*pLine) | ((ULONG)(pixel -> gx_pixel_green) << 8)); |
208 |
|
818726 |
(*pLine) = (GX_COLOR)((*pLine) | pixel -> gx_pixel_blue); |
209 |
|
818726 |
(*pLine) = (GX_COLOR)((*pLine) | 0xff000000); |
210 |
|
|
} |
211 |
|
|
|
212 |
|
1394370 |
image_reader -> gx_image_reader_putdata += 4; |
213 |
|
|
|
214 |
|
1394370 |
return GX_SUCCESS; |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
/**************************************************************************/ |
218 |
|
|
/* */ |
219 |
|
|
/* FUNCTION RELEASE */ |
220 |
|
|
/* */ |
221 |
|
|
/* _gx_image_reader_24xrgb_rotated_pixel_write PORTABLE C */ |
222 |
|
|
/* 6.1.4 */ |
223 |
|
|
/* AUTHOR */ |
224 |
|
|
/* */ |
225 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
226 |
|
|
/* */ |
227 |
|
|
/* DESCRIPTION */ |
228 |
|
|
/* */ |
229 |
|
|
/* This function writes a pixel to output rotated pixelmap data */ |
230 |
|
|
/* structure. */ |
231 |
|
|
/* */ |
232 |
|
|
/* INPUT */ |
233 |
|
|
/* */ |
234 |
|
|
/* image_reader Image reader control block. */ |
235 |
|
|
/* pixel Pixel to write. */ |
236 |
|
|
/* */ |
237 |
|
|
/* OUTPUT */ |
238 |
|
|
/* */ |
239 |
|
|
/* Completion Status */ |
240 |
|
|
/* */ |
241 |
|
|
/* CALLS */ |
242 |
|
|
/* */ |
243 |
|
|
/* None */ |
244 |
|
|
/* */ |
245 |
|
|
/* CALLED BY */ |
246 |
|
|
/* */ |
247 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
248 |
|
|
/* */ |
249 |
|
|
/* RELEASE HISTORY */ |
250 |
|
|
/* */ |
251 |
|
|
/* DATE NAME DESCRIPTION */ |
252 |
|
|
/* */ |
253 |
|
|
/* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */ |
254 |
|
|
/* */ |
255 |
|
|
/**************************************************************************/ |
256 |
|
2970461 |
static UINT _gx_image_reader_24xrgb_rotated_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
257 |
|
|
{ |
258 |
|
|
GX_COLOR *pLine; |
259 |
|
|
|
260 |
✓✓ |
2970461 |
if (!image_reader -> gx_image_reader_size_testing) |
261 |
|
|
{ |
262 |
|
2933460 |
pLine = (GX_COLOR *)image_reader -> gx_image_reader_putdata; |
263 |
|
|
|
264 |
|
2933460 |
(*pLine) = (GX_COLOR)((pixel -> gx_pixel_red << 16)); |
265 |
|
2933460 |
(*pLine) = (GX_COLOR)((*pLine) | ((ULONG)(pixel -> gx_pixel_green) << 8)); |
266 |
|
2933460 |
(*pLine) = (GX_COLOR)((*pLine) | pixel -> gx_pixel_blue); |
267 |
|
2933460 |
(*pLine) = (GX_COLOR)((*pLine) | ((ULONG)(pixel -> gx_pixel_alpha) << 24)); |
268 |
|
|
} |
269 |
|
|
|
270 |
✓✓ |
2970461 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ROTATE_CW) |
271 |
|
|
{ |
272 |
|
2968841 |
image_reader -> gx_image_reader_putdata -= (image_reader -> gx_image_reader_image_height << 2); |
273 |
|
|
} |
274 |
|
|
else |
275 |
|
|
{ |
276 |
|
1620 |
image_reader -> gx_image_reader_putdata += (image_reader -> gx_image_reader_image_height << 2); |
277 |
|
|
} |
278 |
|
|
|
279 |
|
2970461 |
return GX_SUCCESS; |
280 |
|
|
} |
281 |
|
|
|
282 |
|
|
/**************************************************************************/ |
283 |
|
|
/* */ |
284 |
|
|
/* FUNCTION RELEASE */ |
285 |
|
|
/* */ |
286 |
|
|
/* _gx_image_reader_32argb_pixel_write PORTABLE C */ |
287 |
|
|
/* 6.1 */ |
288 |
|
|
/* AUTHOR */ |
289 |
|
|
/* */ |
290 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
291 |
|
|
/* */ |
292 |
|
|
/* DESCRIPTION */ |
293 |
|
|
/* */ |
294 |
|
|
/* This function writes a pixel to output pixelmap data structure. */ |
295 |
|
|
/* */ |
296 |
|
|
/* INPUT */ |
297 |
|
|
/* */ |
298 |
|
|
/* image_reader Image reader control block. */ |
299 |
|
|
/* pixel Pixel to write. */ |
300 |
|
|
/* */ |
301 |
|
|
/* OUTPUT */ |
302 |
|
|
/* */ |
303 |
|
|
/* Completion Status */ |
304 |
|
|
/* */ |
305 |
|
|
/* CALLS */ |
306 |
|
|
/* */ |
307 |
|
|
/* None */ |
308 |
|
|
/* */ |
309 |
|
|
/* CALLED BY */ |
310 |
|
|
/* */ |
311 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
312 |
|
|
/* */ |
313 |
|
|
/* RELEASE HISTORY */ |
314 |
|
|
/* */ |
315 |
|
|
/* DATE NAME DESCRIPTION */ |
316 |
|
|
/* */ |
317 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
318 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
319 |
|
|
/* resulting in version 6.1 */ |
320 |
|
|
/* */ |
321 |
|
|
/**************************************************************************/ |
322 |
|
928600 |
static UINT _gx_image_reader_32argb_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
323 |
|
|
{ |
324 |
|
|
GX_COLOR *pLine; |
325 |
|
|
|
326 |
✓✓ |
928600 |
if (!image_reader -> gx_image_reader_size_testing) |
327 |
|
|
{ |
328 |
|
745750 |
pLine = (GX_COLOR *)image_reader -> gx_image_reader_putdata; |
329 |
|
|
|
330 |
|
745750 |
(*pLine) = (GX_COLOR)(pixel -> gx_pixel_alpha << 24); |
331 |
|
745750 |
(*pLine) = (GX_COLOR)((*pLine) | ((ULONG)(pixel -> gx_pixel_red) << 16)); |
332 |
|
745750 |
(*pLine) = (GX_COLOR)((*pLine) | ((ULONG)(pixel -> gx_pixel_green) << 8)); |
333 |
|
745750 |
(*pLine) = (GX_COLOR)((*pLine) | pixel -> gx_pixel_blue); |
334 |
|
|
} |
335 |
|
|
|
336 |
|
928600 |
image_reader -> gx_image_reader_putdata += 4; |
337 |
|
|
|
338 |
|
928600 |
return GX_SUCCESS; |
339 |
|
|
} |
340 |
|
|
|
341 |
|
|
/**************************************************************************/ |
342 |
|
|
/* */ |
343 |
|
|
/* FUNCTION RELEASE */ |
344 |
|
|
/* */ |
345 |
|
|
/* _gx_image_reader_565rgb_rle_pixel_write PORTABLE C */ |
346 |
|
|
/* 6.1 */ |
347 |
|
|
/* AUTHOR */ |
348 |
|
|
/* */ |
349 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
350 |
|
|
/* */ |
351 |
|
|
/* DESCRIPTION */ |
352 |
|
|
/* */ |
353 |
|
|
/* This function writes a pixel to output pixemap data structure. */ |
354 |
|
|
/* */ |
355 |
|
|
/* INPUT */ |
356 |
|
|
/* */ |
357 |
|
|
/* image_reader Image reader control block. */ |
358 |
|
|
/* pixel Pixel to write. */ |
359 |
|
|
/* */ |
360 |
|
|
/* OUTPUT */ |
361 |
|
|
/* */ |
362 |
|
|
/* Completion Status */ |
363 |
|
|
/* */ |
364 |
|
|
/* CALLS */ |
365 |
|
|
/* */ |
366 |
|
|
/* None */ |
367 |
|
|
/* */ |
368 |
|
|
/* CALLED BY */ |
369 |
|
|
/* */ |
370 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
371 |
|
|
/* */ |
372 |
|
|
/* RELEASE HISTORY */ |
373 |
|
|
/* */ |
374 |
|
|
/* DATE NAME DESCRIPTION */ |
375 |
|
|
/* */ |
376 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
377 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
378 |
|
|
/* resulting in version 6.1 */ |
379 |
|
|
/* */ |
380 |
|
|
/**************************************************************************/ |
381 |
|
2592746 |
static UINT _gx_image_reader_565rgb_rle_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
382 |
|
|
{ |
383 |
|
|
USHORT *pLine; |
384 |
|
|
GX_UBYTE *pAlpha; |
385 |
|
|
|
386 |
✓✓ |
2592746 |
if (!image_reader -> gx_image_reader_size_testing) |
387 |
|
|
{ |
388 |
|
1280647 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
389 |
|
|
|
390 |
✓✓ |
1280647 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
391 |
|
|
{ |
392 |
|
173235 |
pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_putdata; |
393 |
|
|
|
394 |
|
|
/* Skip count. */ |
395 |
|
173235 |
pAlpha++; |
396 |
|
173235 |
pLine++; |
397 |
|
|
|
398 |
|
173235 |
(*pAlpha) = pixel -> gx_pixel_alpha; |
399 |
|
|
} |
400 |
|
|
|
401 |
|
1280647 |
pixel -> gx_pixel_red &= 0xf8; |
402 |
|
1280647 |
pixel -> gx_pixel_green &= 0xfc; |
403 |
|
1280647 |
pixel -> gx_pixel_blue &= 0xf8; |
404 |
|
|
|
405 |
|
1280647 |
(*pLine) = (USHORT)(pixel -> gx_pixel_red << 8); |
406 |
|
1280647 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 3)); |
407 |
|
1280647 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_blue >> 3)); |
408 |
|
|
} |
409 |
|
|
|
410 |
✓✓ |
2592746 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
411 |
|
|
{ |
412 |
|
377922 |
image_reader -> gx_image_reader_putdata += 4; |
413 |
|
|
} |
414 |
|
|
else |
415 |
|
|
{ |
416 |
|
2214824 |
image_reader -> gx_image_reader_putdata += 2; |
417 |
|
|
} |
418 |
|
|
|
419 |
|
2592746 |
return GX_SUCCESS; |
420 |
|
|
} |
421 |
|
|
|
422 |
|
|
/**************************************************************************/ |
423 |
|
|
/* */ |
424 |
|
|
/* FUNCTION RELEASE */ |
425 |
|
|
/* */ |
426 |
|
|
/* _gx_image_reader_565rgb_pixel_write PORTABLE C */ |
427 |
|
|
/* 6.1 */ |
428 |
|
|
/* AUTHOR */ |
429 |
|
|
/* */ |
430 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
431 |
|
|
/* */ |
432 |
|
|
/* DESCRIPTION */ |
433 |
|
|
/* */ |
434 |
|
|
/* This function writes a pixel to output pixemap data structure. */ |
435 |
|
|
/* */ |
436 |
|
|
/* INPUT */ |
437 |
|
|
/* */ |
438 |
|
|
/* image_reader Image reader control block. */ |
439 |
|
|
/* pixel Pixel to write. */ |
440 |
|
|
/* */ |
441 |
|
|
/* OUTPUT */ |
442 |
|
|
/* */ |
443 |
|
|
/* Completion Status */ |
444 |
|
|
/* */ |
445 |
|
|
/* CALLS */ |
446 |
|
|
/* */ |
447 |
|
|
/* None */ |
448 |
|
|
/* */ |
449 |
|
|
/* CALLED BY */ |
450 |
|
|
/* */ |
451 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
452 |
|
|
/* */ |
453 |
|
|
/* RELEASE HISTORY */ |
454 |
|
|
/* */ |
455 |
|
|
/* DATE NAME DESCRIPTION */ |
456 |
|
|
/* */ |
457 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
458 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
459 |
|
|
/* resulting in version 6.1 */ |
460 |
|
|
/* */ |
461 |
|
|
/**************************************************************************/ |
462 |
|
3015025 |
static UINT _gx_image_reader_565rgb_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
463 |
|
|
{ |
464 |
|
|
USHORT *pLine; |
465 |
|
|
GX_UBYTE *pAlpha; |
466 |
|
|
|
467 |
|
3015025 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
468 |
|
|
|
469 |
|
3015025 |
pixel -> gx_pixel_red &= 0xf8; |
470 |
|
3015025 |
pixel -> gx_pixel_green &= 0xfc; |
471 |
|
3015025 |
pixel -> gx_pixel_blue &= 0xf8; |
472 |
|
|
|
473 |
|
3015025 |
(*pLine) = (USHORT)(pixel -> gx_pixel_red << 8); |
474 |
|
3015025 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 3)); |
475 |
|
3015025 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_blue >> 3)); |
476 |
|
|
|
477 |
✓✓ |
3015025 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
478 |
|
|
{ |
479 |
|
1126053 |
pAlpha = image_reader -> gx_image_reader_putauxdata; |
480 |
|
|
|
481 |
|
1126053 |
(*pAlpha) = pixel -> gx_pixel_alpha; |
482 |
|
|
} |
483 |
|
|
|
484 |
|
3015025 |
image_reader -> gx_image_reader_putauxdata += 1; |
485 |
|
3015025 |
image_reader -> gx_image_reader_putdata += 2; |
486 |
|
|
|
487 |
|
3015025 |
return GX_SUCCESS; |
488 |
|
|
} |
489 |
|
|
|
490 |
|
|
/**************************************************************************/ |
491 |
|
|
/* */ |
492 |
|
|
/* FUNCTION RELEASE */ |
493 |
|
|
/* */ |
494 |
|
|
/* _gx_image_reader_565rgb_rotated_pixel_write PORTABLE C */ |
495 |
|
|
/* 6.1.5 */ |
496 |
|
|
/* AUTHOR */ |
497 |
|
|
/* */ |
498 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
499 |
|
|
/* */ |
500 |
|
|
/* DESCRIPTION */ |
501 |
|
|
/* */ |
502 |
|
|
/* This function rotates a pixel to output pixemap data structure. */ |
503 |
|
|
/* */ |
504 |
|
|
/* INPUT */ |
505 |
|
|
/* */ |
506 |
|
|
/* image_reader Image reader control block. */ |
507 |
|
|
/* pixel Pixel to write. */ |
508 |
|
|
/* */ |
509 |
|
|
/* OUTPUT */ |
510 |
|
|
/* */ |
511 |
|
|
/* Completion Status */ |
512 |
|
|
/* */ |
513 |
|
|
/* CALLS */ |
514 |
|
|
/* */ |
515 |
|
|
/* None */ |
516 |
|
|
/* */ |
517 |
|
|
/* CALLED BY */ |
518 |
|
|
/* */ |
519 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
520 |
|
|
/* */ |
521 |
|
|
/* RELEASE HISTORY */ |
522 |
|
|
/* */ |
523 |
|
|
/* DATE NAME DESCRIPTION */ |
524 |
|
|
/* */ |
525 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
526 |
|
|
/* 03-02-2021 Ting Zhu Modified comment(s), */ |
527 |
|
|
/* improved logic, */ |
528 |
|
|
/* resulting in version 6.1.5 */ |
529 |
|
|
/* */ |
530 |
|
|
/**************************************************************************/ |
531 |
|
2482571 |
static UINT _gx_image_reader_565rgb_rotated_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
532 |
|
|
{ |
533 |
|
|
USHORT *pLine; |
534 |
|
|
GX_UBYTE *pAlpha; |
535 |
|
|
|
536 |
✓✓ |
2482571 |
if(!image_reader -> gx_image_reader_size_testing) |
537 |
|
|
{ |
538 |
|
2453211 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
539 |
|
|
|
540 |
|
2453211 |
pixel -> gx_pixel_red &= 0xf8; |
541 |
|
2453211 |
pixel -> gx_pixel_green &= 0xfc; |
542 |
|
2453211 |
pixel -> gx_pixel_blue &= 0xf8; |
543 |
|
|
|
544 |
|
2453211 |
(*pLine) = (USHORT)(pixel -> gx_pixel_red << 8); |
545 |
|
2453211 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 3)); |
546 |
|
2453211 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_blue >> 3)); |
547 |
|
|
|
548 |
✓✓ |
2453211 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
549 |
|
|
{ |
550 |
|
2447055 |
pAlpha = image_reader -> gx_image_reader_putauxdata; |
551 |
|
|
|
552 |
|
2447055 |
(*pAlpha) = pixel -> gx_pixel_alpha; |
553 |
|
|
} |
554 |
|
|
} |
555 |
|
|
|
556 |
✓✓ |
2482571 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ROTATE_CW) |
557 |
|
|
{ |
558 |
|
1699976 |
image_reader -> gx_image_reader_putauxdata -= image_reader -> gx_image_reader_image_height; |
559 |
|
1699976 |
image_reader -> gx_image_reader_putdata -= (image_reader -> gx_image_reader_image_height << 1); |
560 |
|
|
} |
561 |
|
|
else |
562 |
|
|
{ |
563 |
|
782595 |
image_reader -> gx_image_reader_putauxdata += image_reader -> gx_image_reader_image_height; |
564 |
|
782595 |
image_reader -> gx_image_reader_putdata += (image_reader -> gx_image_reader_image_height << 1); |
565 |
|
|
} |
566 |
|
|
|
567 |
|
2482571 |
return GX_SUCCESS; |
568 |
|
|
} |
569 |
|
|
|
570 |
|
|
/**************************************************************************/ |
571 |
|
|
/* */ |
572 |
|
|
/* FUNCTION RELEASE */ |
573 |
|
|
/* */ |
574 |
|
|
/* _gx_image_reader_1555xrgb_rle_pixel_write PORTABLE C */ |
575 |
|
|
/* 6.1 */ |
576 |
|
|
/* AUTHOR */ |
577 |
|
|
/* */ |
578 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
579 |
|
|
/* */ |
580 |
|
|
/* DESCRIPTION */ |
581 |
|
|
/* */ |
582 |
|
|
/* This function writes an 1555xrgb format pixel to output pixemap */ |
583 |
|
|
/* data structure. */ |
584 |
|
|
/* */ |
585 |
|
|
/* INPUT */ |
586 |
|
|
/* */ |
587 |
|
|
/* image_reader Image reader control block. */ |
588 |
|
|
/* pixel Pixel to write. */ |
589 |
|
|
/* */ |
590 |
|
|
/* OUTPUT */ |
591 |
|
|
/* */ |
592 |
|
|
/* Completion Status */ |
593 |
|
|
/* */ |
594 |
|
|
/* CALLS */ |
595 |
|
|
/* */ |
596 |
|
|
/* None */ |
597 |
|
|
/* */ |
598 |
|
|
/* CALLED BY */ |
599 |
|
|
/* */ |
600 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
601 |
|
|
/* */ |
602 |
|
|
/* RELEASE HISTORY */ |
603 |
|
|
/* */ |
604 |
|
|
/* DATE NAME DESCRIPTION */ |
605 |
|
|
/* */ |
606 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
607 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
608 |
|
|
/* resulting in version 6.1 */ |
609 |
|
|
/* */ |
610 |
|
|
/**************************************************************************/ |
611 |
|
676444 |
static UINT _gx_image_reader_1555xrgb_rle_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
612 |
|
|
{ |
613 |
|
|
USHORT *pLine; |
614 |
|
|
GX_UBYTE *pAlpha; |
615 |
|
|
|
616 |
✓✓ |
676444 |
if (!image_reader -> gx_image_reader_size_testing) |
617 |
|
|
{ |
618 |
|
338222 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
619 |
|
|
|
620 |
✓✓ |
338222 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
621 |
|
|
{ |
622 |
|
196870 |
pAlpha = (GX_UBYTE *)image_reader -> gx_image_reader_putdata; |
623 |
|
|
|
624 |
|
|
/* Skip count. */ |
625 |
|
196870 |
pAlpha++; |
626 |
|
196870 |
pLine++; |
627 |
|
|
|
628 |
|
196870 |
(*pAlpha) = pixel -> gx_pixel_alpha; |
629 |
|
|
} |
630 |
|
|
|
631 |
|
338222 |
pixel -> gx_pixel_red &= 0xf8; |
632 |
|
338222 |
pixel -> gx_pixel_green &= 0xf8; |
633 |
|
338222 |
pixel -> gx_pixel_blue &= 0xf8; |
634 |
|
|
|
635 |
|
338222 |
(*pLine) = (USHORT)(pixel -> gx_pixel_red << 7); |
636 |
|
338222 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 2)); |
637 |
|
338222 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_blue >> 3)); |
638 |
|
|
} |
639 |
|
|
|
640 |
✓✓ |
676444 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
641 |
|
|
{ |
642 |
|
393740 |
image_reader -> gx_image_reader_putdata += 4; |
643 |
|
|
} |
644 |
|
|
else |
645 |
|
|
{ |
646 |
|
282704 |
image_reader -> gx_image_reader_putdata += 2; |
647 |
|
|
} |
648 |
|
|
|
649 |
|
676444 |
return GX_SUCCESS; |
650 |
|
|
} |
651 |
|
|
|
652 |
|
|
/**************************************************************************/ |
653 |
|
|
/* */ |
654 |
|
|
/* FUNCTION RELEASE */ |
655 |
|
|
/* */ |
656 |
|
|
/* _gx_image_reader_1555xrgb_pixel_write PORTABLE C */ |
657 |
|
|
/* 6.1 */ |
658 |
|
|
/* AUTHOR */ |
659 |
|
|
/* */ |
660 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
661 |
|
|
/* */ |
662 |
|
|
/* DESCRIPTION */ |
663 |
|
|
/* */ |
664 |
|
|
/* This function writes an 1555xrgb format pixel to output pixemap */ |
665 |
|
|
/* data structure. */ |
666 |
|
|
/* */ |
667 |
|
|
/* INPUT */ |
668 |
|
|
/* */ |
669 |
|
|
/* image_reader Image reader control block. */ |
670 |
|
|
/* pixel Pixel to write. */ |
671 |
|
|
/* */ |
672 |
|
|
/* OUTPUT */ |
673 |
|
|
/* */ |
674 |
|
|
/* Completion Status */ |
675 |
|
|
/* */ |
676 |
|
|
/* CALLS */ |
677 |
|
|
/* */ |
678 |
|
|
/* None */ |
679 |
|
|
/* */ |
680 |
|
|
/* CALLED BY */ |
681 |
|
|
/* */ |
682 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
683 |
|
|
/* */ |
684 |
|
|
/* RELEASE HISTORY */ |
685 |
|
|
/* */ |
686 |
|
|
/* DATE NAME DESCRIPTION */ |
687 |
|
|
/* */ |
688 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
689 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
690 |
|
|
/* resulting in version 6.1 */ |
691 |
|
|
/* */ |
692 |
|
|
/**************************************************************************/ |
693 |
|
921645 |
static UINT _gx_image_reader_1555xrgb_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
694 |
|
|
{ |
695 |
|
|
USHORT *pLine; |
696 |
|
|
GX_UBYTE *pAlpha; |
697 |
|
|
|
698 |
|
921645 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
699 |
|
|
|
700 |
|
921645 |
pixel -> gx_pixel_red &= 0xf8; |
701 |
|
921645 |
pixel -> gx_pixel_green &= 0xf8; |
702 |
|
921645 |
pixel -> gx_pixel_blue &= 0xf8; |
703 |
|
|
|
704 |
|
921645 |
(*pLine) = (USHORT)(pixel -> gx_pixel_red << 7); |
705 |
|
921645 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 2)); |
706 |
|
921645 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_blue >> 3)); |
707 |
|
|
|
708 |
✓✓ |
921645 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ALPHA) |
709 |
|
|
{ |
710 |
|
468585 |
pAlpha = image_reader -> gx_image_reader_putauxdata; |
711 |
|
|
|
712 |
|
468585 |
(*pAlpha) = pixel -> gx_pixel_alpha; |
713 |
|
|
} |
714 |
|
|
|
715 |
|
921645 |
image_reader -> gx_image_reader_putauxdata += 1; |
716 |
|
921645 |
image_reader -> gx_image_reader_putdata += 2; |
717 |
|
|
|
718 |
|
921645 |
return GX_SUCCESS; |
719 |
|
|
} |
720 |
|
|
|
721 |
|
|
/**************************************************************************/ |
722 |
|
|
/* */ |
723 |
|
|
/* FUNCTION RELEASE */ |
724 |
|
|
/* */ |
725 |
|
|
/* _gx_image_reader_4444argb_pixel_write PORTABLE C */ |
726 |
|
|
/* 6.1 */ |
727 |
|
|
/* AUTHOR */ |
728 |
|
|
/* */ |
729 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
730 |
|
|
/* */ |
731 |
|
|
/* DESCRIPTION */ |
732 |
|
|
/* */ |
733 |
|
|
/* This function writes an 4444argb format pixel (no transparency) to */ |
734 |
|
|
/* output pixemap data structure. */ |
735 |
|
|
/* */ |
736 |
|
|
/* INPUT */ |
737 |
|
|
/* */ |
738 |
|
|
/* image_reader Image reader control block. */ |
739 |
|
|
/* pixel Pixel to write. */ |
740 |
|
|
/* */ |
741 |
|
|
/* OUTPUT */ |
742 |
|
|
/* */ |
743 |
|
|
/* Completion Status */ |
744 |
|
|
/* */ |
745 |
|
|
/* CALLS */ |
746 |
|
|
/* */ |
747 |
|
|
/* None */ |
748 |
|
|
/* */ |
749 |
|
|
/* CALLED BY */ |
750 |
|
|
/* */ |
751 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
752 |
|
|
/* */ |
753 |
|
|
/* RELEASE HISTORY */ |
754 |
|
|
/* */ |
755 |
|
|
/* DATE NAME DESCRIPTION */ |
756 |
|
|
/* */ |
757 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
758 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
759 |
|
|
/* resulting in version 6.1 */ |
760 |
|
|
/* */ |
761 |
|
|
/**************************************************************************/ |
762 |
|
629890 |
static UINT _gx_image_reader_4444argb_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
763 |
|
|
{ |
764 |
|
|
USHORT *pLine; |
765 |
|
|
|
766 |
✓✓ |
629890 |
if (!image_reader -> gx_image_reader_size_testing) |
767 |
|
|
{ |
768 |
|
539765 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
769 |
|
|
|
770 |
|
539765 |
pixel -> gx_pixel_alpha &= 0xf0; |
771 |
|
539765 |
pixel -> gx_pixel_red &= 0xf0; |
772 |
|
539765 |
pixel -> gx_pixel_green &= 0xf0; |
773 |
|
539765 |
pixel -> gx_pixel_blue &= 0xf0; |
774 |
|
|
|
775 |
|
539765 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_red << 4)); |
776 |
|
539765 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 0)); |
777 |
|
539765 |
(*pLine) = (USHORT)((*pLine) | pixel -> gx_pixel_blue >> 4); |
778 |
|
539765 |
(*pLine) = (USHORT)((*pLine) | 0xf000); |
779 |
|
|
} |
780 |
|
|
|
781 |
|
629890 |
image_reader -> gx_image_reader_putdata += 2; |
782 |
|
|
|
783 |
|
629890 |
return GX_SUCCESS; |
784 |
|
|
} |
785 |
|
|
|
786 |
|
|
/**************************************************************************/ |
787 |
|
|
/* */ |
788 |
|
|
/* FUNCTION RELEASE */ |
789 |
|
|
/* */ |
790 |
|
|
/* _gx_image_reader_4444argb_transparent_write PORTABLE C */ |
791 |
|
|
/* 6.1 */ |
792 |
|
|
/* AUTHOR */ |
793 |
|
|
/* */ |
794 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
795 |
|
|
/* */ |
796 |
|
|
/* DESCRIPTION */ |
797 |
|
|
/* */ |
798 |
|
|
/* This function writes an 4444argb format pixel (with transparency) */ |
799 |
|
|
/* to output pixemap data structure. */ |
800 |
|
|
/* */ |
801 |
|
|
/* INPUT */ |
802 |
|
|
/* */ |
803 |
|
|
/* image_reader Image reader control block. */ |
804 |
|
|
/* pixel Pixel to write. */ |
805 |
|
|
/* */ |
806 |
|
|
/* OUTPUT */ |
807 |
|
|
/* */ |
808 |
|
|
/* Completion Status */ |
809 |
|
|
/* */ |
810 |
|
|
/* CALLS */ |
811 |
|
|
/* */ |
812 |
|
|
/* None */ |
813 |
|
|
/* */ |
814 |
|
|
/* CALLED BY */ |
815 |
|
|
/* */ |
816 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
817 |
|
|
/* */ |
818 |
|
|
/* RELEASE HISTORY */ |
819 |
|
|
/* */ |
820 |
|
|
/* DATE NAME DESCRIPTION */ |
821 |
|
|
/* */ |
822 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
823 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
824 |
|
|
/* resulting in version 6.1 */ |
825 |
|
|
/* */ |
826 |
|
|
/**************************************************************************/ |
827 |
|
420729 |
static UINT _gx_image_reader_4444argb_transparent_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
828 |
|
|
{ |
829 |
|
|
USHORT *pLine; |
830 |
|
|
|
831 |
✓✓ |
420729 |
if (!image_reader -> gx_image_reader_size_testing) |
832 |
|
|
{ |
833 |
|
340527 |
pLine = (USHORT *)image_reader -> gx_image_reader_putdata; |
834 |
|
|
|
835 |
|
340527 |
pixel -> gx_pixel_alpha &= 0xf0; |
836 |
|
340527 |
pixel -> gx_pixel_red &= 0xf0; |
837 |
|
340527 |
pixel -> gx_pixel_green &= 0xf0; |
838 |
|
340527 |
pixel -> gx_pixel_blue &= 0xf0; |
839 |
|
|
|
840 |
|
340527 |
(*pLine) = (USHORT)(pixel -> gx_pixel_alpha << 8); |
841 |
|
340527 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_red << 4)); |
842 |
|
340527 |
(*pLine) = (USHORT)((*pLine) | (pixel -> gx_pixel_green << 0)); |
843 |
|
340527 |
(*pLine) = (USHORT)((*pLine) | pixel -> gx_pixel_blue >> 4); |
844 |
|
|
} |
845 |
|
|
|
846 |
|
420729 |
image_reader -> gx_image_reader_putdata += 2; |
847 |
|
|
|
848 |
|
420729 |
return GX_SUCCESS; |
849 |
|
|
} |
850 |
|
|
|
851 |
|
|
/**************************************************************************/ |
852 |
|
|
/* */ |
853 |
|
|
/* FUNCTION RELEASE */ |
854 |
|
|
/* */ |
855 |
|
|
/* _gx_image_reader_4bit_grayscale_pixel_write PORTABLE C */ |
856 |
|
|
/* 6.1 */ |
857 |
|
|
/* AUTHOR */ |
858 |
|
|
/* */ |
859 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
860 |
|
|
/* */ |
861 |
|
|
/* DESCRIPTION */ |
862 |
|
|
/* */ |
863 |
|
|
/* This function writes an 4bit grayscale format pixel */ |
864 |
|
|
/* (no transparency)to output pixelmap data structure. */ |
865 |
|
|
/* */ |
866 |
|
|
/* INPUT */ |
867 |
|
|
/* */ |
868 |
|
|
/* image_reader Image reader control block. */ |
869 |
|
|
/* pixel Pixel to write. */ |
870 |
|
|
/* */ |
871 |
|
|
/* OUTPUT */ |
872 |
|
|
/* */ |
873 |
|
|
/* Completion Status */ |
874 |
|
|
/* */ |
875 |
|
|
/* CALLS */ |
876 |
|
|
/* */ |
877 |
|
|
/* _gx_image_reader_rgb2gray Convert RGB value to grayscale*/ |
878 |
|
|
/* */ |
879 |
|
|
/* CALLED BY */ |
880 |
|
|
/* */ |
881 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
882 |
|
|
/* */ |
883 |
|
|
/* RELEASE HISTORY */ |
884 |
|
|
/* */ |
885 |
|
|
/* DATE NAME DESCRIPTION */ |
886 |
|
|
/* */ |
887 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
888 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
889 |
|
|
/* resulting in version 6.1 */ |
890 |
|
|
/* */ |
891 |
|
|
/**************************************************************************/ |
892 |
|
618030 |
static UINT _gx_image_reader_4bit_grayscale_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
893 |
|
|
{ |
894 |
|
|
GX_UBYTE *pLine; |
895 |
|
|
GX_UBYTE gray; |
896 |
|
|
GX_UBYTE color; |
897 |
|
|
|
898 |
✓✓ |
618030 |
if (!image_reader -> gx_image_reader_size_testing) |
899 |
|
|
{ |
900 |
|
547245 |
_gx_image_reader_rgb2gray(pixel, &gray); |
901 |
|
547245 |
gray >>= 4; |
902 |
|
|
|
903 |
|
547245 |
color = (GX_UBYTE)(gray | (gray << 4)); |
904 |
|
547245 |
pixel -> gx_pixel_red = color; |
905 |
|
547245 |
pixel -> gx_pixel_green = color; |
906 |
|
547245 |
pixel -> gx_pixel_blue = color; |
907 |
|
|
|
908 |
|
547245 |
pLine = image_reader -> gx_image_reader_putdata; |
909 |
|
|
|
910 |
✓✓ |
547245 |
if (image_reader -> gx_image_reader_putdata_mask & 0xf0) |
911 |
|
|
{ |
912 |
|
274159 |
(*pLine) = (GX_UBYTE)(gray << 4); |
913 |
|
|
} |
914 |
|
|
else |
915 |
|
|
{ |
916 |
|
273086 |
(*pLine) |= gray; |
917 |
|
|
} |
918 |
|
|
} |
919 |
|
|
|
920 |
|
618030 |
image_reader -> gx_image_reader_putdata_mask >>= 4; |
921 |
|
|
|
922 |
✓✓ |
618030 |
if (!image_reader -> gx_image_reader_putdata_mask) |
923 |
|
|
{ |
924 |
|
308476 |
image_reader -> gx_image_reader_putdata++; |
925 |
|
308476 |
image_reader -> gx_image_reader_putdata_mask = 0xf0; |
926 |
|
|
} |
927 |
|
|
|
928 |
|
618030 |
return GX_SUCCESS; |
929 |
|
|
} |
930 |
|
|
|
931 |
|
|
/**************************************************************************/ |
932 |
|
|
/* */ |
933 |
|
|
/* FUNCTION RELEASE */ |
934 |
|
|
/* */ |
935 |
|
|
/* _gx_image_reader_4bit_grayscale_transparent_write PORTABLE C */ |
936 |
|
|
/* 6.1 */ |
937 |
|
|
/* AUTHOR */ |
938 |
|
|
/* */ |
939 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
940 |
|
|
/* */ |
941 |
|
|
/* DESCRIPTION */ |
942 |
|
|
/* */ |
943 |
|
|
/* This function writes an 4bit grayscale format pixel */ |
944 |
|
|
/* (with transparency)to output pixelmap data structure. */ |
945 |
|
|
/* */ |
946 |
|
|
/* INPUT */ |
947 |
|
|
/* */ |
948 |
|
|
/* image_reader Image reader control block. */ |
949 |
|
|
/* pixel Pixel to write. */ |
950 |
|
|
/* */ |
951 |
|
|
/* OUTPUT */ |
952 |
|
|
/* */ |
953 |
|
|
/* Completion Status */ |
954 |
|
|
/* */ |
955 |
|
|
/* CALLS */ |
956 |
|
|
/* */ |
957 |
|
|
/* _gx_image_reader_rgb2gray Convert RGB value to grayscale*/ |
958 |
|
|
/* */ |
959 |
|
|
/* CALLED BY */ |
960 |
|
|
/* */ |
961 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
962 |
|
|
/* */ |
963 |
|
|
/* RELEASE HISTORY */ |
964 |
|
|
/* */ |
965 |
|
|
/* DATE NAME DESCRIPTION */ |
966 |
|
|
/* */ |
967 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
968 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
969 |
|
|
/* resulting in version 6.1 */ |
970 |
|
|
/* */ |
971 |
|
|
/**************************************************************************/ |
972 |
|
394436 |
static UINT _gx_image_reader_4bit_grayscale_transparent_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
973 |
|
|
{ |
974 |
|
|
GX_UBYTE *pLine; |
975 |
|
|
GX_UBYTE *pAuxData; |
976 |
|
|
GX_UBYTE gray; |
977 |
|
|
GX_UBYTE color; |
978 |
|
|
|
979 |
✓✓ |
394436 |
if (!image_reader -> gx_image_reader_size_testing) |
980 |
|
|
{ |
981 |
|
353541 |
_gx_image_reader_rgb2gray(pixel, &gray); |
982 |
|
353541 |
gray >>= 4; |
983 |
|
|
|
984 |
|
353541 |
color = (GX_UBYTE)(gray | (gray << 4)); |
985 |
|
353541 |
pixel -> gx_pixel_red = color; |
986 |
|
353541 |
pixel -> gx_pixel_green = color; |
987 |
|
353541 |
pixel -> gx_pixel_blue = color; |
988 |
|
|
|
989 |
|
353541 |
pLine = image_reader -> gx_image_reader_putdata; |
990 |
|
|
|
991 |
✓✓ |
353541 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_COMPRESS) |
992 |
|
|
{ |
993 |
|
|
/* with compression, with transparent: 1 byte color |
994 |
|
|
0x00-0x0f: pixel value |
995 |
|
|
0xff: transparent value */ |
996 |
✓✓ |
40895 |
if (pixel -> gx_pixel_alpha < 128) |
997 |
|
|
{ |
998 |
|
2308 |
(*pLine) = GX_TRANSPARENT_COLOR; |
999 |
|
|
} |
1000 |
|
|
else |
1001 |
|
|
{ |
1002 |
|
38587 |
(*pLine) = gray; |
1003 |
|
|
} |
1004 |
|
|
} |
1005 |
|
|
else |
1006 |
|
|
{ |
1007 |
|
|
/* without compression, with transparent: half byte color, |
1008 |
|
|
1-bit transparent go into auxdata. */ |
1009 |
✓✓ |
312646 |
if (image_reader -> gx_image_reader_putdata_mask & 0xf0) |
1010 |
|
|
{ |
1011 |
|
157124 |
(*pLine) = (GX_UBYTE)(gray << 4); |
1012 |
|
|
} |
1013 |
|
|
else |
1014 |
|
|
{ |
1015 |
|
155522 |
(*pLine) |= gray; |
1016 |
|
|
} |
1017 |
|
|
|
1018 |
|
312646 |
pAuxData = image_reader -> gx_image_reader_putauxdata; |
1019 |
|
|
|
1020 |
✓✓ |
312646 |
if (pixel -> gx_pixel_alpha > 128) |
1021 |
|
|
{ |
1022 |
|
217507 |
(*pAuxData) &= (GX_UBYTE)(~image_reader -> gx_image_reader_putauxdata_mask); |
1023 |
|
|
} |
1024 |
|
|
else |
1025 |
|
|
{ |
1026 |
|
95139 |
(*pAuxData) |= image_reader -> gx_image_reader_putauxdata_mask; |
1027 |
|
|
} |
1028 |
|
|
} |
1029 |
|
|
} |
1030 |
|
|
|
1031 |
✓✓ |
394436 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_COMPRESS) |
1032 |
|
|
{ |
1033 |
|
81790 |
image_reader -> gx_image_reader_putdata++; |
1034 |
|
|
} |
1035 |
|
|
else |
1036 |
|
|
{ |
1037 |
|
|
|
1038 |
|
312646 |
image_reader -> gx_image_reader_putdata_mask >>= 4; |
1039 |
|
|
|
1040 |
✓✓ |
312646 |
if (!image_reader -> gx_image_reader_putdata_mask) |
1041 |
|
|
{ |
1042 |
|
155522 |
image_reader -> gx_image_reader_putdata++; |
1043 |
|
155522 |
image_reader -> gx_image_reader_putdata_mask = 0xf0; |
1044 |
|
|
} |
1045 |
|
|
|
1046 |
|
312646 |
image_reader -> gx_image_reader_putauxdata_mask >>= 1; |
1047 |
✓✓ |
312646 |
if (!image_reader -> gx_image_reader_putauxdata_mask) |
1048 |
|
|
{ |
1049 |
|
38480 |
image_reader -> gx_image_reader_putauxdata++; |
1050 |
|
38480 |
image_reader -> gx_image_reader_putauxdata_mask = 0x80; |
1051 |
|
|
} |
1052 |
|
|
} |
1053 |
|
|
|
1054 |
|
394436 |
return GX_SUCCESS; |
1055 |
|
|
} |
1056 |
|
|
|
1057 |
|
|
/**************************************************************************/ |
1058 |
|
|
/* */ |
1059 |
|
|
/* FUNCTION RELEASE */ |
1060 |
|
|
/* */ |
1061 |
|
|
/* _gx_image_reader_monochrome_pixel_write PORTABLE C */ |
1062 |
|
|
/* 6.1 */ |
1063 |
|
|
/* AUTHOR */ |
1064 |
|
|
/* */ |
1065 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
1066 |
|
|
/* */ |
1067 |
|
|
/* DESCRIPTION */ |
1068 |
|
|
/* */ |
1069 |
|
|
/* This function writes a monochrome format pixel (no transparency) to */ |
1070 |
|
|
/* output pixelmap data structure. */ |
1071 |
|
|
/* */ |
1072 |
|
|
/* INPUT */ |
1073 |
|
|
/* */ |
1074 |
|
|
/* image_reader Image reader control block. */ |
1075 |
|
|
/* pixel Pixel to write. */ |
1076 |
|
|
/* */ |
1077 |
|
|
/* OUTPUT */ |
1078 |
|
|
/* */ |
1079 |
|
|
/* Completion Status */ |
1080 |
|
|
/* */ |
1081 |
|
|
/* CALLS */ |
1082 |
|
|
/* */ |
1083 |
|
|
/* _gx_image_reader_rgb2gray Convert RGB value to grayscale*/ |
1084 |
|
|
/* */ |
1085 |
|
|
/* CALLED BY */ |
1086 |
|
|
/* */ |
1087 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
1088 |
|
|
/* */ |
1089 |
|
|
/* RELEASE HISTORY */ |
1090 |
|
|
/* */ |
1091 |
|
|
/* DATE NAME DESCRIPTION */ |
1092 |
|
|
/* */ |
1093 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
1094 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
1095 |
|
|
/* resulting in version 6.1 */ |
1096 |
|
|
/* */ |
1097 |
|
|
/**************************************************************************/ |
1098 |
|
562013 |
static UINT _gx_image_reader_monochrome_pixel_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
1099 |
|
|
{ |
1100 |
|
|
GX_UBYTE *pLine; |
1101 |
|
|
GX_UBYTE gray; |
1102 |
|
|
GX_UBYTE color; |
1103 |
|
|
|
1104 |
|
562013 |
pLine = image_reader -> gx_image_reader_putdata; |
1105 |
|
|
|
1106 |
✓✓ |
562013 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_COMPRESS) |
1107 |
|
|
{ |
1108 |
|
|
/* [7-bit counter][1-bit color]*/ |
1109 |
✓✓ |
58477 |
if (!image_reader -> gx_image_reader_size_testing) |
1110 |
|
|
{ |
1111 |
|
3404 |
_gx_image_reader_rgb2gray(pixel, &gray); |
1112 |
✓✓ |
3404 |
if (gray > image_reader -> gx_image_reader_mono_shreshold) |
1113 |
|
|
{ |
1114 |
|
2104 |
(*pLine) |= 0x01; |
1115 |
|
|
} |
1116 |
|
|
else |
1117 |
|
|
{ |
1118 |
|
1300 |
(*pLine) &= 0xfe; |
1119 |
|
|
} |
1120 |
|
|
} |
1121 |
|
58477 |
image_reader -> gx_image_reader_putdata++; |
1122 |
|
|
} |
1123 |
|
|
else |
1124 |
|
|
{ |
1125 |
|
|
/* [1-bit color]*/ |
1126 |
|
503536 |
_gx_image_reader_rgb2gray(pixel, &gray); |
1127 |
✓✓ |
503536 |
if (gray > image_reader -> gx_image_reader_mono_shreshold) |
1128 |
|
|
{ |
1129 |
|
322452 |
(*pLine) |= image_reader -> gx_image_reader_putdata_mask; |
1130 |
|
322452 |
color = 255; |
1131 |
|
|
} |
1132 |
|
|
else |
1133 |
|
|
{ |
1134 |
|
181084 |
(*pLine) &= (GX_UBYTE)(~image_reader -> gx_image_reader_putdata_mask); |
1135 |
|
181084 |
color = 0; |
1136 |
|
|
} |
1137 |
|
|
|
1138 |
|
503536 |
pixel -> gx_pixel_red = color; |
1139 |
|
503536 |
pixel -> gx_pixel_green = color; |
1140 |
|
503536 |
pixel -> gx_pixel_blue = color; |
1141 |
|
503536 |
pixel -> gx_pixel_alpha = 0xff; |
1142 |
|
|
|
1143 |
|
503536 |
image_reader -> gx_image_reader_putdata_mask >>= 1; |
1144 |
|
|
|
1145 |
✓✓ |
503536 |
if (!image_reader -> gx_image_reader_putdata_mask) |
1146 |
|
|
{ |
1147 |
|
61722 |
image_reader -> gx_image_reader_putdata++; |
1148 |
|
61722 |
image_reader -> gx_image_reader_putdata_mask = 0x80; |
1149 |
|
|
} |
1150 |
|
|
} |
1151 |
|
|
|
1152 |
|
562013 |
return GX_SUCCESS; |
1153 |
|
|
} |
1154 |
|
|
|
1155 |
|
|
/**************************************************************************/ |
1156 |
|
|
/* */ |
1157 |
|
|
/* FUNCTION RELEASE */ |
1158 |
|
|
/* */ |
1159 |
|
|
/* _gx_image_reader_monochrome_transparent_write PORTABLE C */ |
1160 |
|
|
/* 6.1 */ |
1161 |
|
|
/* AUTHOR */ |
1162 |
|
|
/* */ |
1163 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
1164 |
|
|
/* */ |
1165 |
|
|
/* DESCRIPTION */ |
1166 |
|
|
/* */ |
1167 |
|
|
/* This function writes a monochrome format pixel (with transparency) */ |
1168 |
|
|
/* to output pixelmap data structure. */ |
1169 |
|
|
/* */ |
1170 |
|
|
/* INPUT */ |
1171 |
|
|
/* */ |
1172 |
|
|
/* image_reader Image reader control block. */ |
1173 |
|
|
/* pixel Pixel to write. */ |
1174 |
|
|
/* */ |
1175 |
|
|
/* OUTPUT */ |
1176 |
|
|
/* */ |
1177 |
|
|
/* Completion Status */ |
1178 |
|
|
/* */ |
1179 |
|
|
/* CALLS */ |
1180 |
|
|
/* */ |
1181 |
|
|
/* _gx_image_reader_rgb2gray Convert RGB value to grayscale*/ |
1182 |
|
|
/* */ |
1183 |
|
|
/* CALLED BY */ |
1184 |
|
|
/* */ |
1185 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
1186 |
|
|
/* */ |
1187 |
|
|
/* RELEASE HISTORY */ |
1188 |
|
|
/* */ |
1189 |
|
|
/* DATE NAME DESCRIPTION */ |
1190 |
|
|
/* */ |
1191 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
1192 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
1193 |
|
|
/* resulting in version 6.1 */ |
1194 |
|
|
/* */ |
1195 |
|
|
/**************************************************************************/ |
1196 |
|
464993 |
static UINT _gx_image_reader_monochrome_transparent_write(GX_IMAGE_READER *image_reader, GX_PIXEL *pixel) |
1197 |
|
|
{ |
1198 |
|
|
GX_UBYTE *pLine; |
1199 |
|
|
GX_UBYTE gray; |
1200 |
|
|
GX_UBYTE trans_mask; |
1201 |
|
|
GX_UBYTE color; |
1202 |
|
|
|
1203 |
|
464993 |
pLine = image_reader -> gx_image_reader_putdata; |
1204 |
|
|
|
1205 |
✓✓ |
464993 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_COMPRESS) |
1206 |
|
|
{ |
1207 |
|
|
/* [6-bit counter][1-bit color][1-bit transparency]*/ |
1208 |
✓✓ |
99770 |
if (!image_reader -> gx_image_reader_size_testing) |
1209 |
|
|
{ |
1210 |
✓✓ |
2949 |
if (pixel -> gx_pixel_alpha < 128) |
1211 |
|
|
{ |
1212 |
|
|
/* Mark as transparency. */ |
1213 |
|
877 |
(*pLine) &= 0xfc; |
1214 |
|
|
} |
1215 |
|
|
else |
1216 |
|
|
{ |
1217 |
|
2072 |
(*pLine) |= 0x01; |
1218 |
|
|
|
1219 |
|
|
/* Write color: 0 or 1. */ |
1220 |
|
2072 |
_gx_image_reader_rgb2gray(pixel, &gray); |
1221 |
✓✓ |
2072 |
if (gray > image_reader -> gx_image_reader_mono_shreshold) |
1222 |
|
|
{ |
1223 |
|
1075 |
(*pLine) |= 0x02; |
1224 |
|
|
} |
1225 |
|
|
else |
1226 |
|
|
{ |
1227 |
|
997 |
(*pLine) &= 0xfd; |
1228 |
|
|
} |
1229 |
|
|
} |
1230 |
|
|
} |
1231 |
|
99770 |
image_reader -> gx_image_reader_putdata++; |
1232 |
|
|
} |
1233 |
|
|
else |
1234 |
|
|
{ |
1235 |
|
|
/* [1-bit color][1-bit transparency]*/ |
1236 |
|
365223 |
trans_mask = image_reader -> gx_image_reader_putdata_mask >> 1; |
1237 |
✓✓ |
365223 |
if (pixel -> gx_pixel_alpha < 128) |
1238 |
|
|
{ |
1239 |
|
|
/* Mark as transparency. */ |
1240 |
|
111185 |
(*pLine) &= (GX_UBYTE)(~trans_mask); |
1241 |
|
111185 |
(*pLine) &= (GX_UBYTE)(~image_reader -> gx_image_reader_putdata_mask); |
1242 |
|
|
} |
1243 |
|
|
else |
1244 |
|
|
{ |
1245 |
|
254038 |
(*pLine) |= trans_mask; |
1246 |
|
|
|
1247 |
|
254038 |
_gx_image_reader_rgb2gray(pixel, &gray); |
1248 |
✓✓ |
254038 |
if (gray > image_reader -> gx_image_reader_mono_shreshold) |
1249 |
|
|
{ |
1250 |
|
112246 |
(*pLine) |= image_reader -> gx_image_reader_putdata_mask; |
1251 |
|
112246 |
color = 255; |
1252 |
|
|
} |
1253 |
|
|
else |
1254 |
|
|
{ |
1255 |
|
141792 |
(*pLine) &= (GX_UBYTE)(~image_reader -> gx_image_reader_putdata_mask); |
1256 |
|
141792 |
color = 0; |
1257 |
|
|
} |
1258 |
|
254038 |
pixel -> gx_pixel_red = color; |
1259 |
|
254038 |
pixel -> gx_pixel_green = color; |
1260 |
|
254038 |
pixel -> gx_pixel_blue = color; |
1261 |
|
|
} |
1262 |
|
|
|
1263 |
|
365223 |
image_reader -> gx_image_reader_putdata_mask >>= 2; |
1264 |
|
|
|
1265 |
✓✓ |
365223 |
if (!image_reader -> gx_image_reader_putdata_mask) |
1266 |
|
|
{ |
1267 |
|
89904 |
image_reader -> gx_image_reader_putdata++; |
1268 |
|
89904 |
image_reader -> gx_image_reader_putdata_mask = 0x80; |
1269 |
|
|
} |
1270 |
|
|
} |
1271 |
|
|
|
1272 |
|
464993 |
return GX_SUCCESS; |
1273 |
|
|
} |
1274 |
|
|
|
1275 |
|
|
/**************************************************************************/ |
1276 |
|
|
/* */ |
1277 |
|
|
/* FUNCTION RELEASE */ |
1278 |
|
|
/* */ |
1279 |
|
|
/* _gx_image_reader_pixel_rotated_write_callback_set PORTABLE C */ |
1280 |
|
|
/* 6.1.4 */ |
1281 |
|
|
/* AUTHOR */ |
1282 |
|
|
/* */ |
1283 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
1284 |
|
|
/* */ |
1285 |
|
|
/* DESCRIPTION */ |
1286 |
|
|
/* */ |
1287 |
|
|
/* This function sets pixel write callback of the image reader when */ |
1288 |
|
|
/* rotation mode is set. */ |
1289 |
|
|
/* */ |
1290 |
|
|
/* INPUT */ |
1291 |
|
|
/* */ |
1292 |
|
|
/* image_reader Image reader control block */ |
1293 |
|
|
/* outmap Outpu pixelmap. */ |
1294 |
|
|
/* */ |
1295 |
|
|
/* OUTPUT */ |
1296 |
|
|
/* */ |
1297 |
|
|
/* Completion Status */ |
1298 |
|
|
/* */ |
1299 |
|
|
/* CALLS */ |
1300 |
|
|
/* */ |
1301 |
|
|
/* _gx_image_reader_565rgb_rotated_pixel_write */ |
1302 |
|
|
/* Write 565rgb format pixel in */ |
1303 |
|
|
/* rotation mode */ |
1304 |
|
|
/* _gx_image_reader_24xrgb_rotated_pixel_write */ |
1305 |
|
|
/* Write 24xrgn format pixel in */ |
1306 |
|
|
/* rotation mode */ |
1307 |
|
|
/* */ |
1308 |
|
|
/* CALLED BY */ |
1309 |
|
|
/* */ |
1310 |
|
|
/* _gx_image_reader_pixel_write_callback_set */ |
1311 |
|
|
/* */ |
1312 |
|
|
/* RELEASE HISTORY */ |
1313 |
|
|
/* */ |
1314 |
|
|
/* DATE NAME DESCRIPTION */ |
1315 |
|
|
/* */ |
1316 |
|
|
/* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */ |
1317 |
|
|
/* 02-02-2021 Kenneth Maxwell Modified comment(s), */ |
1318 |
|
|
/* added 24xrgb format support,*/ |
1319 |
|
|
/* resulting in version 6.1.4 */ |
1320 |
|
|
/* */ |
1321 |
|
|
/**************************************************************************/ |
1322 |
|
180 |
static UINT _gx_image_reader_pixel_rotated_write_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap) |
1323 |
|
|
{ |
1324 |
✓✓✓ |
180 |
switch (outmap -> gx_pixelmap_format) |
1325 |
|
|
{ |
1326 |
|
67 |
case GX_COLOR_FORMAT_565RGB: |
1327 |
|
67 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_565rgb_rotated_pixel_write; |
1328 |
|
|
|
1329 |
✓✓ |
67 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ROTATE_CW) |
1330 |
|
|
{ |
1331 |
|
47 |
outmap -> gx_pixelmap_flags |= GX_PIXELMAP_ROTATED_90; |
1332 |
|
|
|
1333 |
|
47 |
image_reader -> gx_image_reader_putdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_data; |
1334 |
|
47 |
image_reader -> gx_image_reader_putdatarow += (outmap -> gx_pixelmap_width - 1) * (outmap -> gx_pixelmap_height << 1); |
1335 |
|
|
|
1336 |
✓✓ |
47 |
if (outmap -> gx_pixelmap_aux_data) |
1337 |
|
|
{ |
1338 |
|
32 |
image_reader -> gx_image_reader_putauxdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_aux_data; |
1339 |
|
32 |
image_reader -> gx_image_reader_putauxdatarow += (outmap -> gx_pixelmap_width - 1) * outmap -> gx_pixelmap_height; |
1340 |
|
|
} |
1341 |
|
|
|
1342 |
|
47 |
image_reader -> gx_image_reader_putdatarow_stride = 2; |
1343 |
|
47 |
image_reader -> gx_image_reader_putauxdatarow_stride = 1; |
1344 |
|
|
} |
1345 |
|
|
else |
1346 |
|
|
{ |
1347 |
|
20 |
outmap -> gx_pixelmap_flags |= GX_PIXELMAP_ROTATED_270; |
1348 |
|
|
|
1349 |
|
20 |
image_reader -> gx_image_reader_putdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_data; |
1350 |
|
20 |
image_reader -> gx_image_reader_putdatarow += (outmap -> gx_pixelmap_height - 1) * 2; |
1351 |
|
|
|
1352 |
✓✓ |
20 |
if (outmap -> gx_pixelmap_aux_data) |
1353 |
|
|
{ |
1354 |
|
15 |
image_reader -> gx_image_reader_putauxdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_aux_data; |
1355 |
|
15 |
image_reader -> gx_image_reader_putauxdatarow += (outmap -> gx_pixelmap_height - 1); |
1356 |
|
|
} |
1357 |
|
|
|
1358 |
|
20 |
image_reader -> gx_image_reader_putdatarow_stride = -2; |
1359 |
|
20 |
image_reader -> gx_image_reader_putauxdatarow_stride = -1; |
1360 |
|
|
} |
1361 |
|
67 |
break; |
1362 |
|
|
|
1363 |
|
112 |
case GX_COLOR_FORMAT_24XRGB: |
1364 |
|
112 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_24xrgb_rotated_pixel_write; |
1365 |
|
|
|
1366 |
✓✓ |
112 |
if (image_reader -> gx_image_reader_mode & GX_IMAGE_READER_MODE_ROTATE_CW) |
1367 |
|
|
{ |
1368 |
|
107 |
outmap -> gx_pixelmap_flags |= GX_PIXELMAP_ROTATED_90; |
1369 |
|
|
|
1370 |
|
107 |
image_reader -> gx_image_reader_putdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_data; |
1371 |
|
107 |
image_reader -> gx_image_reader_putdatarow += (outmap -> gx_pixelmap_width - 1) * (outmap -> gx_pixelmap_height << 2); |
1372 |
|
|
|
1373 |
|
107 |
image_reader -> gx_image_reader_putdatarow_stride = 4; |
1374 |
|
|
} |
1375 |
|
|
else |
1376 |
|
|
{ |
1377 |
|
5 |
outmap -> gx_pixelmap_flags |= GX_PIXELMAP_ROTATED_270; |
1378 |
|
|
|
1379 |
|
5 |
image_reader -> gx_image_reader_putdatarow = (GX_UBYTE *)outmap -> gx_pixelmap_data; |
1380 |
|
5 |
image_reader -> gx_image_reader_putdatarow += ((outmap -> gx_pixelmap_height - 1) << 2); |
1381 |
|
|
|
1382 |
|
5 |
image_reader -> gx_image_reader_putdatarow_stride = -4; |
1383 |
|
|
} |
1384 |
|
112 |
break; |
1385 |
|
|
|
1386 |
|
1 |
default: |
1387 |
|
1 |
return GX_NOT_SUPPORTED; |
1388 |
|
|
} |
1389 |
|
|
|
1390 |
|
179 |
return GX_SUCCESS; |
1391 |
|
|
} |
1392 |
|
|
|
1393 |
|
|
/**************************************************************************/ |
1394 |
|
|
/* */ |
1395 |
|
|
/* FUNCTION RELEASE */ |
1396 |
|
|
/* */ |
1397 |
|
|
/* _gx_image_reader_pixel_write_callback_set PORTABLE C */ |
1398 |
|
|
/* 6.1.3 */ |
1399 |
|
|
/* AUTHOR */ |
1400 |
|
|
/* */ |
1401 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
1402 |
|
|
/* */ |
1403 |
|
|
/* DESCRIPTION */ |
1404 |
|
|
/* */ |
1405 |
|
|
/* This function sets pixel write callback of the image reader. */ |
1406 |
|
|
/* */ |
1407 |
|
|
/* INPUT */ |
1408 |
|
|
/* */ |
1409 |
|
|
/* image_reader Image reader control block */ |
1410 |
|
|
/* outmap Outpu pixelmap. */ |
1411 |
|
|
/* */ |
1412 |
|
|
/* OUTPUT */ |
1413 |
|
|
/* */ |
1414 |
|
|
/* Completion Status */ |
1415 |
|
|
/* */ |
1416 |
|
|
/* CALLS */ |
1417 |
|
|
/* */ |
1418 |
|
|
/* _gx_image_reader_565rgb_rle_pixel_write */ |
1419 |
|
|
/* Write 565 rgb fromat pixel */ |
1420 |
|
|
/* in compress mode */ |
1421 |
|
|
/* _gx_image_reader_565rgb_pixel_write Write 565 rgb format pixel */ |
1422 |
|
|
/* _gx_image_reader_1555xrgb_rle_pixel_write */ |
1423 |
|
|
/* Write 1555xrgb format pixel */ |
1424 |
|
|
/* in compress mode */ |
1425 |
|
|
/* _gx_image_reader_1555xrgb_pixel_write Write 1555xrgb format pixel */ |
1426 |
|
|
/* _gx_image_reader_4444argb_transparent_write */ |
1427 |
|
|
/* Write 4444argb format pixel */ |
1428 |
|
|
/* with transparency */ |
1429 |
|
|
/* _gx_image_reader_4444argb_pixel_write Write 4444argb format pixel */ |
1430 |
|
|
/* _gx_image_reader_32argb_pixel_write Write 32argb format pixel */ |
1431 |
|
|
/* _gx_image_reader_24xrgb_pixel_write Write 24xrgb format pixel */ |
1432 |
|
|
/* _gx_image_reader_8bit_alpha_write Write 8bit alphamap format */ |
1433 |
|
|
/* pixel */ |
1434 |
|
|
/* _gx_image_reader_8bit_palette_write Write 8bit palette format */ |
1435 |
|
|
/* pixel */ |
1436 |
|
|
/* _gx_image_reader_4bit_grayscale_transparent_write */ |
1437 |
|
|
/* Write 4bit grayscale format */ |
1438 |
|
|
/* pixel with transparency */ |
1439 |
|
|
/* _gx_image_reader_4bit_grayscale_pixel_write */ |
1440 |
|
|
/* Write 4bit grayscale format */ |
1441 |
|
|
/* pixel */ |
1442 |
|
|
/* _gx_image_reader_monochrome_transparent_write */ |
1443 |
|
|
/* Write 1bpp format pixel with */ |
1444 |
|
|
/* transparency */ |
1445 |
|
|
/* _gx_image_reader_monochrome_pixel_write */ |
1446 |
|
|
/* Write 1bpp format pixel */ |
1447 |
|
|
/* _gx_system_memory_allocator Application defined memory */ |
1448 |
|
|
/* allocator function */ |
1449 |
|
|
/* _gx_system_memory_free Application defined memory */ |
1450 |
|
|
/* free function */ |
1451 |
|
|
/* */ |
1452 |
|
|
/* CALLED BY */ |
1453 |
|
|
/* */ |
1454 |
|
|
/* _gx_image_reader_colorspace_convert */ |
1455 |
|
|
/* */ |
1456 |
|
|
/* RELEASE HISTORY */ |
1457 |
|
|
/* */ |
1458 |
|
|
/* DATE NAME DESCRIPTION */ |
1459 |
|
|
/* */ |
1460 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
1461 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
1462 |
|
|
/* resulting in version 6.1 */ |
1463 |
|
|
/* 12-31-2020 Kenneth Maxwell Modified comment(s), */ |
1464 |
|
|
/* supported rotation mode, */ |
1465 |
|
|
/* resulting in version 6.1.3 */ |
1466 |
|
|
/* */ |
1467 |
|
|
/**************************************************************************/ |
1468 |
|
1150 |
UINT _gx_image_reader_pixel_write_callback_set(GX_IMAGE_READER *image_reader, GX_PIXELMAP *outmap) |
1469 |
|
|
{ |
1470 |
|
|
/* Allocate memory for data of the output pixelmap. */ |
1471 |
✓✓ |
1150 |
if (outmap -> gx_pixelmap_data_size) |
1472 |
|
|
{ |
1473 |
|
953 |
outmap -> gx_pixelmap_data = (GX_UBYTE *)_gx_system_memory_allocator(outmap -> gx_pixelmap_data_size); |
1474 |
|
|
|
1475 |
✓✓ |
953 |
if (outmap -> gx_pixelmap_data == GX_NULL) |
1476 |
|
|
{ |
1477 |
|
2 |
return GX_SYSTEM_MEMORY_ERROR; |
1478 |
|
|
} |
1479 |
|
|
|
1480 |
|
951 |
memset((void *)outmap -> gx_pixelmap_data, 0, outmap -> gx_pixelmap_data_size); |
1481 |
|
|
|
1482 |
|
951 |
image_reader -> gx_image_reader_putdata = (GX_UBYTE *)outmap -> gx_pixelmap_data; |
1483 |
|
|
} |
1484 |
|
|
|
1485 |
|
|
/* Allocate memory for aux data of the output pixelmap. */ |
1486 |
✓✓ |
1148 |
if (outmap -> gx_pixelmap_aux_data_size) |
1487 |
|
|
{ |
1488 |
|
185 |
outmap -> gx_pixelmap_aux_data = (GX_UBYTE *)_gx_system_memory_allocator(outmap -> gx_pixelmap_aux_data_size); |
1489 |
|
|
|
1490 |
✓✓ |
185 |
if (outmap -> gx_pixelmap_aux_data == GX_NULL) |
1491 |
|
|
{ |
1492 |
|
1 |
_gx_system_memory_free((void *)outmap -> gx_pixelmap_data); |
1493 |
|
1 |
outmap -> gx_pixelmap_data = GX_NULL; |
1494 |
|
1 |
return GX_SYSTEM_MEMORY_ERROR; |
1495 |
|
|
} |
1496 |
|
|
|
1497 |
|
184 |
memset((void *)outmap -> gx_pixelmap_aux_data, 0, outmap -> gx_pixelmap_aux_data_size); |
1498 |
|
|
|
1499 |
|
184 |
image_reader -> gx_image_reader_putauxdata = (GX_UBYTE *)outmap -> gx_pixelmap_aux_data; |
1500 |
|
|
} |
1501 |
|
|
|
1502 |
✓✓ |
1147 |
if (image_reader -> gx_image_reader_mode & (GX_IMAGE_READER_MODE_ROTATE_CW | GX_IMAGE_READER_MODE_ROTATE_CCW)) |
1503 |
|
|
{ |
1504 |
|
180 |
return _gx_image_reader_pixel_rotated_write_callback_set(image_reader, outmap); |
1505 |
|
|
} |
1506 |
|
|
|
1507 |
|
|
/* Set pixel write callback. */ |
1508 |
✓✓✓✓ ✓✓✓✓ ✓ |
967 |
switch (outmap -> gx_pixelmap_format) |
1509 |
|
|
{ |
1510 |
|
252 |
case GX_COLOR_FORMAT_565RGB: |
1511 |
✓✓ |
252 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) |
1512 |
|
|
{ |
1513 |
|
61 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_565rgb_rle_pixel_write; |
1514 |
|
|
} |
1515 |
|
|
else |
1516 |
|
|
{ |
1517 |
|
191 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_565rgb_pixel_write; |
1518 |
|
|
} |
1519 |
|
252 |
break; |
1520 |
|
|
|
1521 |
|
54 |
case GX_COLOR_FORMAT_1555XRGB: |
1522 |
✓✓ |
54 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) |
1523 |
|
|
{ |
1524 |
|
32 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_1555xrgb_rle_pixel_write; |
1525 |
|
|
} |
1526 |
|
|
else |
1527 |
|
|
{ |
1528 |
|
22 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_1555xrgb_pixel_write; |
1529 |
|
|
} |
1530 |
|
54 |
break; |
1531 |
|
|
|
1532 |
|
38 |
case GX_COLOR_FORMAT_4444ARGB: |
1533 |
✓✓ |
38 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) |
1534 |
|
|
{ |
1535 |
|
11 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_4444argb_transparent_write; |
1536 |
|
|
} |
1537 |
|
|
else |
1538 |
|
|
{ |
1539 |
|
27 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_4444argb_pixel_write; |
1540 |
|
|
} |
1541 |
|
38 |
break; |
1542 |
|
|
|
1543 |
|
178 |
case GX_COLOR_FORMAT_32ARGB: |
1544 |
|
|
case GX_COLOR_FORMAT_24XRGB: |
1545 |
✓✓ |
178 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) |
1546 |
|
|
{ |
1547 |
|
70 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_32argb_pixel_write; |
1548 |
|
|
} |
1549 |
|
|
else |
1550 |
|
|
{ |
1551 |
|
108 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_24xrgb_pixel_write; |
1552 |
|
|
} |
1553 |
|
178 |
break; |
1554 |
|
|
|
1555 |
|
238 |
case GX_COLOR_FORMAT_8BIT_ALPHAMAP: |
1556 |
|
238 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_8bit_alpha_write; |
1557 |
|
238 |
break; |
1558 |
|
|
|
1559 |
|
108 |
case GX_COLOR_FORMAT_8BIT_PALETTE: |
1560 |
|
108 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_8bit_palette_write; |
1561 |
|
108 |
break; |
1562 |
|
|
|
1563 |
|
47 |
case GX_COLOR_FORMAT_4BIT_GRAY: |
1564 |
✓✓ |
47 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT) |
1565 |
|
|
{ |
1566 |
|
15 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_4bit_grayscale_transparent_write; |
1567 |
|
|
} |
1568 |
|
|
else |
1569 |
|
|
{ |
1570 |
|
32 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_4bit_grayscale_pixel_write; |
1571 |
|
|
} |
1572 |
|
47 |
image_reader -> gx_image_reader_putdata_mask = 0xf0; |
1573 |
|
47 |
image_reader -> gx_image_reader_putauxdata_mask = 0x80; |
1574 |
|
47 |
break; |
1575 |
|
|
|
1576 |
|
51 |
case GX_COLOR_FORMAT_MONOCHROME: |
1577 |
✓✓ |
51 |
if (outmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT) |
1578 |
|
|
{ |
1579 |
|
22 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_monochrome_transparent_write; |
1580 |
|
|
} |
1581 |
|
|
else |
1582 |
|
|
{ |
1583 |
|
29 |
image_reader -> gx_image_reader_pixel_write = _gx_image_reader_monochrome_pixel_write; |
1584 |
|
|
} |
1585 |
|
51 |
image_reader -> gx_image_reader_putdata_mask = 0x80; |
1586 |
|
51 |
break; |
1587 |
|
|
|
1588 |
|
1 |
default: |
1589 |
|
1 |
return GX_NOT_SUPPORTED; |
1590 |
|
|
} |
1591 |
|
|
|
1592 |
|
966 |
return GX_SUCCESS; |
1593 |
|
|
} |
1594 |
|
|
#endif |
1595 |
|
|
|