[gimp] app: implement the different composite modes for replace mode
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement the different composite modes for replace mode
- Date: Fri, 17 Feb 2017 23:22:15 +0000 (UTC)
commit 15f5d5780e7aaee204d102ab25269f17c75f6bae
Author: Ell <ell_se yahoo com>
Date: Fri Feb 17 12:28:14 2017 -0500
app: implement the different composite modes for replace mode
app/operations/layer-modes/gimpoperationreplace.c | 118 +++++++++++++++++----
1 files changed, 99 insertions(+), 19 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationreplace.c
b/app/operations/layer-modes/gimpoperationreplace.c
index 07a2c0a..7da9fef 100644
--- a/app/operations/layer-modes/gimpoperationreplace.c
+++ b/app/operations/layer-modes/gimpoperationreplace.c
@@ -78,38 +78,118 @@ gimp_operation_replace_process (GeglOperation *op,
gfloat opacity = layer_mode->opacity;
const gboolean has_mask = mask != NULL;
- while (samples--)
+ switch (layer_mode->composite_mode)
{
- gfloat opacity_value = opacity;
- gfloat new_alpha;
- gint b;
+ case GIMP_LAYER_COMPOSITE_SRC_OVER:
+ case GIMP_LAYER_COMPOSITE_AUTO:
+ while (samples--)
+ {
+ gfloat opacity_value = opacity;
+ gfloat new_alpha;
+ gint b;
- if (has_mask)
- opacity_value *= *mask;
+ if (has_mask)
+ opacity_value *= *mask;
- new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity_value + in[ALPHA];
+ new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity_value + in[ALPHA];
- if (new_alpha)
- {
- gfloat ratio = opacity_value * layer[ALPHA] / new_alpha;
+ if (new_alpha)
+ {
+ gfloat ratio = opacity_value * layer[ALPHA] / new_alpha;
- for (b = RED; b < ALPHA; b++)
- out[b] = (layer[b] - in[b]) * ratio + in[b];
+ for (b = RED; b < ALPHA; b++)
+ out[b] = (layer[b] - in[b]) * ratio + in[b];
+ }
+ else
+ {
+ for (b = RED; b < ALPHA; b++)
+ out[b] = in[b];
+ }
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ layer += 4;
+ out += 4;
+
+ if (has_mask)
+ mask++;
}
- else
+ break;
+
+ case GIMP_LAYER_COMPOSITE_SRC_ATOP:
+ while (samples--)
{
+ gfloat opacity_value = opacity;
+ gfloat new_alpha;
+ gint b;
+
+ if (has_mask)
+ opacity_value *= *mask;
+
+ new_alpha = in[ALPHA] * (1.0f - opacity_value);
+
for (b = RED; b < ALPHA; b++)
out[b] = in[b];
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ out += 4;
+
+ if (has_mask)
+ mask++;
+ }
+ break;
+
+ case GIMP_LAYER_COMPOSITE_DST_ATOP:
+ while (samples--)
+ {
+ gfloat opacity_value = opacity;
+ gfloat new_alpha;
+ gint b;
+
+ if (has_mask)
+ opacity_value *= *mask;
+
+ new_alpha = layer[ALPHA] * opacity_value;
+
+ if (new_alpha)
+ {
+ for (b = RED; b < ALPHA; b++)
+ out[b] = layer[b];
+ }
+ else
+ {
+ for (b = RED; b < ALPHA; b++)
+ out[b] = in[b];
+ }
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ layer += 4;
+ out += 4;
+
+ if (has_mask)
+ mask++;
}
+ break;
- out[ALPHA] = new_alpha;
+ case GIMP_LAYER_COMPOSITE_SRC_IN:
+ while (samples--)
+ {
+ gint b;
- in += 4;
- layer += 4;
- out += 4;
+ for (b = RED; b < ALPHA; b++)
+ out[b] = in[b];
- if (has_mask)
- mask++;
+ out[ALPHA] = 0.0f;
+
+ in += 4;
+ out += 4;
+ }
+ break;
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]