aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-07 17:31:42 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-07 17:31:42 +0100
commitecbce72e8485606eef603b84b125483cc992110c (patch)
tree41621c9e0c51a680cd34b121183ff28a9e0b46ee
parentlibclut_linearise + libclut_standardise (diff)
downloadlibclut-ecbce72e8485606eef603b84b125483cc992110c.tar.gz
libclut-ecbce72e8485606eef603b84b125483cc992110c.tar.bz2
libclut-ecbce72e8485606eef603b84b125483cc992110c.tar.xz
libclut_gamma
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--src/libclut.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libclut.h b/src/libclut.h
index 32b099a..2024a14 100644
--- a/src/libclut.h
+++ b/src/libclut.h
@@ -18,6 +18,7 @@
#define LIBCLUT_H
#include <stddef.h>
+#include <math.h>
@@ -310,6 +311,32 @@
while (0)
+/**
+ * Apply gamma correction on the colour curves.
+ *
+ * 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 The gamma parameter the red colour curve.
+ * @param g The gamma parameter the green colour curve.
+ * @param b The gamma parameter the blue colour curve.
+ */
+#define libclut_gamma(ramp, max, type, r, g, b) \
+ do \
+ { \
+ double m__ = (double)(max); \
+ if (r != 1.0) libclut__(ramp, red, type, m__ * pow(LIBCLUT_VALUE / m__, 1.0 / r)); \
+ if (g != 1.0) libclut__(ramp, green, type, m__ * pow(LIBCLUT_VALUE / m__, 1.0 / g)); \
+ if (b != 1.0) libclut__(ramp, blue, type, m__ * pow(LIBCLUT_VALUE / m__, 1.0 / b)); \
+ } \
+ while (0)
+
+
#endif