[gimp] app: reintroduce clamping to vivid-light mode



commit d34800c5fccc1be218e9fc20cc91fc4aa76fee81
Author: Ell <ell_se yahoo com>
Date:   Sat Jan 6 12:51:08 2018 -0500

    app: reintroduce clamping to vivid-light mode
    
    ... removed by commit 0f9da165e078e146cbe960a6aa5f909677d27eb5, and
    improved by this commit.
    
    Our foo-light modes aren't really prepared to handle out-of-range
    input.  Make sure that in-range input doesn't result in out-of-
    range output.

 .../layer-modes/gimpoperationlayermode-blend.c     |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationlayermode-blend.c 
b/app/operations/layer-modes/gimpoperationlayermode-blend.c
index 8e39852..e1e89ce 100644
--- a/app/operations/layer-modes/gimpoperationlayermode-blend.c
+++ b/app/operations/layer-modes/gimpoperationlayermode-blend.c
@@ -1083,9 +1083,15 @@ gimp_operation_layer_mode_blend_vivid_light (const gfloat *in,
               gfloat val;
 
               if (layer[c] <= 0.5f)
-                val = 1.0f - safe_div (1.0f - in[c], 2.0f * layer[c]);
+                {
+                  val = 1.0f - safe_div (1.0f - in[c], 2.0f * layer[c]);
+                  val = MAX (val, 0.0f);
+                }
               else
-                val = safe_div (in[c], 2.0f * (1.0f - layer[c]));
+                {
+                  val = safe_div (in[c], 2.0f * (1.0f - layer[c]));
+                  val = MIN (val, 1.0f);
+                }
 
               comp[c] = val;
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]