|
29 | 29 |
|
30 | 30 | #include "gpujpeg_exif.h" |
31 | 31 |
|
32 | | -#include <assert.h> |
33 | | -#include <ctype.h> |
34 | | -#include <stdint.h> |
35 | | -#include <stdlib.h> |
36 | | -#include <string.h> |
37 | | -#include <time.h> // for strftime |
38 | | - |
| 32 | +#include <assert.h> // for assert |
| 33 | +#include <ctype.h> // for isdigit |
| 34 | +#include <stdint.h> // for uint8_t, uint32_t, uint16_t |
| 35 | +#include <stdio.h> // for printf |
| 36 | +#include <stdlib.h> // for size_t, NULL, free, abort, calloc |
| 37 | +#include <string.h> // for memcpy, strlen, memmove, strcmp |
| 38 | +#include <time.h> // for strftime, time, time_t |
| 39 | +// IWYU pragma: no_include <endian.h> # via compat/endian.h. |
| 40 | + |
| 41 | +// for strncasecmp |
39 | 42 | #ifdef _WIN32 |
40 | 43 | #define strncasecmp _strnicmp |
| 44 | +#else |
| 45 | +#include <strings.h> |
41 | 46 | #endif |
42 | 47 |
|
43 | | -#include "compat/endian.h" |
44 | | -#include "gpujpeg_common_internal.h" |
45 | | -#include "gpujpeg_encoder_internal.h" |
46 | | -#include "gpujpeg_marker.h" |
47 | | -#include "gpujpeg_writer.h" |
| 48 | +#include "../libgpujpeg/gpujpeg_common.h" // for gpujpeg_image_parameters, gpuj... |
| 49 | +#include "../libgpujpeg/gpujpeg_encoder.h" // for GPUJPEG_ENC_OPT_EXIF_TAG |
| 50 | +#include "../libgpujpeg/gpujpeg_type.h" // for gpujpeg_color_space |
| 51 | +#include "compat/endian.h" // IWYU pragma: keep for htobe32 |
| 52 | +#include "compat/time.h" // IWYU pragma: keep for localtime_s |
| 53 | +#include "gpujpeg_common_internal.h" // for gpujpeg_coder, ERROR_MSG, WARN... |
| 54 | +#include "gpujpeg_encoder_internal.h" // for gpujpeg_encoder |
| 55 | +#include "gpujpeg_marker.h" // for gpujpeg_marker_code |
| 56 | +#include "gpujpeg_util.h" // for ARR_SIZE |
| 57 | +#include "gpujpeg_writer.h" // for gpujpeg_writer, gpujpeg_writer... |
48 | 58 |
|
49 | 59 | enum exif_tag_type { |
50 | 60 | ET_NONE = 0, |
@@ -129,6 +139,7 @@ enum { |
129 | 139 | ETIFF_INCHES = 2, |
130 | 140 | NEXT_IFD_PTR_SZ = 4, |
131 | 141 | IFD_ITEM_SZ = 12, |
| 142 | + DPI_DEFAULT = 72, |
132 | 143 | EEXIF_FIRST = 0x827A, // (Exposure time) first tag id of Exif Private Tags |
133 | 144 | }; |
134 | 145 |
|
@@ -321,11 +332,12 @@ gpujpeg_write_0th(struct gpujpeg_encoder* encoder, const uint8_t* start) |
321 | 332 | { |
322 | 333 | char date_time[] = " : : : : "; // unknown val by Exif 2.3 |
323 | 334 | time_t now = time(NULL); |
324 | | - (void) strftime(date_time, sizeof date_time, "%Y:%m:%d %H:%M:%S", localtime(&now)); |
| 335 | + struct tm buf; |
| 336 | + (void) strftime(date_time, sizeof date_time, "%Y:%m:%d %H:%M:%S", localtime_s(&now, &buf)); |
325 | 337 | struct tag_value tags[] = { |
326 | 338 | {ETIFF_ORIENTATION, {.uvalue = ETIFF_ORIENT_HORIZONTAL}}, |
327 | | - {ETIFF_XRESOLUTION, {.urational = {72, 1}} }, |
328 | | - {ETIFF_YRESOLUTION, {.urational = {72, 1}} }, |
| 339 | + {ETIFF_XRESOLUTION, {.urational = {DPI_DEFAULT, 1}} }, |
| 340 | + {ETIFF_YRESOLUTION, {.urational = {DPI_DEFAULT, 1}} }, |
329 | 341 | {ETIFF_RESOLUTION_UNIT, {.uvalue = ETIFF_INCHES} }, |
330 | 342 | {ETIFF_SOFTWARE, {.csvalue = "GPUJPEG"} }, |
331 | 343 | {ETIFF_DATE_TIME , {.csvalue = date_time} }, |
|
0 commit comments