[gimp] app: fix legacy divide blend mode
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix legacy divide blend mode
- Date: Tue, 24 Jan 2017 17:36:53 +0000 (UTC)
commit 6a1d49bc6d7c63e86cd74895e3f1128f8b94ed07
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jan 24 18:36:08 2017 +0100
app: fix legacy divide blend mode
The porting from 8bit per component scaled some 8bit fractions up to huge
floating point numbers, this works for most values but causes trouble for near
transparent pixel values. This commit copies the inner blend loop from the new
divide layer mode, but keeps the old compositing logic.
.../layer-modes-legacy/gimpoperationdividelegacy.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/app/operations/layer-modes-legacy/gimpoperationdividelegacy.c
b/app/operations/layer-modes-legacy/gimpoperationdividelegacy.c
index b20a89a..48564a7 100644
--- a/app/operations/layer-modes-legacy/gimpoperationdividelegacy.c
+++ b/app/operations/layer-modes-legacy/gimpoperationdividelegacy.c
@@ -88,7 +88,15 @@ gimp_operation_divide_legacy_process (GeglOperation *op,
for (b = RED; b < ALPHA; b++)
{
- gfloat comp = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]);
+ gfloat comp = in[b] / layer[b];
+
+ /* make infinities(or NaN) correspond to a high number,
+ * to get more predictable math, ideally higher than 5.0
+ * but it seems like some babl conversions might be
+ * acting up then
+ */
+ if (!(comp > -42949672.0f && comp < 5.0f))
+ comp = 1.0f;
out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]