aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-07 17:27:50 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-07 17:27:50 +0100
commitc58de6faa5c3d99807a4d23a2fdc2de7510f5e8f (patch)
tree11a7168926e02593923b213f55884273cbe28b58 /src
parentm (diff)
downloadlibclut-c58de6faa5c3d99807a4d23a2fdc2de7510f5e8f.tar.gz
libclut-c58de6faa5c3d99807a4d23a2fdc2de7510f5e8f.tar.bz2
libclut-c58de6faa5c3d99807a4d23a2fdc2de7510f5e8f.tar.xz
libclut_linearise + libclut_standardise
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--src/libclut.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libclut.h b/src/libclut.h
index 891c7c4..32b099a 100644
--- a/src/libclut.h
+++ b/src/libclut.h
@@ -252,6 +252,64 @@
while (0)
+/**
+ * Convert the curves from formatted in standard RGB to linear RGB.
+ *
+ * None of the parameter may have side-effects.
+ *
+ * @param ramp Pointer to the gamma ramps, must have the arrays
+ * `red`, `green`, and `blue`, and the scalars
+ * `red_size`, `green_size`, and `blue_size`. Ramp
+ * structures from libgamma can be used.
+ * @param max The maximum value on each stop in the ramps.
+ * @param type The data type used for each stop in the ramps.
+ * @param r Whether to convert the red colour curve.
+ * @param g Whether to convert the green colour curve.
+ * @param b Whether to convert the blue colour curve.
+ */
+#define libclut_linearise(ramp, max, type, r, g, b) \
+ do \
+ { \
+ double m__ = (double)(max); \
+ if (r) \
+ libclut__(ramp, red, type, m__ * libclut_model_standard_to_linear1(LIBCLUT_VALUE / m__)); \
+ if (g) \
+ libclut__(ramp, green, type, m__ * libclut_model_standard_to_linear1(LIBCLUT_VALUE / m__)); \
+ if (b) \
+ libclut__(ramp, blue, type, m__ * libclut_model_standard_to_linear1(LIBCLUT_VALUE / m__)); \
+ } \
+ while (0)
+
+
+/**
+ * Convert the curves from formatted in linear RGB to standard RGB.
+ *
+ * None of the parameter may have side-effects.
+ *
+ * @param ramp Pointer to the gamma ramps, must have the arrays
+ * `red`, `green`, and `blue`, and the scalars
+ * `red_size`, `green_size`, and `blue_size`. Ramp
+ * structures from libgamma can be used.
+ * @param max The maximum value on each stop in the ramps.
+ * @param type The data type used for each stop in the ramps.
+ * @param r Whether to convert the red colour curve.
+ * @param g Whether to convert the green colour curve.
+ * @param b Whether to convert the blue colour curve.
+ */
+#define libclut_standardise(ramp, max, type, r, g, b) \
+ do \
+ { \
+ double m__ = (double)(max); \
+ if (r) \
+ libclut__(ramp, red, type, m__ * libclut_model_linear_to_standard1(LIBCLUT_VALUE / m__)); \
+ if (g) \
+ libclut__(ramp, green, type, m__ * libclut_model_linear_to_standard1(LIBCLUT_VALUE / m__)); \
+ if (b) \
+ libclut__(ramp, blue, type, m__ * libclut_model_linear_to_standard1(LIBCLUT_VALUE / m__)); \
+ } \
+ while (0)
+
+
#endif