[gimp] app: add a handful more blending innerloops
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add a handful more blending innerloops
- Date: Sun, 22 Jan 2017 12:42:16 +0000 (UTC)
commit c9ad09df6195e6ed59f3ece17b055eaed5891e22
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Jan 22 13:40:20 2017 +0100
app: add a handful more blending innerloops
Adding linear burn, vivid light, linear light, pinlight and exclusion formulas
as described on
http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html
app/operations/layer-modes/gimpblendcomposite.h | 163 ++++++++++++++++++++++-
1 files changed, 162 insertions(+), 1 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpblendcomposite.h b/app/operations/layer-modes/gimpblendcomposite.h
index c0b6769..0f55172 100644
--- a/app/operations/layer-modes/gimpblendcomposite.h
+++ b/app/operations/layer-modes/gimpblendcomposite.h
@@ -405,7 +405,7 @@ blendfun_screen (const float *dest,
}
}
-static inline void
+static inline void /* aka linear_dodge */
blendfun_addition (const float *dest,
const float *src,
float *out,
@@ -429,6 +429,31 @@ blendfun_addition (const float *dest,
}
}
+
+static inline void
+blendfun_linear_burn (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ out[c] = dest[c] + src[c] - 1.0f;
+ }
+
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
+
static inline void
blendfun_subtract (const float *dest,
const float *src,
@@ -1105,5 +1130,141 @@ blendfun_copy (const float *dest,
}
}
+/* added according to:
+ http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html */
+static inline void
+blendfun_vivid_light (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ {
+ gfloat comp;
+
+ if (src[c] > 0.5f)
+ {
+ comp = (1.0f - (1.0f - dest[c]) / (2.0f * (src[c] - 0.5f)));
+ }
+ else
+ {
+ comp = dest[c] / (1.0f - 2.0f * src[c]);
+ }
+
+ out[c] = comp;
+ }
+ }
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
+
+
+/* added according to:
+ http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html */
+static inline void
+blendfun_linear_light (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ {
+ gfloat comp;
+ if (src[c] > 0.5f)
+ {
+ comp = dest[c] + 2.0 * (src[c] - 0.5);
+ }
+ else
+ {
+ comp = dest[c] + 2 * (src[c] - 1.0);
+ }
+ out[c] = comp;
+ }
+ }
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
+
+
+/* added according to:
+ http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html */
+static inline void
+blendfun_pin_light (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ {
+ gfloat comp;
+ if (src[c] > 0.5f)
+ {
+ comp = MAX(dest[c], 2 * (src[c] - 0.5));
+ }
+ else
+ {
+ comp = MIN(dest[c], 2 * src[c]);
+ }
+ out[c] = comp;
+ }
+ }
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
+
+static inline void
+blendfun_exclusion (const float *dest,
+ const float *src,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f)
+ {
+ gint c;
+
+ for (c = 0; c < 3; c++)
+ {
+ out[c] = 0.5f - 2.0f * (dest[c] - 0.5f) * (src[c] - 0.5f);
+ }
+ }
+ out[ALPHA] = src[ALPHA];
+
+ out += 4;
+ src += 4;
+ dest += 4;
+ }
+}
#endif /* __GIMP_BLEND_COMPOSITE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]