[gimp] app: implement the different composite modes for behind mode
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement the different composite modes for behind mode
- Date: Fri, 17 Feb 2017 23:22:10 +0000 (UTC)
commit b6d7be4a0fc12942305d8936b66e46d6e2802180
Author: Ell <ell_se yahoo com>
Date: Fri Feb 17 12:20:58 2017 -0500
app: implement the different composite modes for behind mode
app/operations/layer-modes/gimpoperationbehind.c | 156 +++++++++++++++++++---
1 files changed, 134 insertions(+), 22 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationbehind.c
b/app/operations/layer-modes/gimpoperationbehind.c
index 92c9590..8ecb61a 100644
--- a/app/operations/layer-modes/gimpoperationbehind.c
+++ b/app/operations/layer-modes/gimpoperationbehind.c
@@ -72,44 +72,156 @@ gimp_operation_behind_process (GeglOperation *op,
gfloat opacity = layer_mode->opacity;
const gboolean has_mask = mask != NULL;
- while (samples--)
+ switch (layer_mode->composite_mode)
{
- gfloat src1_alpha = in[ALPHA];
- gfloat src2_alpha = layer[ALPHA] * opacity;
- gfloat new_alpha;
- gint b;
+ case GIMP_LAYER_COMPOSITE_SRC_OVER:
+ case GIMP_LAYER_COMPOSITE_AUTO:
+ while (samples--)
+ {
+ gfloat src1_alpha = in[ALPHA];
+ gfloat src2_alpha = layer[ALPHA] * opacity;
+ gfloat new_alpha;
+ gint b;
+
+ if (has_mask)
+ src2_alpha *= *mask;
+
+ new_alpha = src2_alpha + (1.0 - src2_alpha) * src1_alpha;
+
+ if (new_alpha)
+ {
+ gfloat ratio = in[ALPHA] / new_alpha;
+ gfloat compl_ratio = 1.0f - ratio;
+
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = in[b] * ratio + layer[b] * compl_ratio;
+ }
+ }
+ else
+ {
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = layer[b];
+ }
+ }
- if (has_mask)
- src2_alpha *= *mask;
+ out[ALPHA] = new_alpha;
- new_alpha = src2_alpha + (1.0 - src2_alpha) * src1_alpha;
+ in += 4;
+ layer += 4;
+ out += 4;
- if (new_alpha)
+ if (has_mask)
+ mask++;
+ }
+ break;
+
+ case GIMP_LAYER_COMPOSITE_SRC_ATOP:
+ while (samples--)
{
- gfloat ratio = in[ALPHA] / new_alpha;
- gfloat compl_ratio = 1.0f - ratio;
+ gfloat src1_alpha = in[ALPHA];
+ gfloat new_alpha;
+ gint b;
+
+ new_alpha = src1_alpha;
- for (b = RED; b < ALPHA; b++)
+ if (new_alpha)
+ {
+ for (b = RED; b < ALPHA; b++)
+ out[b] = in[b];
+ }
+ else
{
- out[b] = in[b] * ratio + layer[b] * compl_ratio;
+ for (b = RED; b < ALPHA; b++)
+ out[b] = layer[b];
}
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ layer += 4;
+ out += 4;
}
- else
+ break;
+
+ case GIMP_LAYER_COMPOSITE_DST_ATOP:
+ while (samples--)
{
- for (b = RED; b < ALPHA; b++)
+ gfloat src1_alpha = in[ALPHA];
+ gfloat src2_alpha = layer[ALPHA] * opacity;
+ gfloat new_alpha;
+ gint b;
+
+ if (has_mask)
+ src2_alpha *= *mask;
+
+ new_alpha = src2_alpha;
+
+ if (new_alpha)
{
- out[b] = layer[b];
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = layer[b] + (in[b] - layer[b]) * src1_alpha;
+ }
}
+ else
+ {
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = layer[b];
+ }
+ }
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ layer += 4;
+ out += 4;
+
+ if (has_mask)
+ mask++;
}
+ break;
+
+ case GIMP_LAYER_COMPOSITE_SRC_IN:
+ while (samples--)
+ {
+ gfloat src1_alpha = in[ALPHA];
+ gfloat src2_alpha = layer[ALPHA] * opacity;
+ gfloat new_alpha;
+ gint b;
- out[ALPHA] = new_alpha;
+ if (has_mask)
+ src2_alpha *= *mask;
- in += 4;
- layer += 4;
- out += 4;
+ new_alpha = src1_alpha * src2_alpha;
- if (has_mask)
- mask++;
+ if (new_alpha)
+ {
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = in[b];
+ }
+ }
+ else
+ {
+ for (b = RED; b < ALPHA; b++)
+ {
+ out[b] = layer[b];
+ }
+ }
+
+ out[ALPHA] = new_alpha;
+
+ in += 4;
+ layer += 4;
+ out += 4;
+
+ if (has_mask)
+ mask++;
+ }
+ break;
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]