aboutsummaryrefslogtreecommitdiffstats
path: root/src/ramps.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-13 02:32:08 +0200
committerMattias Andrée <maandree@kth.se>2016-07-13 02:32:08 +0200
commit8a866b051a7a6826c456d2cb91a7fd557cb2fd35 (patch)
tree35e0b2fcca2a1054f39755aee6da210a765f6536 /src/ramps.c
parentWork on responses (diff)
downloadcoopgammad-8a866b051a7a6826c456d2cb91a7fd557cb2fd35.tar.gz
coopgammad-8a866b051a7a6826c456d2cb91a7fd557cb2fd35.tar.bz2
coopgammad-8a866b051a7a6826c456d2cb91a7fd557cb2fd35.tar.xz
Applying filters
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/ramps.c')
-rw-r--r--src/ramps.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ramps.c b/src/ramps.c
index b7ad978..d8d4975 100644
--- a/src/ramps.c
+++ b/src/ramps.c
@@ -94,3 +94,47 @@ size_t gamma_ramps_unmarshal(union gamma_ramps* this, const void* buf, size_t ra
return ramps_size;
}
+
+/**
+ * Apply a ramp-trio on top of another ramp-trio
+ *
+ * @param dest The output for the resulting ramp-trio, must be initialised
+ * @param application The red, green and blue ramps, as one single raw array,
+ * of the filter that should be applied
+ * @param depth -1: `float` stops
+ * -2: `double` stops
+ * Other: the number of bits of each (integral) stop
+ * @param base The CLUT on top of which the new filter should be applied,
+ * this can be the same pointer as `dest`
+ */
+void apply(union gamma_ramps* dest, void* application, int depth, union gamma_ramps* base)
+{
+ union gamma_ramps app;
+ size_t bytedepth;
+ size_t red_width, green_width, blue_width;
+
+ if (depth == -1)
+ bytedepth = sizeof(float);
+ else if (depth == -2)
+ bytedepth = sizeof(double);
+ else
+ bytedepth = (size_t)depth / 8;
+
+ red_width = (app.u8.red_size = base->u8.red_size) * bytedepth;
+ green_width = (app.u8.green_size = base->u8.green_size) * bytedepth;
+ blue_width = (app.u8.blue_size = base->u8.blue_size) * bytedepth;
+
+ app.u8.red = application;
+ app.u8.green = app.u8.red + red_width;
+ app.u8.blue = app.u8.green + green_width;
+
+ if (dest != base)
+ {
+ memcpy(dest->u8.red, base->u8.red, red_width);
+ memcpy(dest->u8.green, base->u8.green, green_width);
+ memcpy(dest->u8.blue, base->u8.blue, blue_width);
+ }
+
+ /* TODO apply with libclut */
+}
+