summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af0bf59)
raw | patch | inline | side by side (parent: af0bf59)
author | tavmjong <tavmjong@users.sourceforge.net> | |
Sat, 6 Oct 2007 19:58:48 +0000 (19:58 +0000) | ||
committer | tavmjong <tavmjong@users.sourceforge.net> | |
Sat, 6 Oct 2007 19:58:48 +0000 (19:58 +0000) |
src/display/nr-filter-composite.cpp | patch | blob | history | |
src/display/nr-filter-utils.cpp | patch | blob | history | |
src/display/nr-filter-utils.h | patch | blob | history |
index a5b1d52976ee59a44ab54621c5c570d85440f075..29207b6b906707ec6170542c489192205360018d 100644 (file)
inline void
composite_arithmetic(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = NR::clamp(NR_NORMALIZE_31(arith_k1 * a[0] * b[0]
+ r[0] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[0] * b[0]
+ arith_k2 * a[0] + arith_k3 * b[0] + arith_k4));
- r[1] = NR::clamp(NR_NORMALIZE_31(arith_k1 * a[1] * b[1]
+ r[1] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[1] * b[1]
+ arith_k2 * a[1] + arith_k3 * b[1] + arith_k4));
- r[2] = NR::clamp(NR_NORMALIZE_31(arith_k1 * a[2] * b[2]
+ r[2] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[2] * b[2]
+ arith_k2 * a[2] + arith_k3 * b[2] + arith_k4));
- r[3] = NR::clamp(NR_NORMALIZE_31(arith_k1 * a[3] * b[3]
+ r[3] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[3] * b[3]
+ arith_k2 * a[3] + arith_k3 * b[3] + arith_k4));
}
index 52c8ecc7d27dfef18cb898eb1cce24c465349b10..ddd41298c364f636dd493640afbecfa364e9aceb 100644 (file)
return val;
}
+int clamp3(int const val) {
+ if (val < 0) return 0;
+ if (val > 16581375) return 16581375;
+ return val;
+}
+
int clamp_alpha(int const val, int const alpha) {
if (val < 0) return 0;
if (val > alpha) return alpha;
index 5ac6fa5ab405711a58e2c2c84b10d3281b5c9d4c..91c295e94e7a052897e9f49a8315d86ef415569b 100644 (file)
#include "round.h"
+/* Shouldn't these be inlined? */
namespace NR {
/**
*/
int clamp(int const val);
+/**
+ * Clamps an integer value to a value between 0 and 255^3.
+ *
+ * \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v
+ * \param v the value to clamp
+ */
+int clamp3(int const val);
+
/**
* Macro to use the clamp function with double inputs and unsigned char output
*/