[gimp/goat-invasion] app: added gegl erase mode



commit 091adbbe1ae016c4bfe4b4ccb485b2e8fb3bf87b
Author: Ville Sokk <ville sokk gmail com>
Date:   Sat Apr 28 19:34:10 2012 +0300

    app: added gegl erase mode

 app/gegl/gimp-gegl-nodes.c        |    1 -
 app/gegl/gimpoperationerasemode.c |   49 ++++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index d4e79fa..98dea9c 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -324,7 +324,6 @@ gimp_gegl_node_set_layer_mode (GeglNode             *node,
     case GIMP_COLOR_MODE:
     case GIMP_VALUE_MODE:
     case GIMP_COLOR_ERASE_MODE:
-    case GIMP_ERASE_MODE:
     case GIMP_ANTI_ERASE_MODE:
       gegl_node_set (node,
                      "operation",     "gimp:point-layer-mode",
diff --git a/app/gegl/gimpoperationerasemode.c b/app/gegl/gimpoperationerasemode.c
index 7324d7b..48a9e1a 100644
--- a/app/gegl/gimpoperationerasemode.c
+++ b/app/gegl/gimpoperationerasemode.c
@@ -3,6 +3,7 @@
  *
  * gimpoperationerasemode.c
  * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *               2012 Ville Sokk <ville sokk gmail com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -72,20 +73,44 @@ gimp_operation_erase_mode_process (GeglOperation       *operation,
                                    const GeglRectangle *roi,
                                    gint                 level)
 {
-  gfloat *in    = in_buf;
-  gfloat *layer = aux_buf;
-  gfloat *out   = out_buf;
+  GimpOperationPointLayerMode *point = GIMP_OPERATION_POINT_LAYER_MODE (operation);
+  gfloat                      *in    = in_buf;
+  gfloat                      *layer = aux_buf;
+  gfloat                      *out   = out_buf;
 
-  while (samples--)
+  if (point->premultiplied)
     {
-      out[RED]   = in[RED];
-      out[GREEN] = in[GREEN];
-      out[BLUE]  = in[BLUE];
-      out[ALPHA] = in[ALPHA];
-
-      in    += 4;
-      layer += 4;
-      out   += 4;
+      while (samples--)
+        {
+          gint b;
+
+          out[ALPHA] = in[ALPHA] - in[ALPHA] * layer[ALPHA];
+          for (b = RED; b < ALPHA; b++)
+            {
+              out[b] = in[b] / in[ALPHA] * out[ALPHA];
+            }
+
+          in    += 4;
+          layer += 4;
+          out   += 4;
+        }
+    }
+  else
+    {
+      while (samples--)
+        {
+          gint b;
+
+          for (b = RED; b < ALPHA; b++)
+            {
+              out[b] = in[b];
+            }
+          out[ALPHA] = in[ALPHA] - in[ALPHA] * layer[ALPHA];;
+
+          in    += 4;
+          layer += 4;
+          out   += 4;
+        }
     }
 
   return TRUE;



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