From ecbce72e8485606eef603b84b125483cc992110c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 7 Jan 2016 17:31:42 +0100 Subject: libclut_gamma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libclut.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') 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 +#include @@ -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 -- cgit v1.2.3-70-g09d2