From 0b1f6f665e9b53854b4fd42e69411e511f06d542 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 13 Jul 2016 22:29:21 +0200 Subject: Implement use of libclut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/output.c | 9 ++++++++- src/ramps.c | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index f323ff0..a593c16 100644 --- a/src/output.c +++ b/src/output.c @@ -18,6 +18,8 @@ #include "output.h" #include "util.h" +#include + #include #include #include @@ -432,31 +434,36 @@ int make_plain_ramps(union gamma_ramps* ramps, struct output* output) case 8: if (libgamma_gamma_ramps8_initialise(&(ramps->u8))) return -1; + libclut_start_over(&(ramps->u8), UINT8_MAX, uint8_t, 1, 1, 1); break; case 16: if (libgamma_gamma_ramps16_initialise(&(ramps->u16))) return -1; + libclut_start_over(&(ramps->u16), UINT16_MAX, uint16_t, 1, 1, 1); break; case 32: if (libgamma_gamma_ramps32_initialise(&(ramps->u32))) return -1; + libclut_start_over(&(ramps->u32), UINT32_MAX, uint32_t, 1, 1, 1); break; case 64: if (libgamma_gamma_ramps64_initialise(&(ramps->u64))) return -1; + libclut_start_over(&(ramps->u64), UINT64_MAX, uint64_t, 1, 1, 1); break; case -1: if (libgamma_gamma_rampsf_initialise(&(ramps->f))) return -1; + libclut_start_over(&(ramps->f), 1.0f, float, 1, 1, 1); break; case -2: if (libgamma_gamma_rampsd_initialise(&(ramps->d))) return -1; + libclut_start_over(&(ramps->d), (double)1, double, 1, 1, 1); break; default: abort(); } - /* TODO fill ramps (use libclut) */ return 0; } diff --git a/src/ramps.c b/src/ramps.c index d8d4975..0ae6224 100644 --- a/src/ramps.c +++ b/src/ramps.c @@ -17,6 +17,8 @@ */ #include "ramps.h" +#include + #include #include #include @@ -135,6 +137,28 @@ void apply(union gamma_ramps* dest, void* application, int depth, union gamma_ra memcpy(dest->u8.blue, base->u8.blue, blue_width); } - /* TODO apply with libclut */ + switch (depth) + { + case 8: + libclut_apply(&(dest->u8), UINT8_MAX, uint8_t, &(app.u8), UINT8_MAX, uint8_t, 1, 1, 1); + break; + case 16: + libclut_apply(&(dest->u16), UINT16_MAX, uint16_t, &(app.u16), UINT16_MAX, uint16_t, 1, 1, 1); + break; + case 32: + libclut_apply(&(dest->u32), UINT32_MAX, uint32_t, &(app.u32), UINT32_MAX, uint32_t, 1, 1, 1); + break; + case 64: + libclut_apply(&(dest->u64), UINT64_MAX, uint64_t, &(app.u64), UINT64_MAX, uint64_t, 1, 1, 1); + break; + case -1: + libclut_apply(&(dest->f), 1.0f, float, &(app.d), 1.0f, float, 1, 1, 1); + break; + case -2: + libclut_apply(&(dest->d), (double)1, double, &(app.f), (double)1, double, 1, 1, 1); + break; + default: + abort(); + } } -- cgit v1.2.3-70-g09d2