diff --git a/app/core/core-enums.c b/app/core/core-enums.c index 6811c6ad37..6f33152340 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -155,6 +155,7 @@ gimp_color_pick_mode_get_type (void) { GIMP_COLOR_PICK_MODE_PIXEL, "GIMP_COLOR_PICK_MODE_PIXEL", "pixel" }, { GIMP_COLOR_PICK_MODE_RGB_PERCENT, "GIMP_COLOR_PICK_MODE_RGB_PERCENT", "rgb-percent" }, { GIMP_COLOR_PICK_MODE_RGB_U8, "GIMP_COLOR_PICK_MODE_RGB_U8", "rgb-u8" }, + { GIMP_COLOR_PICK_MODE_GRAYSCALE, "GIMP_COLOR_PICK_MODE_GRAYSCALE", "grayscale" }, { GIMP_COLOR_PICK_MODE_HSV, "GIMP_COLOR_PICK_MODE_HSV", "hsv" }, { GIMP_COLOR_PICK_MODE_LCH, "GIMP_COLOR_PICK_MODE_LCH", "lch" }, { GIMP_COLOR_PICK_MODE_LAB, "GIMP_COLOR_PICK_MODE_LAB", "lab" }, @@ -169,6 +170,7 @@ gimp_color_pick_mode_get_type (void) { GIMP_COLOR_PICK_MODE_PIXEL, NC_("color-pick-mode", "Pixel"), NULL }, { GIMP_COLOR_PICK_MODE_RGB_PERCENT, NC_("color-pick-mode", "RGB (%)"), NULL }, { GIMP_COLOR_PICK_MODE_RGB_U8, NC_("color-pick-mode", "RGB (0..255)"), NULL }, + { GIMP_COLOR_PICK_MODE_GRAYSCALE, NC_("color-pick-mode", "Grayscale (%)"), NULL }, { GIMP_COLOR_PICK_MODE_HSV, NC_("color-pick-mode", "HSV"), NULL }, { GIMP_COLOR_PICK_MODE_LCH, NC_("color-pick-mode", "CIE LCh"), NULL }, { GIMP_COLOR_PICK_MODE_LAB, NC_("color-pick-mode", "CIE LAB"), NULL }, diff --git a/app/core/core-enums.h b/app/core/core-enums.h index a50b087cae..3eefbff90d 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -112,6 +112,7 @@ typedef enum /*< pdb-skip >*/ GIMP_COLOR_PICK_MODE_PIXEL, /*< desc="Pixel" >*/ GIMP_COLOR_PICK_MODE_RGB_PERCENT, /*< desc="RGB (%)" >*/ GIMP_COLOR_PICK_MODE_RGB_U8, /*< desc="RGB (0..255)" >*/ + GIMP_COLOR_PICK_MODE_GRAYSCALE, /*< desc="Grayscale (%)">*/ GIMP_COLOR_PICK_MODE_HSV, /*< desc="HSV" >*/ GIMP_COLOR_PICK_MODE_LCH, /*< desc="CIE LCh" >*/ GIMP_COLOR_PICK_MODE_LAB, /*< desc="CIE LAB" >*/ diff --git a/app/widgets/gimpcolorframe.c b/app/widgets/gimpcolorframe.c index ccdc0e0ea7..1681a0a209 100644 --- a/app/widgets/gimpcolorframe.c +++ b/app/widgets/gimpcolorframe.c @@ -168,6 +168,7 @@ gimp_color_frame_init (GimpColorFrame *frame) GIMP_COLOR_PICK_MODE_PIXEL, GIMP_COLOR_PICK_MODE_RGB_PERCENT, GIMP_COLOR_PICK_MODE_RGB_U8, + GIMP_COLOR_PICK_MODE_GRAYSCALE, GIMP_COLOR_PICK_MODE_HSV, GIMP_COLOR_PICK_MODE_LCH, GIMP_COLOR_PICK_MODE_LAB, @@ -927,6 +928,40 @@ gimp_color_frame_update (GimpColorFrame *frame) } break; + case GIMP_COLOR_PICK_MODE_GRAYSCALE: + /* TRANSLATORS: V for Value (grayscale) */ + names[0] = C_("Grayscale", "V:"); + + if (has_alpha) + /* TRANSLATORS: A for Alpha (color transparency) */ + names[1] = C_("Alpha channel", "A:"); + + if (frame->sample_valid) + { + static const Babl *fish = NULL; + gfloat grayscale[2]; + GimpRGB grayscale_color; + + if (G_UNLIKELY (! fish)) + fish = babl_fish (babl_format ("R'G'B'A double"), + babl_format ("Y'A float")); + + babl_process (fish, &frame->color, grayscale, 1); + + /* Change color area color to grayscale if image is not + * in Grayscale Mode */ + gimp_rgba_set (&grayscale_color, grayscale[0], grayscale[0], + grayscale[0], GIMP_OPACITY_OPAQUE); + gimp_color_area_set_color (GIMP_COLOR_AREA (frame->color_area), + &grayscale_color); + + values = g_new0 (gchar *, 5); + + values[0] = g_strdup_printf ("%.01f %%", grayscale[0] * 100.0); + values[1] = g_strdup_printf ("%.01f %%", grayscale[1] * 100.0); + } + break; + case GIMP_COLOR_PICK_MODE_HSV: /* TRANSLATORS: H for Hue (HSV color space) */ names[0] = C_("HSV color space", "H:");