app: add darken only, lighten only that uses luminance
These variations on darken only and lighten only have the advantage over the componentvise versions that they always use the full triplet of either original or new layer - meaning no new colors/hues will be introduced. This is similar to how these modes operated/operates in picture publisher and photo-paint.
This commit is contained in:
@ -360,6 +360,8 @@ gimp_layer_mode_get_type (void)
|
||||
{ GIMP_LAYER_MODE_EXCLUSION_LINEAR, "GIMP_LAYER_MODE_EXCLUSION_LINEAR", "exclusion-linear" },
|
||||
{ GIMP_LAYER_MODE_LINEAR_BURN, "GIMP_LAYER_MODE_LINEAR_BURN", "linear-burn" },
|
||||
{ GIMP_LAYER_MODE_LINEAR_BURN_LINEAR, "GIMP_LAYER_MODE_LINEAR_BURN_LINEAR", "linear-burn-linear" },
|
||||
{ GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY, "GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY", "luminance-darken-only" },
|
||||
{ GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY, "GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY", "luminance-lighten-only" },
|
||||
{ GIMP_LAYER_MODE_ERASE, "GIMP_LAYER_MODE_ERASE", "erase" },
|
||||
{ GIMP_LAYER_MODE_REPLACE, "GIMP_LAYER_MODE_REPLACE", "replace" },
|
||||
{ GIMP_LAYER_MODE_ANTI_ERASE, "GIMP_LAYER_MODE_ANTI_ERASE", "anti-erase" },
|
||||
@ -439,6 +441,8 @@ gimp_layer_mode_get_type (void)
|
||||
{ GIMP_LAYER_MODE_EXCLUSION_LINEAR, NC_("layer-mode", "Exclusion (linear)"), NULL },
|
||||
{ GIMP_LAYER_MODE_LINEAR_BURN, NC_("layer-mode", "Linear burn"), NULL },
|
||||
{ GIMP_LAYER_MODE_LINEAR_BURN_LINEAR, NC_("layer-mode", "Linear burn (linear)"), NULL },
|
||||
{ GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY, NC_("layer-mode", "Luminance darken only"), NULL },
|
||||
{ GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY, NC_("layer-mode", "Luminance lighten only"), NULL },
|
||||
{ GIMP_LAYER_MODE_ERASE, NC_("layer-mode", "Erase"), NULL },
|
||||
{ GIMP_LAYER_MODE_REPLACE, NC_("layer-mode", "Replace"), NULL },
|
||||
{ GIMP_LAYER_MODE_ANTI_ERASE, NC_("layer-mode", "Anti erase"), NULL },
|
||||
|
@ -230,6 +230,8 @@ typedef enum
|
||||
GIMP_LAYER_MODE_EXCLUSION_LINEAR, /*< desc="Exclusion (linear)" >*/
|
||||
GIMP_LAYER_MODE_LINEAR_BURN, /*< desc="Linear burn" >*/
|
||||
GIMP_LAYER_MODE_LINEAR_BURN_LINEAR, /*< desc="Linear burn (linear)" >*/
|
||||
GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY, /*< desc="Luminance darken only" >*/
|
||||
GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY,/*< desc="Luminance lighten only" >*/
|
||||
|
||||
/* Internal modes, not available to the PDB */
|
||||
GIMP_LAYER_MODE_ERASE = 1000, /*< pdb-skip, desc="Erase" >*/
|
||||
|
@ -118,6 +118,8 @@ gimp_layer_mode_is_linear (GimpLayerMode mode)
|
||||
case GIMP_LAYER_MODE_SUBTRACT:
|
||||
case GIMP_LAYER_MODE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_HSV_HUE:
|
||||
case GIMP_LAYER_MODE_HSV_SATURATION:
|
||||
case GIMP_LAYER_MODE_HSV_COLOR:
|
||||
@ -246,6 +248,8 @@ gimp_layer_mode_get_blend_space (GimpLayerMode mode)
|
||||
case GIMP_LAYER_MODE_SUBTRACT_LINEAR:
|
||||
case GIMP_LAYER_MODE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_DIVIDE_LINEAR:
|
||||
case GIMP_LAYER_MODE_DODGE_LINEAR:
|
||||
case GIMP_LAYER_MODE_BURN_LINEAR:
|
||||
@ -325,6 +329,8 @@ gimp_layer_mode_get_composite_mode (GimpLayerMode mode)
|
||||
case GIMP_LAYER_MODE_SUBTRACT_LINEAR:
|
||||
case GIMP_LAYER_MODE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY:
|
||||
case GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY:
|
||||
case GIMP_LAYER_MODE_HSV_HUE:
|
||||
case GIMP_LAYER_MODE_HSV_SATURATION:
|
||||
case GIMP_LAYER_MODE_HSV_COLOR:
|
||||
@ -676,6 +682,20 @@ gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
|
||||
-1
|
||||
},
|
||||
|
||||
{
|
||||
GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY,
|
||||
-1
|
||||
},
|
||||
|
||||
{
|
||||
GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY,
|
||||
-1
|
||||
},
|
||||
|
||||
{
|
||||
GIMP_LAYER_MODE_ERASE,
|
||||
GIMP_LAYER_MODE_ERASE,
|
||||
|
@ -984,6 +984,70 @@ blendfun_darken_only (const float *dest,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_luminance_lighten_only (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (dest[ALPHA] != 0.0f && src[ALPHA] != 0.0f)
|
||||
{
|
||||
gint c;
|
||||
float dest_luminance =
|
||||
GIMP_RGB_LUMINANCE(dest[0], dest[1], dest[2]);
|
||||
float src_luminance =
|
||||
GIMP_RGB_LUMINANCE(src[0], src[1], src[2]);
|
||||
|
||||
if (dest_luminance >= src_luminance)
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = dest[c];
|
||||
else
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = src[c];
|
||||
}
|
||||
|
||||
out[ALPHA] = src[ALPHA];
|
||||
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_luminance_darken_only (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (dest[ALPHA] != 0.0f && src[ALPHA] != 0.0f)
|
||||
{
|
||||
gint c;
|
||||
float dest_luminance =
|
||||
GIMP_RGB_LUMINANCE(dest[0], dest[1], dest[2]);
|
||||
float src_luminance =
|
||||
GIMP_RGB_LUMINANCE(src[0], src[1], src[2]);
|
||||
|
||||
if (dest_luminance <= src_luminance)
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = dest[c];
|
||||
else
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = src[c];
|
||||
}
|
||||
|
||||
out[ALPHA] = src[ALPHA];
|
||||
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lighten_only (const float *dest,
|
||||
const float *src,
|
||||
@ -1717,6 +1781,8 @@ static inline GimpBlendFunc gimp_layer_mode_get_blend_fun (GimpLayerMode mode)
|
||||
case GIMP_LAYER_MODE_DIFFERENCE: return blendfun_difference;
|
||||
case GIMP_LAYER_MODE_DARKEN_ONLY: return blendfun_darken_only;
|
||||
case GIMP_LAYER_MODE_LIGHTEN_ONLY: return blendfun_lighten_only;
|
||||
case GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY: return blendfun_luminance_darken_only;
|
||||
case GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY: return blendfun_luminance_lighten_only;
|
||||
case GIMP_LAYER_MODE_VIVID_LIGHT_LINEAR:
|
||||
case GIMP_LAYER_MODE_VIVID_LIGHT: return blendfun_vivid_light;
|
||||
case GIMP_LAYER_MODE_PIN_LIGHT_LINEAR:
|
||||
|
@ -104,12 +104,13 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
|
||||
GtkWidget *combo;
|
||||
|
||||
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE,
|
||||
45,
|
||||
47,
|
||||
GIMP_LAYER_MODE_NORMAL,
|
||||
GIMP_LAYER_MODE_NORMAL_LINEAR,
|
||||
GIMP_LAYER_MODE_DISSOLVE,
|
||||
GIMP_LAYER_MODE_LIGHTEN_ONLY,
|
||||
GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_LIGHTEN_ONLY,
|
||||
GIMP_LAYER_MODE_SCREEN,
|
||||
GIMP_LAYER_MODE_SCREEN_LEGACY,
|
||||
GIMP_LAYER_MODE_DODGE,
|
||||
@ -118,6 +119,7 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode,
|
||||
GIMP_LAYER_MODE_ADDITION_LEGACY,
|
||||
GIMP_LAYER_MODE_DARKEN_ONLY,
|
||||
GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY,
|
||||
GIMP_LAYER_MODE_LUMINANCE_DARKEN_ONLY,
|
||||
GIMP_LAYER_MODE_MULTIPLY,
|
||||
GIMP_LAYER_MODE_MULTIPLY_LINEAR,
|
||||
GIMP_LAYER_MODE_MULTIPLY_LEGACY,
|
||||
|
Reference in New Issue
Block a user