aboutsummaryrefslogtreecommitdiffstats
path: root/src/libclut.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-13 20:41:53 +0200
committerMattias Andrée <maandree@kth.se>2016-07-13 20:41:53 +0200
commit0397b7620352c69b33116eb9263956deb3d5923d (patch)
treef80c5b9c392e1e0a8930f4624e0d02c29aeff1dc /src/libclut.h
parentTest and fix libclut_linearise and libclut_standardise (diff)
downloadlibclut-0397b7620352c69b33116eb9263956deb3d5923d.tar.gz
libclut-0397b7620352c69b33116eb9263956deb3d5923d.tar.bz2
libclut-0397b7620352c69b33116eb9263956deb3d5923d.tar.xz
Fix bugs and test libclut_clip and libclut_apply
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/libclut.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libclut.h b/src/libclut.h
index e469260..01f00b4 100644
--- a/src/libclut.h
+++ b/src/libclut.h
@@ -693,17 +693,17 @@
* @param ftype Same as `type`, but for the filter to apply. (Not actually used).
* @param channel The channel, must be either "red", "green", or "blue".
*/
-#define libclut_apply__(clut, max, type, filter, fmax, ftype, channel) \
- do \
- { \
- size_t i__, rn__ = (clut)->channel##_size, fn__ = (filter)->channel##_size; \
- size_t x__, rm__ = (double)(max), m__ = (double)(max) / (double)(fmax); \
- for (i__ = 0; i__ < rn__; i__++) \
- { \
- x__ = (size_t)((double)((clut)->channel[i__]) / rm__ * fn__); \
- (clut)->channel[i__] = (type)((double)((filter)->channel[x__]) * m__); \
- } \
- } \
+#define libclut_apply__(clut, max, type, filter, fmax, ftype, channel) \
+ do \
+ { \
+ size_t i__, rn__ = (clut)->channel##_size - 1, fn__ = (filter)->channel##_size - 1; \
+ double x__, rm__ = (double)(max), m__ = (double)(max) / (double)(fmax); \
+ for (i__ = 0; i__ < rn__; i__++) \
+ { \
+ x__ = (double)((clut)->channel[i__]) / rm__ * fn__; \
+ (clut)->channel[i__] = (type)((double)((filter)->channel[(size_t)x__]) * m__); \
+ } \
+ } \
while (0)
@@ -730,8 +730,8 @@
#define libclut_cie_apply(clut, max, type, filter, fmax, ftype, r, g, b) \
do \
{ \
- size_t rfn__ = (filter)->red_size, gfn__ = (filter)->green_size; \
- size_t bfn__ = (filter)->blue_size, x__; \
+ size_t rfn__ = (filter)->red_size - 1, gfn__ = (filter)->green_size - 1; \
+ size_t bfn__ = (filter)->blue_size - 1, x__; \
size_t rm__ = (double)(max), fm__ = (double)(fmax); \
libclut_cie__(clut, max, type, 0, r, g, b, \
(x__ = (size_t)(Y__ / rm__ * rfn__), (double)((filter)->red[x__]) / fm__), \