exif-utils.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*! \file exif-utils.h
  2. * \brief EXIF data manipulation functions and types
  3. */
  4. /*
  5. * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef __EXIF_UTILS_H__
  23. #define __EXIF_UTILS_H__
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. #include <libexif/exif-byte-order.h>
  28. #include <libexif/exif-format.h>
  29. #include <libexif/_stdint.h>
  30. /* If these definitions don't work for you, please let us fix the
  31. * macro generating _stdint.h */
  32. /*! EXIF Unsigned Byte data type */
  33. typedef unsigned char ExifByte; /* 1 byte */
  34. /*! EXIF Signed Byte data type */
  35. typedef signed char ExifSByte; /* 1 byte */
  36. /*! EXIF Text String data type */
  37. typedef char * ExifAscii;
  38. /*! EXIF Unsigned Short data type */
  39. typedef uint16_t ExifShort; /* 2 bytes */
  40. /*! EXIF Signed Short data type */
  41. typedef int16_t ExifSShort; /* 2 bytes */
  42. /*! EXIF Unsigned Long data type */
  43. typedef uint32_t ExifLong; /* 4 bytes */
  44. /*! EXIF Signed Long data type */
  45. typedef int32_t ExifSLong; /* 4 bytes */
  46. /*! EXIF Unsigned Rational data type */
  47. typedef struct {ExifLong numerator; ExifLong denominator;} ExifRational;
  48. typedef char ExifUndefined; /* 1 byte */
  49. /*! EXIF Signed Rational data type */
  50. typedef struct {ExifSLong numerator; ExifSLong denominator;} ExifSRational;
  51. /*! Retrieve an #ExifShort value from memory.
  52. *
  53. * \param[in] b pointer to raw EXIF value in memory
  54. * \param[in] order byte order of raw value
  55. * \return value
  56. */
  57. ExifShort exif_get_short (const unsigned char *b, ExifByteOrder order);
  58. /*! Retrieve an #ExifSShort value from memory.
  59. *
  60. * \param[in] b pointer to raw EXIF value in memory
  61. * \param[in] order byte order of raw value
  62. * \return value
  63. */
  64. ExifSShort exif_get_sshort (const unsigned char *b, ExifByteOrder order);
  65. /*! Retrieve an #ExifLong value from memory.
  66. *
  67. * \param[in] b pointer to raw EXIF value in memory
  68. * \param[in] order byte order of raw value
  69. * \return value
  70. */
  71. ExifLong exif_get_long (const unsigned char *b, ExifByteOrder order);
  72. /*! Retrieve an #ExifSLong value from memory.
  73. *
  74. * \param[in] b pointer to raw EXIF value in memory
  75. * \param[in] order byte order of raw value
  76. * \return value
  77. */
  78. ExifSLong exif_get_slong (const unsigned char *b, ExifByteOrder order);
  79. /*! Retrieve an #ExifRational value from memory.
  80. *
  81. * \param[in] b pointer to raw EXIF value in memory
  82. * \param[in] order byte order of raw value
  83. * \return value
  84. */
  85. ExifRational exif_get_rational (const unsigned char *b, ExifByteOrder order);
  86. /*! Retrieve an #ExifSRational value from memory.
  87. *
  88. * \param[in] b pointer to raw EXIF value in memory
  89. * \param[in] order byte order of raw value
  90. * \return value
  91. */
  92. ExifSRational exif_get_srational (const unsigned char *b, ExifByteOrder order);
  93. /*! Store an ExifShort value into memory in EXIF format.
  94. *
  95. * \param[out] b buffer in which to write raw value
  96. * \param[in] order byte order to use
  97. * \param[in] value data value to store
  98. */
  99. void exif_set_short (unsigned char *b, ExifByteOrder order,
  100. ExifShort value);
  101. /*! Store an ExifSShort value into memory in EXIF format.
  102. *
  103. * \param[out] b buffer in which to write raw value
  104. * \param[in] order byte order to use
  105. * \param[in] value data value to store
  106. */
  107. void exif_set_sshort (unsigned char *b, ExifByteOrder order,
  108. ExifSShort value);
  109. /*! Store an ExifLong value into memory in EXIF format.
  110. *
  111. * \param[out] b buffer in which to write raw value
  112. * \param[in] order byte order to use
  113. * \param[in] value data value to store
  114. */
  115. void exif_set_long (unsigned char *b, ExifByteOrder order,
  116. ExifLong value);
  117. /*! Store an ExifSLong value into memory in EXIF format.
  118. *
  119. * \param[out] b buffer in which to write raw value
  120. * \param[in] order byte order to use
  121. * \param[in] value data value to store
  122. */
  123. void exif_set_slong (unsigned char *b, ExifByteOrder order,
  124. ExifSLong value);
  125. /*! Store an ExifRational value into memory in EXIF format.
  126. *
  127. * \param[out] b buffer in which to write raw value
  128. * \param[in] order byte order to use
  129. * \param[in] value data value to store
  130. */
  131. void exif_set_rational (unsigned char *b, ExifByteOrder order,
  132. ExifRational value);
  133. /*! Store an ExifSRational value into memory in EXIF format.
  134. *
  135. * \param[out] b buffer in which to write raw value
  136. * \param[in] order byte order to use
  137. * \param[in] value data value to store
  138. */
  139. void exif_set_srational (unsigned char *b, ExifByteOrder order,
  140. ExifSRational value);
  141. /*! \internal */
  142. void exif_convert_utf16_to_utf8 (char *out, const unsigned short *in, int maxlen);
  143. /* Please do not use this function outside of the library. */
  144. /*! \internal */
  145. void exif_array_set_byte_order (ExifFormat, unsigned char *, unsigned int,
  146. ExifByteOrder o_orig, ExifByteOrder o_new);
  147. #undef MIN
  148. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  149. #undef MAX
  150. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  151. /* For compatibility with older versions */
  152. /*! \deprecated Use EXIF_TAG_SUB_SEC_TIME instead. */
  153. #define EXIF_TAG_SUBSEC_TIME EXIF_TAG_SUB_SEC_TIME
  154. #ifdef __cplusplus
  155. }
  156. #endif /* __cplusplus */
  157. #endif /* __EXIF_UTILS_H__ */