Commit 3f420614 authored by Michael Natterer's avatar Michael Natterer 😴

app, libgimpbase: allow to select colors by CIE L, C, and H

Add the additional enum values to enum GimpSelectCriterion, and
the few needed lines to gimppickable-contiguous-region.c.

It's horribly slow, but works.
parent db4e120b
......@@ -285,6 +285,12 @@ choose_format (GeglBuffer *buffer,
format = babl_format ("HSVA float");
break;
case GIMP_SELECT_CRITERION_LCH_L:
case GIMP_SELECT_CRITERION_LCH_C:
case GIMP_SELECT_CRITERION_LCH_H:
format = babl_format ("CIE LCH(ab) alpha float");
break;
default:
g_return_val_if_reached (NULL);
break;
......@@ -362,6 +368,19 @@ pixel_difference (const gfloat *col1,
case GIMP_SELECT_CRITERION_V:
max = fabs (col1[2] - col2[2]);
break;
case GIMP_SELECT_CRITERION_LCH_L:
max = fabs (col1[0] - col2[0]) / 100.0;
break;
case GIMP_SELECT_CRITERION_LCH_C:
max = fabs (col1[1] - col2[1]) / 100.0;
break;
case GIMP_SELECT_CRITERION_LCH_H:
max = fabs (col1[2] - col2[2]) / 360.0;
max = MIN (max, 1.0 - max);
break;
}
}
......
......@@ -1581,6 +1581,9 @@ gimp_select_criterion_get_type (void)
{ GIMP_SELECT_CRITERION_S, "GIMP_SELECT_CRITERION_S", "s" },
{ GIMP_SELECT_CRITERION_V, "GIMP_SELECT_CRITERION_V", "v" },
{ GIMP_SELECT_CRITERION_A, "GIMP_SELECT_CRITERION_A", "a" },
{ GIMP_SELECT_CRITERION_LCH_L, "GIMP_SELECT_CRITERION_LCH_L", "lch-l" },
{ GIMP_SELECT_CRITERION_LCH_C, "GIMP_SELECT_CRITERION_LCH_C", "lch-c" },
{ GIMP_SELECT_CRITERION_LCH_H, "GIMP_SELECT_CRITERION_LCH_H", "lch-h" },
{ 0, NULL, NULL }
};
......@@ -1594,6 +1597,9 @@ gimp_select_criterion_get_type (void)
{ GIMP_SELECT_CRITERION_S, NC_("select-criterion", "Saturation"), NULL },
{ GIMP_SELECT_CRITERION_V, NC_("select-criterion", "Value"), NULL },
{ GIMP_SELECT_CRITERION_A, NC_("select-criterion", "Alpha"), NULL },
{ GIMP_SELECT_CRITERION_LCH_L, NC_("select-criterion", "LCH Lightness"), NULL },
{ GIMP_SELECT_CRITERION_LCH_C, NC_("select-criterion", "LCH Chroma"), NULL },
{ GIMP_SELECT_CRITERION_LCH_H, NC_("select-criterion", "LCH Hue"), NULL },
{ 0, NULL, NULL }
};
......
......@@ -736,14 +736,17 @@ GType gimp_select_criterion_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_SELECT_CRITERION_COMPOSITE, /*< desc="Composite" >*/
GIMP_SELECT_CRITERION_R, /*< desc="Red" >*/
GIMP_SELECT_CRITERION_G, /*< desc="Green" >*/
GIMP_SELECT_CRITERION_B, /*< desc="Blue" >*/
GIMP_SELECT_CRITERION_H, /*< desc="Hue" >*/
GIMP_SELECT_CRITERION_S, /*< desc="Saturation" >*/
GIMP_SELECT_CRITERION_V, /*< desc="Value" >*/
GIMP_SELECT_CRITERION_A /*< desc="Alpha" >*/
GIMP_SELECT_CRITERION_COMPOSITE, /*< desc="Composite" >*/
GIMP_SELECT_CRITERION_R, /*< desc="Red" >*/
GIMP_SELECT_CRITERION_G, /*< desc="Green" >*/
GIMP_SELECT_CRITERION_B, /*< desc="Blue" >*/
GIMP_SELECT_CRITERION_H, /*< desc="Hue" >*/
GIMP_SELECT_CRITERION_S, /*< desc="Saturation" >*/
GIMP_SELECT_CRITERION_V, /*< desc="Value" >*/
GIMP_SELECT_CRITERION_A, /*< desc="Alpha" >*/
GIMP_SELECT_CRITERION_LCH_L, /*< desc="LCH Lightness" >*/
GIMP_SELECT_CRITERION_LCH_C, /*< desc="LCH Chroma" >*/
GIMP_SELECT_CRITERION_LCH_H, /*< desc="LCH Hue" >*/
} GimpSelectCriterion;
......
......@@ -522,7 +522,10 @@ package Gimp::CodeGen::enums;
GIMP_SELECT_CRITERION_R GIMP_SELECT_CRITERION_G
GIMP_SELECT_CRITERION_B GIMP_SELECT_CRITERION_H
GIMP_SELECT_CRITERION_S GIMP_SELECT_CRITERION_V
GIMP_SELECT_CRITERION_A) ],
GIMP_SELECT_CRITERION_A
GIMP_SELECT_CRITERION_LCH_L
GIMP_SELECT_CRITERION_LCH_C
GIMP_SELECT_CRITERION_LCH_H) ],
mapping => { GIMP_SELECT_CRITERION_COMPOSITE => '0',
GIMP_SELECT_CRITERION_R => '1',
GIMP_SELECT_CRITERION_G => '2',
......@@ -530,7 +533,10 @@ package Gimp::CodeGen::enums;
GIMP_SELECT_CRITERION_H => '4',
GIMP_SELECT_CRITERION_S => '5',
GIMP_SELECT_CRITERION_V => '6',
GIMP_SELECT_CRITERION_A => '7' }
GIMP_SELECT_CRITERION_A => '7',
GIMP_SELECT_CRITERION_LCH_L => '8',
GIMP_SELECT_CRITERION_LCH_C => '9',
GIMP_SELECT_CRITERION_LCH_H => '10' }
},
GimpSizeType =>
{ 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