libdng.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #ifndef LIBDNG_LIBRARY_H
  2. #define LIBDNG_LIBRARY_H
  3. #include <limits.h>
  4. #include <time.h>
  5. #include <stdint.h>
  6. #include <stdbool.h>
  7. #define EXPORT __attribute__((__visibility__("default")))
  8. typedef struct {
  9. char *camera_make;
  10. char *camera_model;
  11. char *unique_camera_model;
  12. char *software;
  13. uint16_t orientation;
  14. struct tm datetime;
  15. uint16_t exposure_program;
  16. float exposure_time;
  17. uint32_t iso;
  18. float fnumber;
  19. float focal_length;
  20. float crop_factor;
  21. float frame_rate;
  22. // Raw image data
  23. uint16_t bayer_pattern_dimensions[2];
  24. float neutral[3];
  25. float analogbalance[3];
  26. uint8_t cfapattern[4];
  27. uint32_t whitelevel;
  28. // Calibration data
  29. float color_matrix_1[9];
  30. float color_matrix_2[9];
  31. float forward_matrix_1[9];
  32. float forward_matrix_2[9];
  33. unsigned short illuminant_1;
  34. unsigned short illuminant_2;
  35. unsigned int hue_sat_map_dims[3];
  36. size_t tone_curve_length;
  37. float *tone_curve;
  38. float *hue_sat_map_data_1;
  39. float *hue_sat_map_data_2;
  40. uint16_t bit_depth;
  41. bool needs_repack;
  42. uint32_t width;
  43. uint32_t height;
  44. float distortion_a;
  45. float distortion_b;
  46. float distortion_c;
  47. float vignette_k1;
  48. float vignette_k2;
  49. float vignette_k3;
  50. } libdng_info;
  51. #define LIBDNG_ORIENTATION_TOPLEFT 1
  52. #define LIBDNG_ORIENTATION_TOPRIGHT 2
  53. #define LIBDNG_ORIENTATION_BOTRIGHT 3
  54. #define LIBDNG_ORIENTATION_BOTLEFT 4
  55. #define LIBDNG_ORIENTATION_LEFTTOP 5
  56. #define LIBDNG_ORIENTATION_RIGHTTOP 6
  57. #define LIBDNG_ORIENTATION_RIGHTBOT 7
  58. #define LIBDNG_ORIENTATION_LEFTBOT 8
  59. #define LIBDNG_EXPOSUREPROGRAM_UNDEFINED 0
  60. #define LIBDNG_EXPOSUREPROGRAM_MANUAL 1
  61. #define LIBDNG_EXPOSUREPROGRAM_NORMAL 2
  62. #define LIBDNG_EXPOSUREPROGRAM_APERTURE_PRIORITY 3
  63. #define LIBDNG_EXPOSUREPROGRAM_SHUTTER_PRIORITY 4
  64. #define LIBDNG_EXPOSUREPROGRAM_CREATIVE 5
  65. #define LIBDNG_EXPOSUREPROGRAM_ACTION 6
  66. #define LIBDNG_EXPOSUREPROGRAM_PORTRAIT 7
  67. #define LIBDNG_EXPOSUREPROGRAM_LANDSCAPE 8
  68. #define LIBDNG_ILLUMINANT_UNKNOWN 0
  69. #define LIBDNG_ILLUMINANT_DAYLIGHT 1
  70. #define LIBDNG_ILLUMINANT_FLUORESCENT 2
  71. #define LIBDNG_ILLUMINANT_TUNGSTEN 3
  72. #define LIBDNG_ILLUMINANT_FLASH 4
  73. #define LIBDNG_ILLUMINANT_FINE_WEATHER 9
  74. #define LIBDNG_ILLUMINANT_CLOUDY_WEATHER 10
  75. #define LIBDNG_ILLUMINANT_SHADE 11
  76. #define LIBDNG_ILLUMINANT_DAYLIGHT_FLUORESCENT 12
  77. #define LIBDNG_ILLUMINANT_DAY_WHITE_FLUORESCENT 13
  78. #define LIBDNG_ILLUMINANT_COOL_WHITE_FLUORESCENT 14
  79. #define LIBDNG_ILLUMINANT_WHITE_FLUORESCENT 15
  80. #define LIBDNG_ILLUMINANT_STANDARD_A 17
  81. #define LIBDNG_ILLUMINANT_STANDARD_B 18
  82. #define LIBDNG_ILLUMINANT_STANDARD_C 19
  83. #define LIBDNG_ILLUMINANT_D55 20
  84. #define LIBDNG_ILLUMINANT_D65 21
  85. #define LIBDNG_ILLUMINANT_D75 22
  86. #define LIBDNG_ILLUMINANT_D50 23
  87. #define LIBDNG_ILLUMINANT_ISO_TUNGSTEN 24
  88. #define LIBDNG_ILLUMINANT_OTHER 255
  89. EXPORT int
  90. libdng_init();
  91. EXPORT void
  92. libdng_new(libdng_info *dng);
  93. EXPORT void
  94. libdng_free(libdng_info *dng);
  95. EXPORT int
  96. libdng_set_mode_from_name(libdng_info *dng, const char *name);
  97. EXPORT int
  98. libdng_set_mode_from_pixfmt(libdng_info *dng, uint32_t pixfmt);
  99. EXPORT int
  100. libdng_set_make_model(libdng_info *dng, const char *make, const char *model);
  101. EXPORT int
  102. libdng_set_software(libdng_info *dng, const char *software);
  103. EXPORT int
  104. libdng_set_datetime(libdng_info *dng, struct tm time);
  105. EXPORT int
  106. libdng_set_datetime_now(libdng_info *dng);
  107. EXPORT int
  108. libdng_set_orientation(libdng_info *dng, uint16_t orientation);
  109. EXPORT int
  110. libdng_set_neutral(libdng_info *dng, float red, float green, float blue);
  111. EXPORT int
  112. libdng_set_analog_balance(libdng_info *dng, float red, float green, float blue);
  113. EXPORT int
  114. libdng_load_calibration_file(libdng_info *dng, const char *path);
  115. EXPORT int
  116. libdng_set_exposure_program(libdng_info *dng, uint16_t mode);
  117. EXPORT int
  118. libdng_set_exposure_time(libdng_info *dng, float seconds);
  119. EXPORT int
  120. libdng_set_iso(libdng_info *dng, uint32_t isospeed);
  121. EXPORT int
  122. libdng_set_fnumber(libdng_info *dng, float fnumber);
  123. EXPORT int
  124. libdng_set_focal_length(libdng_info *dng, float focal_length, float crop_factor);
  125. EXPORT int
  126. libdng_set_frame_rate(libdng_info *dng, float framerate);
  127. EXPORT int
  128. libdng_set_distortion(libdng_info *dng, float a, float b, float c);
  129. EXPORT int
  130. libdng_set_vignette(libdng_info *dng, float k1, float k2, float k3);
  131. EXPORT int
  132. libdng_write(libdng_info *dng, const char *path, unsigned int width, unsigned int height, const uint8_t *data,
  133. size_t length);
  134. EXPORT int
  135. libdng_write_with_thumbnail(libdng_info *dng, const char *path, unsigned int width, unsigned int height,
  136. const uint8_t *data,
  137. size_t length, unsigned int thumb_width, unsigned int thumb_height, const uint8_t *thumb, size_t thumb_length);
  138. EXPORT int
  139. libdng_read(libdng_info *dng, const char *path);
  140. EXPORT int
  141. libdng_read_image(libdng_info *dng, const char *path, uint8_t index, uint8_t **data, size_t *length, uint32_t *width,
  142. uint32_t *height);
  143. #endif //LIBDNG_LIBRARY_H