diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2007-10-06 19:58:48 +0000 |
|---|---|---|
| committer | tavmjong <tavmjong@users.sourceforge.net> | 2007-10-06 19:58:48 +0000 |
| commit | 394afb18f3d0f58d489515b480ab12ecf9e11f59 (patch) | |
| tree | 98b3ef4a4f790e60069ee8b2c232358f2c3c8454 /src | |
| parent | reenable stop moving by keys, add select-all (diff) | |
| download | inkscape-394afb18f3d0f58d489515b480ab12ecf9e11f59.tar.gz inkscape-394afb18f3d0f58d489515b480ab12ecf9e11f59.zip | |
Composite Filter: Handle negative K's in Arithmetic mode.
(bzr r3839)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-filter-composite.cpp | 8 | ||||
| -rw-r--r-- | src/display/nr-filter-utils.cpp | 6 | ||||
| -rw-r--r-- | src/display/nr-filter-utils.h | 9 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index a5b1d5297..29207b6b9 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -73,13 +73,13 @@ static int arith_k1, arith_k2, arith_k3, arith_k4; 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)); } diff --git a/src/display/nr-filter-utils.cpp b/src/display/nr-filter-utils.cpp index 52c8ecc7d..ddd41298c 100644 --- a/src/display/nr-filter-utils.cpp +++ b/src/display/nr-filter-utils.cpp @@ -8,6 +8,12 @@ int clamp(int const val) { 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; diff --git a/src/display/nr-filter-utils.h b/src/display/nr-filter-utils.h index 5ac6fa5ab..91c295e94 100644 --- a/src/display/nr-filter-utils.h +++ b/src/display/nr-filter-utils.h @@ -14,6 +14,7 @@ #include "round.h" +/* Shouldn't these be inlined? */ namespace NR { /** @@ -26,6 +27,14 @@ 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 */ #define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v))) |
