[gimp] app: added initial gegl replace mode



commit 7eb0d8f4c8778e0bb05f2ea685a3547a796e2dfe
Author: Ville Sokk <ville sokk gmail com>
Date:   Tue Apr 24 12:25:19 2012 +0300

    app: added initial gegl replace mode

 app/gegl/gimp-gegl-nodes.c          |    1 -
 app/gegl/gimpoperationreplacemode.c |   24 ++++++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index dde78ce..a750634 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -256,7 +256,6 @@ gimp_gegl_node_set_layer_mode (GeglNode             *node,
     case GIMP_VALUE_MODE:
     case GIMP_COLOR_ERASE_MODE:
     case GIMP_ERASE_MODE:
-    case GIMP_REPLACE_MODE:
     case GIMP_ANTI_ERASE_MODE:
       gegl_node_set (node,
                      "operation",     "gimp:point-layer-mode",
diff --git a/app/gegl/gimpoperationreplacemode.c b/app/gegl/gimpoperationreplacemode.c
index e8cd21c..2143772 100644
--- a/app/gegl/gimpoperationreplacemode.c
+++ b/app/gegl/gimpoperationreplacemode.c
@@ -78,10 +78,26 @@ gimp_operation_replace_mode_process (GeglOperation       *operation,
 
   while (samples--)
     {
-      out[RED]   = in[RED];
-      out[GREEN] = in[GREEN];
-      out[BLUE]  = in[BLUE];
-      out[ALPHA] = in[ALPHA];
+      gint b;
+      gfloat ratio = 1 / layer[ALPHA] / layer[ALPHA];
+
+      for (b = RED; b < ALPHA; b++)
+        {
+          gfloat t;
+
+          if (layer[b] > in[b])
+            {
+              t = (layer[b] - in[b]) * ratio;
+              out[b] = in[b] + t;
+            }
+          else
+            {
+              t= (in[b] - layer[b]) * ratio;
+              out[b] = in[b] - t;
+            }
+        }
+
+      out[ALPHA] = layer[ALPHA];
 
       in    += 4;
       layer += 4;



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