qcms.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* vim: set ts=8 sw=8 noexpandtab: */
  2. // qcms
  3. // Copyright (C) 2009 Mozilla Foundation
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining
  6. // a copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the Software
  10. // is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  17. // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. #ifndef QCMS_H
  23. #define QCMS_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdio.h>
  28. struct _qcms_profile;
  29. typedef struct _qcms_profile qcms_profile;
  30. struct _qcms_transform;
  31. typedef struct _qcms_transform qcms_transform;
  32. typedef int qcms_bool;
  33. /* ICC Section 6.1.5 Color Space Signatures (abridged) */
  34. typedef enum {
  35. XYZData /* ‘XYZ ’ */ = 0x58595A20,
  36. labData /* ‘Lab ’ */ = 0x4C616220,
  37. luvData /* ‘Luv ’ */ = 0x4C757620,
  38. YCbCrData /* ‘YCbr' */ = 0x59436272,
  39. YxyData /* ‘Yxy ’ */ = 0x59787920,
  40. rgbData /* ‘RGB ’ */ = 0x52474220,
  41. grayData /* ‘GRAY’ */ = 0x47524159,
  42. hsvData /* ‘HSV ’ */ = 0x48535620,
  43. hlsData /* ‘HLS ’ */ = 0x484C5320,
  44. cmykData /* ‘CMYK’ */ = 0x434D594B,
  45. cmyData /* ‘CMY ’ */ = 0x434D5920,
  46. } qcms_color_space;
  47. /* ICC Section 6.1.11 Rendering Intents */
  48. typedef enum {
  49. QCMS_INTENT_DEFAULT = 0,
  50. QCMS_INTENT_PERCEPTUAL = 0,
  51. QCMS_INTENT_RELATIVE_COLORIMETRIC = 1,
  52. QCMS_INTENT_SATURATION = 2,
  53. QCMS_INTENT_ABSOLUTE_COLORIMETRIC = 3
  54. } qcms_intent;
  55. /* Input data formats */
  56. typedef enum {
  57. QCMS_DATA_RGB_8,
  58. QCMS_DATA_RGBA_8,
  59. QCMS_DATA_GRAY_8,
  60. QCMS_DATA_GRAYA_8
  61. } qcms_data_type;
  62. /* Output data format for qcms_transform_data_type() */
  63. typedef enum {
  64. QCMS_OUTPUT_RGBX,
  65. QCMS_OUTPUT_BGRX
  66. } qcms_output_type;
  67. /* Output data format for qcms_transform_get_input|output_trc_rgba() */
  68. typedef enum {
  69. QCMS_TRC_PARAMETRIC, // Not implemented.
  70. QCMS_TRC_FLOAT, // Not implemented.
  71. QCMS_TRC_HALF_FLOAT, // IEE754: binary16.
  72. QCMS_TRC_USHORT, // 0.16 fixed point.
  73. } qcms_trc_type;
  74. /* Output data of specific channel curve for qcms_profile_get_parametric_curve() */
  75. typedef enum {
  76. QCMS_TRC_RED,
  77. QCMS_TRC_GREEN,
  78. QCMS_TRC_BLUE,
  79. } qcms_trc_channel;
  80. typedef struct {
  81. double x;
  82. double y;
  83. double Y;
  84. } qcms_CIE_xyY;
  85. typedef struct {
  86. qcms_CIE_xyY red;
  87. qcms_CIE_xyY green;
  88. qcms_CIE_xyY blue;
  89. } qcms_CIE_xyYTRIPLE;
  90. typedef struct {
  91. float X;
  92. float Y;
  93. float Z;
  94. } qcms_xyz_float;
  95. qcms_profile* qcms_profile_create_rgb_with_gamma(
  96. qcms_CIE_xyY white_point,
  97. qcms_CIE_xyYTRIPLE primaries,
  98. float gamma);
  99. qcms_profile* qcms_profile_from_memory(const void *mem, size_t size);
  100. qcms_profile* qcms_profile_from_file(FILE *file);
  101. qcms_profile* qcms_profile_from_path(const char *path);
  102. #ifdef _WIN32
  103. qcms_profile* qcms_profile_from_unicode_path(const wchar_t *path);
  104. #endif
  105. qcms_profile* qcms_profile_sRGB(void);
  106. void qcms_profile_release(qcms_profile *profile);
  107. qcms_bool qcms_profile_is_bogus(qcms_profile *profile);
  108. qcms_bool qcms_profile_has_white_point(qcms_profile *profile);
  109. qcms_xyz_float qcms_profile_get_white_point(qcms_profile *profile);
  110. qcms_intent qcms_profile_get_rendering_intent(qcms_profile *profile);
  111. qcms_color_space qcms_profile_get_color_space(qcms_profile *profile);
  112. unsigned qcms_profile_get_version(qcms_profile *profile);
  113. qcms_bool qcms_profile_white_transform(qcms_profile *profile, float XYZ[3]);
  114. qcms_bool qcms_profile_match(qcms_profile *p1, qcms_profile *p2);
  115. const char* qcms_profile_get_description(qcms_profile *profile);
  116. void qcms_profile_precache_output_transform(qcms_profile *profile);
  117. size_t qcms_profile_get_vcgt_channel_length(qcms_profile *profile);
  118. qcms_bool qcms_profile_get_vcgt_rgb_channels(qcms_profile *profile, unsigned short *data);
  119. float qcms_profile_ntsc_relative_gamut_size(qcms_profile *profile);
  120. size_t qcms_profile_get_parametric_curve(qcms_profile *profile, qcms_trc_channel channel, float data[7]);
  121. qcms_transform* qcms_transform_create(
  122. qcms_profile *in, qcms_data_type in_type,
  123. qcms_profile *out, qcms_data_type out_type,
  124. qcms_intent intent);
  125. size_t qcms_transform_get_input_trc_rgba(
  126. qcms_transform *transform, qcms_profile *in, qcms_trc_type type, unsigned short *data);
  127. size_t qcms_transform_get_output_trc_rgba(
  128. qcms_transform *transform, qcms_profile *out, qcms_trc_type type, unsigned short *data);
  129. qcms_bool qcms_transform_is_matrix(qcms_transform *transform);
  130. float qcms_transform_get_matrix(qcms_transform *transform, unsigned i, unsigned j);
  131. qcms_bool qcms_transform_create_LUT_zyx_bgra(
  132. qcms_profile *in, qcms_profile *out, qcms_intent intent,
  133. int samples, unsigned char* lut);
  134. void qcms_transform_data(qcms_transform *transform, void *src, void *dest, size_t length);
  135. void qcms_transform_data_type(qcms_transform *transform, void *src, void *dest, size_t length, qcms_output_type type);
  136. void qcms_transform_release(qcms_transform *);
  137. void qcms_enable_iccv4();
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. /*
  142. * In general, QCMS is not threadsafe. However, it should be safe to create
  143. * profile and transformation objects on different threads, so long as you
  144. * don't use the same objects on different threads at the same time.
  145. */
  146. #endif