[gimp] Issue #2345 - Add xyY to color sample readouts
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #2345 - Add xyY to color sample readouts
- Date: Tue, 23 Oct 2018 16:06:58 +0000 (UTC)
commit 298cc57042b97cde2a6a7ef4dc5b89eeb40fd2e5
Author: Elle Stone <ellestone ninedegreesbelow com>
Date: Mon Oct 22 17:34:11 2018 -0400
Issue #2345 - Add xyY to color sample readouts
Add xyY color space to the color spaces for sampling colors.
Also add code to xcf-load.c that makes sure the sample point loading
code handles unknown future GimpColorPickMode values (fall back to
PIXEL pick mode).
app/core/core-enums.c | 2 ++
app/core/core-enums.h | 9 ++++++-
app/widgets/gimpcolorframe.c | 64 +++++++++++++++++++++++++++++++++++++-------
app/xcf/xcf-load.c | 3 +++
4 files changed, 68 insertions(+), 10 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index ff935015a9..efa7cbcfe4 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -141,6 +141,7 @@ gimp_color_pick_mode_get_type (void)
{ GIMP_COLOR_PICK_MODE_LCH, "GIMP_COLOR_PICK_MODE_LCH", "lch" },
{ GIMP_COLOR_PICK_MODE_LAB, "GIMP_COLOR_PICK_MODE_LAB", "lab" },
{ GIMP_COLOR_PICK_MODE_CMYK, "GIMP_COLOR_PICK_MODE_CMYK", "cmyk" },
+ { GIMP_COLOR_PICK_MODE_XYY, "GIMP_COLOR_PICK_MODE_XYY", "xyy" },
{ 0, NULL, NULL }
};
@@ -153,6 +154,7 @@ gimp_color_pick_mode_get_type (void)
{ GIMP_COLOR_PICK_MODE_LCH, NC_("color-pick-mode", "CIE LCh"), NULL },
{ GIMP_COLOR_PICK_MODE_LAB, NC_("color-pick-mode", "CIE LAB"), NULL },
{ GIMP_COLOR_PICK_MODE_CMYK, NC_("color-pick-mode", "CMYK"), NULL },
+ { GIMP_COLOR_PICK_MODE_XYY, NC_("color-pick-mode", "CIE xyY"), NULL },
{ 0, NULL, NULL }
};
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index fa0d72fd2b..6c153a576e 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -86,6 +86,10 @@ typedef enum /*< pdb-skip >*/
} GimpChannelBorderStyle;
+/* Note: when appending values here, don't forget to update
+ * GimpColorFrame and other places use this enum to create combo
+ * boxes.
+ */
#define GIMP_TYPE_COLOR_PICK_MODE (gimp_color_pick_mode_get_type ())
GType gimp_color_pick_mode_get_type (void) G_GNUC_CONST;
@@ -98,7 +102,10 @@ typedef enum /*< pdb-skip >*/
GIMP_COLOR_PICK_MODE_HSV, /*< desc="HSV" >*/
GIMP_COLOR_PICK_MODE_LCH, /*< desc="CIE LCh" >*/
GIMP_COLOR_PICK_MODE_LAB, /*< desc="CIE LAB" >*/
- GIMP_COLOR_PICK_MODE_CMYK /*< desc="CMYK" >*/
+ GIMP_COLOR_PICK_MODE_CMYK, /*< desc="CMYK" >*/
+ GIMP_COLOR_PICK_MODE_XYY, /*< desc="CIE xyY" >*/
+
+ GIMP_COLOR_PICK_MODE_LAST = GIMP_COLOR_PICK_MODE_XYY /*< skip >*/
} GimpColorPickMode;
diff --git a/app/widgets/gimpcolorframe.c b/app/widgets/gimpcolorframe.c
index cb76bf186e..04c513e1d9 100644
--- a/app/widgets/gimpcolorframe.c
+++ b/app/widgets/gimpcolorframe.c
@@ -134,17 +134,31 @@ gimp_color_frame_class_init (GimpColorFrameClass *klass)
static void
gimp_color_frame_init (GimpColorFrame *frame)
{
- GtkWidget *vbox;
- GtkWidget *vbox2;
- GtkWidget *label;
- gint i;
+ GtkListStore *store;
+ GtkWidget *vbox;
+ GtkWidget *vbox2;
+ GtkWidget *label;
+ gint i;
frame->sample_valid = FALSE;
frame->sample_format = babl_format ("R'G'B' u8");
gimp_rgba_set (&frame->color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
- frame->combo = gimp_enum_combo_box_new (GIMP_TYPE_COLOR_PICK_MODE);
+ /* create the store manually so the values have a nice order */
+ store = gimp_enum_store_new_with_values (GIMP_TYPE_COLOR_PICK_MODE,
+ GIMP_COLOR_PICK_MODE_LAST + 1,
+ GIMP_COLOR_PICK_MODE_PIXEL,
+ GIMP_COLOR_PICK_MODE_RGB_PERCENT,
+ GIMP_COLOR_PICK_MODE_RGB_U8,
+ GIMP_COLOR_PICK_MODE_HSV,
+ GIMP_COLOR_PICK_MODE_LCH,
+ GIMP_COLOR_PICK_MODE_LAB,
+ GIMP_COLOR_PICK_MODE_XYY,
+ GIMP_COLOR_PICK_MODE_CMYK);
+ frame->combo = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store));
+ g_object_unref (store);
+
gtk_frame_set_label_widget (GTK_FRAME (frame), frame->combo);
gtk_widget_show (frame->combo);
@@ -913,10 +927,42 @@ gimp_color_frame_update (GimpColorFrame *frame)
values = g_new0 (gchar *, 5);
- values[0] = g_strdup_printf ("%.01f ", lab[0]);
- values[1] = g_strdup_printf ("%.01f ", lab[1]);
- values[2] = g_strdup_printf ("%.01f ", lab[2]);
- values[3] = g_strdup_printf ("%.01f %%", lab[3] * 100.0);
+ values[0] = g_strdup_printf ("%.01f ", lab[0]);
+ values[1] = g_strdup_printf ("%.01f ", lab[1]);
+ values[2] = g_strdup_printf ("%.01f ", lab[2]);
+ values[3] = g_strdup_printf ("%.01f %%", lab[3] * 100.0);
+ }
+ break;
+
+ case GIMP_COLOR_PICK_MODE_XYY:
+ /* TRANSLATORS: x from xyY color space */
+ names[0] = C_("xyY color space", "x:");
+ /* TRANSLATORS: y from xyY color space */
+ names[1] = C_("xyY color space", "y:");
+ /* TRANSLATORS: Y from xyY color space */
+ names[2] = C_("xyY color space", "Y:");
+
+ if (has_alpha)
+ /* TRANSLATORS: A for Alpha (color transparency) */
+ names[3] = C_("Alpha channel", "A:");
+
+ if (frame->sample_valid)
+ {
+ static const Babl *fish = NULL;
+ gfloat xyY[4];
+
+ if (G_UNLIKELY (! fish))
+ fish = babl_fish (babl_format ("R'G'B'A double"),
+ babl_format ("CIE xyY alpha float"));
+
+ babl_process (fish, &frame->color, xyY, 1);
+
+ values = g_new0 (gchar *, 5);
+
+ values[0] = g_strdup_printf ("%1.6f ", xyY[0]);
+ values[1] = g_strdup_printf ("%1.6f ", xyY[1]);
+ values[2] = g_strdup_printf ("%1.6f ", xyY[2]);
+ values[3] = g_strdup_printf ("%.01f %%", xyY[3] * 100.0);
}
break;
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index aca8f9fd17..eb79f030b9 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -829,6 +829,9 @@ xcf_load_image_props (XcfInfo *info,
GIMP_LOG (XCF, "prop sample point x=%d y=%d mode=%d",
x, y, pick_mode);
+ if (pick_mode > GIMP_COLOR_PICK_MODE_LAST)
+ pick_mode = GIMP_COLOR_PICK_MODE_PIXEL;
+
sample_point = gimp_image_add_sample_point_at_pos (image,
x, y, FALSE);
gimp_image_set_sample_point_pick_mode (image, sample_point,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]