Commit aaed8a6e authored by Elle Stone's avatar Elle Stone Committed by Øyvind "pippin" Kolås

app: Bug 753163 - Add blend mode "RGB Luminance"

This adds a blend mode similar to CIE Luminance - but that does not alter
saturation.
parent eeebd980
......@@ -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
};
......
......@@ -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
};
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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 },
......
......@@ -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)" >*/
......
......@@ -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));
......
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment