[gimp] app: Bug 753163 - Add blend mode "RGB Luminance"
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Bug 753163 - Add blend mode "RGB Luminance"
- Date: Mon, 20 Feb 2017 12:54:59 +0000 (UTC)
commit aaed8a6eb95af8d98ebf0102acc7a3eca5857914
Author: Elle Stone <ellestone ninedegreesbelow com>
Date: Mon Feb 20 05:26:51 2017 -0500
app: Bug 753163 - Add blend mode "RGB Luminance"
This adds a blend mode similar to CIE Luminance - but that does not alter
saturation.
app/actions/context-commands.c | 3 +-
app/actions/layers-commands.c | 3 +-
app/core/gimpimage.c | 1 +
app/operations/layer-modes/gimp-layer-modes.c | 13 +++++
.../layer-modes/gimpoperationlayermode.c | 36 ++++++++++++
app/operations/operations-enums.c | 2 +
app/operations/operations-enums.h | 1 +
libgimp/gimpbrushselectbutton.c | 2 +-
libgimp/gimpenums.h | 1 +
tools/pdbgen/enums.pl | 58 ++++++++++----------
10 files changed, 89 insertions(+), 31 deletions(-)
---
diff --git a/app/actions/context-commands.c b/app/actions/context-commands.c
index c75eeea..277cba5 100644
--- a/app/actions/context-commands.c
+++ b/app/actions/context-commands.c
@@ -76,7 +76,8 @@ static const GimpLayerMode paint_modes[] =
GIMP_LAYER_MODE_LCH_HUE,
GIMP_LAYER_MODE_LCH_CHROMA,
GIMP_LAYER_MODE_LCH_COLOR,
- GIMP_LAYER_MODE_LCH_LIGHTNESS
+ GIMP_LAYER_MODE_LCH_LIGHTNESS,
+ GIMP_LAYER_MODE_LUMINANCE
};
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index c0bd422..4a13694 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -108,7 +108,8 @@ static const GimpLayerMode layer_modes[] =
GIMP_LAYER_MODE_LCH_HUE,
GIMP_LAYER_MODE_LCH_CHROMA,
GIMP_LAYER_MODE_LCH_COLOR,
- GIMP_LAYER_MODE_LCH_LIGHTNESS
+ GIMP_LAYER_MODE_LCH_LIGHTNESS,
+ GIMP_LAYER_MODE_LUMINANCE
};
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 5a81a91..0d20cb8 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2407,6 +2407,7 @@ gimp_image_get_xcf_version (GimpImage *image,
case GIMP_LAYER_MODE_LCH_CHROMA:
case GIMP_LAYER_MODE_LCH_COLOR:
case GIMP_LAYER_MODE_LCH_LIGHTNESS:
+ case GIMP_LAYER_MODE_LUMINANCE:
version = MAX (9, version);
break;
diff --git a/app/operations/layer-modes/gimp-layer-modes.c b/app/operations/layer-modes/gimp-layer-modes.c
index 7eea18d..7cdae33 100644
--- a/app/operations/layer-modes/gimp-layer-modes.c
+++ b/app/operations/layer-modes/gimp-layer-modes.c
@@ -471,6 +471,18 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.blend_space = GIMP_LAYER_COLOR_SPACE_LAB
},
+ { GIMP_LAYER_MODE_LUMINANCE,
+
+ .op_name = "gimp:layer-mode",
+ .function = gimp_operation_layer_mode_process_pixels,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .context = GIMP_LAYER_MODE_CONTEXT_ALL,
+ .paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
+ .composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
+ .composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR,
+ .blend_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
+ },
+
{ GIMP_LAYER_MODE_NORMAL_LINEAR,
.op_name = "gimp:normal",
@@ -874,6 +886,7 @@ static const GimpLayerMode layer_mode_group_default[] =
GIMP_LAYER_MODE_LCH_CHROMA,
GIMP_LAYER_MODE_LCH_COLOR,
GIMP_LAYER_MODE_LCH_LIGHTNESS,
+ GIMP_LAYER_MODE_LUMINANCE,
GIMP_LAYER_MODE_SEPARATOR,
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c
b/app/operations/layer-modes/gimpoperationlayermode.c
index 69574d9..fa1581c 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -1634,6 +1634,41 @@ blendfun_lch_lightness (const float *dest,
}
}
+static inline void
+blendfun_luminance (const float *dest,//*in,
+ const float *src,//*layer,
+ float *out,
+ int samples)
+{
+ while (samples--)
+ {
+ if (src[ALPHA] != 0.0f && dest[ALPHA] != 0.0f)
+ {
+ gfloat tmp1[2 * samples], *layer_Y = tmp1;
+ gfloat tmp2[2 * samples], *in_Y = tmp2;
+ gint i;
+ babl_process (babl_fish ("RGBA float", "RGBA float"), dest, out, samples);
+ babl_process (babl_fish ("RGBA float", "YA float"), src, layer_Y, samples);
+ babl_process (babl_fish ("RGBA float", "YA float"), dest, in_Y, samples);
+
+ for (i = 0; i < samples; ++i)
+ {
+ gfloat ratio = layer_Y[2 * i] / MAX(in_Y[2 * i], 0.0000000000000000001);
+ out[4 * i] *= ratio;
+ out[4 * i + 1] *= ratio;
+ out[4 * i + 2] *= ratio;
+ }
+
+ babl_process (babl_fish ("RGBA float", "RGBA float"), out, out, samples);
+ }
+
+ out[ALPHA] = dest[ALPHA];
+
+ out += 4;
+ dest += 4;
+ src += 4;
+ }
+}
static inline void
blendfun_copy (const float *dest,
@@ -1858,6 +1893,7 @@ gimp_layer_mode_get_blend_fun (GimpLayerMode mode)
case GIMP_LAYER_MODE_LCH_COLOR: return blendfun_lch_color;
case GIMP_LAYER_MODE_LCH_HUE: return blendfun_lch_hue;
case GIMP_LAYER_MODE_LCH_LIGHTNESS: return blendfun_lch_lightness;
+ case GIMP_LAYER_MODE_LUMINANCE: return blendfun_luminance;
case GIMP_LAYER_MODE_HARDLIGHT: return blendfun_hardlight;
case GIMP_LAYER_MODE_SOFTLIGHT: return blendfun_softlight;
case GIMP_LAYER_MODE_DIVIDE: return blendfun_divide;
diff --git a/app/operations/operations-enums.c b/app/operations/operations-enums.c
index 378f914..c7c5656 100644
--- a/app/operations/operations-enums.c
+++ b/app/operations/operations-enums.c
@@ -109,6 +109,7 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_LCH_CHROMA, "GIMP_LAYER_MODE_LCH_CHROMA", "lch-chroma" },
{ GIMP_LAYER_MODE_LCH_COLOR, "GIMP_LAYER_MODE_LCH_COLOR", "lch-color" },
{ GIMP_LAYER_MODE_LCH_LIGHTNESS, "GIMP_LAYER_MODE_LCH_LIGHTNESS", "lch-lightness" },
+ { GIMP_LAYER_MODE_LUMINANCE, "GIMP_LAYER_MODE_LUMINANCE", "luminance" },
{ GIMP_LAYER_MODE_NORMAL_LINEAR, "GIMP_LAYER_MODE_NORMAL_LINEAR", "normal-linear" },
{ GIMP_LAYER_MODE_BEHIND, "GIMP_LAYER_MODE_BEHIND", "behind" },
{ GIMP_LAYER_MODE_MULTIPLY, "GIMP_LAYER_MODE_MULTIPLY", "multiply" },
@@ -173,6 +174,7 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_LCH_CHROMA, NC_("layer-mode", "Chroma (LCH)"), NULL },
{ GIMP_LAYER_MODE_LCH_COLOR, NC_("layer-mode", "Color (LCH)"), NULL },
{ GIMP_LAYER_MODE_LCH_LIGHTNESS, NC_("layer-mode", "Lightness (LCH)"), NULL },
+ { GIMP_LAYER_MODE_LUMINANCE, NC_("layer-mode", "Luminance"), NULL },
{ GIMP_LAYER_MODE_NORMAL_LINEAR, NC_("layer-mode", "Normal (linear)"), NULL },
{ GIMP_LAYER_MODE_BEHIND, NC_("layer-mode", "Behind"), NULL },
{ GIMP_LAYER_MODE_MULTIPLY, NC_("layer-mode", "Multiply"), NULL },
diff --git a/app/operations/operations-enums.h b/app/operations/operations-enums.h
index 011e17e..269fa1c 100644
--- a/app/operations/operations-enums.h
+++ b/app/operations/operations-enums.h
@@ -85,6 +85,7 @@ typedef enum
GIMP_LAYER_MODE_LCH_CHROMA, /*< desc="Chroma (LCH)" >*/
GIMP_LAYER_MODE_LCH_COLOR, /*< desc="Color (LCH)" >*/
GIMP_LAYER_MODE_LCH_LIGHTNESS, /*< desc="Lightness (LCH)" >*/
+ GIMP_LAYER_MODE_LUMINANCE, /*< desc="Luminance" >*/
/* Since 2.10 */
GIMP_LAYER_MODE_NORMAL_LINEAR, /*< desc="Normal (linear)" >*/
diff --git a/libgimp/gimpbrushselectbutton.c b/libgimp/gimpbrushselectbutton.c
index bfb784d..b98e02c 100644
--- a/libgimp/gimpbrushselectbutton.c
+++ b/libgimp/gimpbrushselectbutton.c
@@ -233,7 +233,7 @@ gimp_brush_select_button_class_init (GimpBrushSelectButtonClass *klass)
g_param_spec_int ("brush-paint-mode",
"Brush paint mode",
"The paint mode of the currently selected brush",
- -1, GIMP_LAYER_MODE_LCH_LIGHTNESS,
+ -1, GIMP_LAYER_MODE_LUMINANCE,
-1,
GIMP_PARAM_READWRITE));
diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h
index 2992042..1519a4d 100644
--- a/libgimp/gimpenums.h
+++ b/libgimp/gimpenums.h
@@ -123,6 +123,7 @@ typedef enum
GIMP_LAYER_MODE_LCH_CHROMA,
GIMP_LAYER_MODE_LCH_COLOR,
GIMP_LAYER_MODE_LCH_LIGHTNESS,
+ GIMP_LAYER_MODE_LUMINANCE,
GIMP_LAYER_MODE_NORMAL_LINEAR,
GIMP_LAYER_MODE_BEHIND,
GIMP_LAYER_MODE_MULTIPLY,
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index c8ca66e..90d2269 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -722,6 +722,7 @@ package Gimp::CodeGen::enums;
GIMP_LAYER_MODE_LCH_CHROMA
GIMP_LAYER_MODE_LCH_COLOR
GIMP_LAYER_MODE_LCH_LIGHTNESS
+ GIMP_LAYER_MODE_LUMINANCE
GIMP_LAYER_MODE_NORMAL_LINEAR
GIMP_LAYER_MODE_BEHIND GIMP_LAYER_MODE_MULTIPLY
GIMP_LAYER_MODE_SCREEN GIMP_LAYER_MODE_DIFFERENCE
@@ -772,34 +773,35 @@ package Gimp::CodeGen::enums;
GIMP_LAYER_MODE_LCH_CHROMA => '25',
GIMP_LAYER_MODE_LCH_COLOR => '26',
GIMP_LAYER_MODE_LCH_LIGHTNESS => '27',
- GIMP_LAYER_MODE_NORMAL_LINEAR => '28',
- GIMP_LAYER_MODE_BEHIND => '29',
- GIMP_LAYER_MODE_MULTIPLY => '30',
- GIMP_LAYER_MODE_SCREEN => '31',
- GIMP_LAYER_MODE_DIFFERENCE => '32',
- GIMP_LAYER_MODE_ADDITION => '33',
- GIMP_LAYER_MODE_SUBTRACT => '34',
- GIMP_LAYER_MODE_DARKEN_ONLY => '35',
- GIMP_LAYER_MODE_LIGHTEN_ONLY => '36',
- GIMP_LAYER_MODE_HSV_HUE => '37',
- GIMP_LAYER_MODE_HSV_SATURATION => '38',
- GIMP_LAYER_MODE_HSV_COLOR => '39',
- GIMP_LAYER_MODE_HSV_VALUE => '40',
- GIMP_LAYER_MODE_DIVIDE => '41',
- GIMP_LAYER_MODE_DODGE => '42',
- GIMP_LAYER_MODE_BURN => '43',
- GIMP_LAYER_MODE_HARDLIGHT => '44',
- GIMP_LAYER_MODE_SOFTLIGHT => '45',
- GIMP_LAYER_MODE_GRAIN_EXTRACT => '46',
- GIMP_LAYER_MODE_GRAIN_MERGE => '47',
- GIMP_LAYER_MODE_VIVID_LIGHT => '48',
- GIMP_LAYER_MODE_PIN_LIGHT => '49',
- GIMP_LAYER_MODE_LINEAR_LIGHT => '50',
- GIMP_LAYER_MODE_HARD_MIX => '51',
- GIMP_LAYER_MODE_EXCLUSION => '52',
- GIMP_LAYER_MODE_LINEAR_BURN => '53',
- GIMP_LAYER_MODE_LUMA_DARKEN_ONLY => '54',
- GIMP_LAYER_MODE_LUMA_LIGHTEN_ONLY => '55' }
+ GIMP_LAYER_MODE_LUMINANCE => '28',
+ GIMP_LAYER_MODE_NORMAL_LINEAR => '29',
+ GIMP_LAYER_MODE_BEHIND => '30',
+ GIMP_LAYER_MODE_MULTIPLY => '31',
+ GIMP_LAYER_MODE_SCREEN => '32',
+ GIMP_LAYER_MODE_DIFFERENCE => '33',
+ GIMP_LAYER_MODE_ADDITION => '34',
+ GIMP_LAYER_MODE_SUBTRACT => '35',
+ GIMP_LAYER_MODE_DARKEN_ONLY => '36',
+ GIMP_LAYER_MODE_LIGHTEN_ONLY => '37',
+ GIMP_LAYER_MODE_HSV_HUE => '38',
+ GIMP_LAYER_MODE_HSV_SATURATION => '39',
+ GIMP_LAYER_MODE_HSV_COLOR => '40',
+ GIMP_LAYER_MODE_HSV_VALUE => '41',
+ GIMP_LAYER_MODE_DIVIDE => '42',
+ GIMP_LAYER_MODE_DODGE => '43',
+ GIMP_LAYER_MODE_BURN => '44',
+ GIMP_LAYER_MODE_HARDLIGHT => '45',
+ GIMP_LAYER_MODE_SOFTLIGHT => '46',
+ GIMP_LAYER_MODE_GRAIN_EXTRACT => '47',
+ GIMP_LAYER_MODE_GRAIN_MERGE => '48',
+ GIMP_LAYER_MODE_VIVID_LIGHT => '49',
+ GIMP_LAYER_MODE_PIN_LIGHT => '50',
+ GIMP_LAYER_MODE_LINEAR_LIGHT => '51',
+ GIMP_LAYER_MODE_HARD_MIX => '52',
+ GIMP_LAYER_MODE_EXCLUSION => '53',
+ GIMP_LAYER_MODE_LINEAR_BURN => '54',
+ GIMP_LAYER_MODE_LUMA_DARKEN_ONLY => '55',
+ GIMP_LAYER_MODE_LUMA_LIGHTEN_ONLY => '56' }
},
GimpConvertDitherType =>
{ contig => 1,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]