From d34800c5fccc1be218e9fc20cc91fc4aa76fee81 Mon Sep 17 00:00:00 2001 From: Ell Date: Sat, 6 Jan 2018 12:51:08 -0500 Subject: [PATCH] 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 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/operations/layer-modes/gimpoperationlayermode-blend.c b/app/operations/layer-modes/gimpoperationlayermode-blend.c index 8e3985203f..e1e89ce11c 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; }