[gimp] app: cleaned dissolve and lighten only modes
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: cleaned dissolve and lighten only modes
- Date: Wed, 2 May 2012 16:39:16 +0000 (UTC)
commit 0233c99c8bb7e93e1c9709e3f43e28acd0883b2c
Author: Ville Sokk <ville sokk gmail com>
Date: Wed Apr 18 21:35:38 2012 +0300
app: cleaned dissolve and lighten only modes
app/gegl/gimpoperationdissolvemode.c | 8 ++++----
app/gegl/gimpoperationlightenonlymode.c | 28 +++++++++++++++-------------
2 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/app/gegl/gimpoperationdissolvemode.c b/app/gegl/gimpoperationdissolvemode.c
index 20be8df..06ef48b 100644
--- a/app/gegl/gimpoperationdissolvemode.c
+++ b/app/gegl/gimpoperationdissolvemode.c
@@ -99,12 +99,12 @@ gimp_operation_dissolve_mode_process (GeglOperation *operation,
const GeglRectangle *result,
gint level)
{
- gint x, y, i;
+ gint x, y;
gfloat *in = in_buf;
gfloat *out = out_buf;
gfloat *aux = aux_buf;
-
- for (i = 0, y = result->y; y < result->y + result->height; y++)
+
+ for (y = result->y; y < result->y + result->height; y++)
{
GRand *gr = g_rand_new_with_seed (random_table[y % RANDOM_TABLE_SIZE]);
@@ -112,7 +112,7 @@ gimp_operation_dissolve_mode_process (GeglOperation *operation,
for (x = 0; x < result->x; x++)
g_rand_int (gr);
- for (x = result->x; x < result->x + result->width; x++, i++)
+ for (x = result->x; x < result->x + result->width; x++)
{
if (g_rand_int_range (gr, 0, 255) >= aux[3] * 255)
{
diff --git a/app/gegl/gimpoperationlightenonlymode.c b/app/gegl/gimpoperationlightenonlymode.c
index 96c5013..e4cb137 100644
--- a/app/gegl/gimpoperationlightenonlymode.c
+++ b/app/gegl/gimpoperationlightenonlymode.c
@@ -28,7 +28,7 @@
#include "gimpoperationlightenonlymode.h"
-
+static void gimp_operation_lighten_only_mode_prepare (GeglOperation *operation);
static gboolean gimp_operation_lighten_only_mode_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
@@ -41,14 +41,6 @@ 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)
@@ -65,7 +57,7 @@ gimp_operation_lighten_only_mode_class_init (GimpOperationLightenOnlyModeClass *
NULL);
point_class->process = gimp_operation_lighten_only_mode_process;
- operation_class->prepare = prepare;
+ operation_class->prepare = gimp_operation_lighten_only_mode_prepare;
}
static void
@@ -73,6 +65,16 @@ gimp_operation_lighten_only_mode_init (GimpOperationLightenOnlyMode *self)
{
}
+static void
+gimp_operation_lighten_only_mode_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 gboolean
gimp_operation_lighten_only_mode_process (GeglOperation *operation,
void *in_buf,
@@ -89,12 +91,10 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = MIN (in[ALPHA] * layer[ALPHA], layer[ALPHA] * in[ALPHA]);
+ gfloat comp_alpha = in[ALPHA] * layer[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]);
@@ -102,6 +102,8 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
out[b] = comp * ratio + in[b] * (1 - ratio);
}
+ out[ALPHA] = in[ALPHA];
+
in += 4;
layer += 4;
out += 4;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]