[gimp/goat-invasion: 504/608] app: added gegl version of lighten only blending mode
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 504/608] app: added gegl version of lighten only blending mode
- Date: Fri, 27 Apr 2012 21:07:44 +0000 (UTC)
commit 44c83310aede1d214f8c13918acbb16e8b22e66e
Author: Ville Sokk <ville sokk gmail com>
Date: Tue Apr 17 23:00:28 2012 +0300
app: added gegl version of lighten only blending mode
app/gegl/gimp-gegl-nodes.c | 3 +--
app/gegl/gimpoperationlightenonlymode.c | 29 ++++++++++++++++++++++++-----
2 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index 1b05df5..2038488 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -257,7 +257,6 @@ gimp_gegl_node_set_layer_mode (GeglNode *node,
case GIMP_ADDITION_MODE:
case GIMP_SUBTRACT_MODE:
case GIMP_DARKEN_ONLY_MODE:
- case GIMP_LIGHTEN_ONLY_MODE:
case GIMP_HUE_MODE:
case GIMP_SATURATION_MODE:
case GIMP_COLOR_MODE:
@@ -296,7 +295,7 @@ gimp_gegl_node_set_layer_mode (GeglNode *node,
case GIMP_ADDITION_MODE: operation = "gimp:addition-mode"; break;
case GIMP_SUBTRACT_MODE: operation = "gimp:subtract-mode"; break;
case GIMP_DARKEN_ONLY_MODE: operation = "gimp:darken-mode"; break;
- case GIMP_LIGHTEN_ONLY_MODE: operation = "gimp:lighten-mode"; break;
+ case GIMP_LIGHTEN_ONLY_MODE: operation = "gimp:lighten-only-mode"; break;
case GIMP_HUE_MODE: operation = "gimp:hue-mode"; break;
case GIMP_SATURATION_MODE: operation = "gimp:saturation-mode"; break;
case GIMP_COLOR_MODE: operation = "gimp:color-mode"; break;
diff --git a/app/gegl/gimpoperationlightenonlymode.c b/app/gegl/gimpoperationlightenonlymode.c
index 5915799..96c5013 100644
--- a/app/gegl/gimpoperationlightenonlymode.c
+++ b/app/gegl/gimpoperationlightenonlymode.c
@@ -3,6 +3,7 @@
*
* gimpoperationlightenonlymode.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
@@ -40,6 +41,14 @@ static gboolean gimp_operation_lighten_only_mode_process (GeglOperation *o
G_DEFINE_TYPE (GimpOperationLightenOnlyMode, gimp_operation_lighten_only_mode,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
+static void prepare (GeglOperation *operation)
+{
+ const Babl *format = babl_format ("R'G'B'A float");
+
+ gegl_operation_set_format (operation, "input", format);
+ gegl_operation_set_format (operation, "aux", format);
+ gegl_operation_set_format (operation, "output", format);
+}
static void
gimp_operation_lighten_only_mode_class_init (GimpOperationLightenOnlyModeClass *klass)
@@ -55,7 +64,8 @@ gimp_operation_lighten_only_mode_class_init (GimpOperationLightenOnlyModeClass *
"description", "GIMP lighten only mode operation",
NULL);
- point_class->process = gimp_operation_lighten_only_mode_process;
+ point_class->process = gimp_operation_lighten_only_mode_process;
+ operation_class->prepare = prepare;
}
static void
@@ -69,7 +79,7 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
void *aux_buf,
void *out_buf,
glong samples,
- const GeglRectangle *roi,
+ const GeglRectangle *result,
gint level)
{
gfloat *in = in_buf;
@@ -78,11 +88,20 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
while (samples--)
{
- out[RED] = in[RED];
- out[GREEN] = in[GREEN];
- out[BLUE] = in[BLUE];
+ gint b;
+ gfloat comp_alpha = MIN (in[ALPHA] * layer[ALPHA], layer[ALPHA] * in[ALPHA]);
+ gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
+ gfloat ratio = comp_alpha / new_alpha;
+
out[ALPHA] = in[ALPHA];
+ for (b = RED; b < ALPHA; b++)
+ {
+ gfloat comp = MAX (layer[b], in[b]);
+
+ out[b] = comp * ratio + in[b] * (1 - ratio);
+ }
+
in += 4;
layer += 4;
out += 4;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]