[gimp/goat-invasion] app: fixed a bug in gegl legacy blending modes
- From: Ville Sokk <villesokk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] app: fixed a bug in gegl legacy blending modes
- Date: Sat, 28 Apr 2012 09:29:18 +0000 (UTC)
commit f642dd9f714c050c214c711ed020d2bae667ffe7
Author: Ville Sokk <ville sokk gmail com>
Date: Sat Apr 28 11:37:27 2012 +0300
app: fixed a bug in gegl legacy blending modes
app/gegl/gimpoperationadditionmode.c | 4 ++--
app/gegl/gimpoperationburnmode.c | 4 ++--
app/gegl/gimpoperationdarkenonlymode.c | 4 ++--
app/gegl/gimpoperationdifferencemode.c | 4 ++--
app/gegl/gimpoperationdividemode.c | 7 +++----
app/gegl/gimpoperationdodgemode.c | 4 ++--
app/gegl/gimpoperationgrainextractmode.c | 4 ++--
app/gegl/gimpoperationgrainmergemode.c | 4 ++--
app/gegl/gimpoperationhardlightmode.c | 4 ++--
app/gegl/gimpoperationlightenonlymode.c | 4 ++--
app/gegl/gimpoperationmultiplymode.c | 4 ++--
app/gegl/gimpoperationoverlaymode.c | 4 ++--
app/gegl/gimpoperationscreenmode.c | 4 ++--
app/gegl/gimpoperationsoftlightmode.c | 4 ++--
app/gegl/gimpoperationsubtractmode.c | 4 ++--
15 files changed, 31 insertions(+), 32 deletions(-)
---
diff --git a/app/gegl/gimpoperationadditionmode.c b/app/gegl/gimpoperationadditionmode.c
index 71b819c..3b51580 100644
--- a/app/gegl/gimpoperationadditionmode.c
+++ b/app/gegl/gimpoperationadditionmode.c
@@ -92,7 +92,7 @@ gimp_operation_addition_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_addition_mode_process (GeglOperation *operation,
gfloat comp = in[b] + layer[b];
comp = CLAMP (comp, 0, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationburnmode.c b/app/gegl/gimpoperationburnmode.c
index 180e225..fca8f77 100644
--- a/app/gegl/gimpoperationburnmode.c
+++ b/app/gegl/gimpoperationburnmode.c
@@ -92,7 +92,7 @@ gimp_operation_burn_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_burn_mode_process (GeglOperation *operation,
gfloat comp = (1 - in[b]) / layer[b];
comp = CLAMP (1 - comp, 0, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationdarkenonlymode.c b/app/gegl/gimpoperationdarkenonlymode.c
index 77113a7..ba8ecf6 100644
--- a/app/gegl/gimpoperationdarkenonlymode.c
+++ b/app/gegl/gimpoperationdarkenonlymode.c
@@ -93,7 +93,7 @@ gimp_operation_darken_only_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_darken_only_mode_process (GeglOperation *operation,
{
gfloat comp = MIN (in[b], layer[b]);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationdifferencemode.c b/app/gegl/gimpoperationdifferencemode.c
index 5bd81e6..65bfce5 100644
--- a/app/gegl/gimpoperationdifferencemode.c
+++ b/app/gegl/gimpoperationdifferencemode.c
@@ -92,7 +92,7 @@ gimp_operation_difference_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_difference_mode_process (GeglOperation *operation,
gfloat comp = in[b] - layer[b];
comp = (comp < 0) ? -comp : comp;
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationdividemode.c b/app/gegl/gimpoperationdividemode.c
index e94b3cc..5da9fe1 100644
--- a/app/gegl/gimpoperationdividemode.c
+++ b/app/gegl/gimpoperationdividemode.c
@@ -76,7 +76,6 @@ gimp_operation_divide_mode_prepare (GeglOperation *operation)
gegl_operation_set_format (operation, "output", format);
}
-
static gboolean
gimp_operation_divide_mode_process (GeglOperation *operation,
void *in_buf,
@@ -93,16 +92,16 @@ gimp_operation_divide_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
- gfloat comp = in[b] / layer[b];
+ gfloat comp = (256 / 255.0 * in[b]) / (1 / 255.0 + layer[b]);
comp = MIN (comp, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationdodgemode.c b/app/gegl/gimpoperationdodgemode.c
index a33e495..308cc4a 100644
--- a/app/gegl/gimpoperationdodgemode.c
+++ b/app/gegl/gimpoperationdodgemode.c
@@ -92,7 +92,7 @@ gimp_operation_dodge_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_dodge_mode_process (GeglOperation *operation,
gfloat comp = in[b] / (1 - layer[b]);
comp = MIN (comp, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationgrainextractmode.c b/app/gegl/gimpoperationgrainextractmode.c
index 2a7886f..f240b44 100644
--- a/app/gegl/gimpoperationgrainextractmode.c
+++ b/app/gegl/gimpoperationgrainextractmode.c
@@ -93,7 +93,7 @@ gimp_operation_grain_extract_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -102,7 +102,7 @@ gimp_operation_grain_extract_mode_process (GeglOperation *operation,
gfloat comp = in[b] - layer[b] + 0.5;
comp = CLAMP (comp, 0, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationgrainmergemode.c b/app/gegl/gimpoperationgrainmergemode.c
index f1a32d8..aac5b7a 100644
--- a/app/gegl/gimpoperationgrainmergemode.c
+++ b/app/gegl/gimpoperationgrainmergemode.c
@@ -93,7 +93,7 @@ gimp_operation_grain_merge_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -102,7 +102,7 @@ gimp_operation_grain_merge_mode_process (GeglOperation *operation,
gfloat comp = in[b] + layer[b] - 0.5;
comp = CLAMP (comp, 0, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationhardlightmode.c b/app/gegl/gimpoperationhardlightmode.c
index 2845b41..3339ea7 100644
--- a/app/gegl/gimpoperationhardlightmode.c
+++ b/app/gegl/gimpoperationhardlightmode.c
@@ -92,7 +92,7 @@ gimp_operation_hardlight_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -111,7 +111,7 @@ gimp_operation_hardlight_mode_process (GeglOperation *operation,
comp = MIN (comp, 1);
}
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationlightenonlymode.c b/app/gegl/gimpoperationlightenonlymode.c
index 1de48cd..63e93f1 100644
--- a/app/gegl/gimpoperationlightenonlymode.c
+++ b/app/gegl/gimpoperationlightenonlymode.c
@@ -92,7 +92,7 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -100,7 +100,7 @@ gimp_operation_lighten_only_mode_process (GeglOperation *operation,
{
gfloat comp = MAX (layer[b], in[b]);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationmultiplymode.c b/app/gegl/gimpoperationmultiplymode.c
index 4aa3b0a..8eb7c6d 100644
--- a/app/gegl/gimpoperationmultiplymode.c
+++ b/app/gegl/gimpoperationmultiplymode.c
@@ -92,7 +92,7 @@ gimp_operation_multiply_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_multiply_mode_process (GeglOperation *operation,
gfloat comp = layer[b] * in[b];
comp = CLAMP (comp, 0, 1);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationoverlaymode.c b/app/gegl/gimpoperationoverlaymode.c
index 680e3c8..f5e0fde 100644
--- a/app/gegl/gimpoperationoverlaymode.c
+++ b/app/gegl/gimpoperationoverlaymode.c
@@ -93,7 +93,7 @@ gimp_operation_overlay_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_overlay_mode_process (GeglOperation *operation,
{
gfloat comp = in[b] * (in[b] + (2 * layer[b]) * (1 - in[b]));
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationscreenmode.c b/app/gegl/gimpoperationscreenmode.c
index c3205f7..7826289 100644
--- a/app/gegl/gimpoperationscreenmode.c
+++ b/app/gegl/gimpoperationscreenmode.c
@@ -92,7 +92,7 @@ gimp_operation_screen_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -100,7 +100,7 @@ gimp_operation_screen_mode_process (GeglOperation *operation,
{
gfloat comp = 1 - (1 - in[b]) * (1 - layer[b]);
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationsoftlightmode.c b/app/gegl/gimpoperationsoftlightmode.c
index 4571a41..1bbcbff 100644
--- a/app/gegl/gimpoperationsoftlightmode.c
+++ b/app/gegl/gimpoperationsoftlightmode.c
@@ -93,7 +93,7 @@ gimp_operation_softlight_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -103,7 +103,7 @@ gimp_operation_softlight_mode_process (GeglOperation *operation,
gfloat screen = 1 - (1 - in[b]) * (1 - layer[b]);
gfloat comp = (1 - in[b]) * multiply + in[b] * screen;
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
diff --git a/app/gegl/gimpoperationsubtractmode.c b/app/gegl/gimpoperationsubtractmode.c
index 77f2544..0a0fabd 100644
--- a/app/gegl/gimpoperationsubtractmode.c
+++ b/app/gegl/gimpoperationsubtractmode.c
@@ -92,7 +92,7 @@ gimp_operation_subtract_mode_process (GeglOperation *operation,
while (samples--)
{
gint b;
- gfloat comp_alpha = in[ALPHA] * layer[ALPHA];
+ gfloat comp_alpha = MIN (in[ALPHA], layer[ALPHA]);
gfloat new_alpha = in[ALPHA] + (1 - in[ALPHA]) * comp_alpha;
gfloat ratio = comp_alpha / new_alpha;
@@ -101,7 +101,7 @@ gimp_operation_subtract_mode_process (GeglOperation *operation,
gfloat comp = in[b] - layer[b];
comp = (comp < 0) ? 0 : comp;
- out[b] = comp * ratio + in[b] * (1 - ratio);
+ out[b] = comp * ratio + in[b] * (1 - ratio) + 0.0001;
}
out[ALPHA] = in[ALPHA];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]