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).
This commit is contained in:
Elle Stone 2018-10-22 17:34:11 -04:00 committed by Michael Natterer
parent a39b4abfbc
commit 298cc57042
4 changed files with 68 additions and 10 deletions

View File

@ -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 }
};

View File

@ -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;

View File

@ -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;

View File

@ -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,