mirror of https://github.com/GNOME/gimp.git
Converting CMYK sample points to babl process
This commit is contained in:
parent
388a5a3b4c
commit
93399de7cd
|
@ -374,7 +374,8 @@ dialogs_cursor_view_new (GimpDialogFactory *factory,
|
|||
GimpUIManager *ui_manager,
|
||||
gint view_size)
|
||||
{
|
||||
return gimp_cursor_view_new (gimp_dialog_factory_get_menu_factory (factory));
|
||||
return gimp_cursor_view_new (context->gimp,
|
||||
gimp_dialog_factory_get_menu_factory (factory));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP,
|
||||
PROP_SAMPLE_MERGED
|
||||
};
|
||||
|
||||
|
@ -63,6 +64,8 @@ struct _GimpCursorViewPrivate
|
|||
{
|
||||
GimpEditor parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
|
||||
GtkWidget *coord_hbox;
|
||||
GtkWidget *selection_hbox;
|
||||
GtkWidget *color_hbox;
|
||||
|
@ -96,6 +99,7 @@ struct _GimpCursorViewPrivate
|
|||
static void gimp_cursor_view_docked_iface_init (GimpDockedInterface *iface);
|
||||
|
||||
static void gimp_cursor_view_dispose (GObject *object);
|
||||
static void gimp_cursor_view_constructed (GObject *object);
|
||||
static void gimp_cursor_view_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
|
@ -153,12 +157,20 @@ gimp_cursor_view_class_init (GimpCursorViewClass* klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->constructed = gimp_cursor_view_constructed;
|
||||
object_class->dispose = gimp_cursor_view_dispose;
|
||||
object_class->get_property = gimp_cursor_view_get_property;
|
||||
object_class->set_property = gimp_cursor_view_set_property;
|
||||
|
||||
widget_class->style_updated = gimp_cursor_view_style_updated;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SAMPLE_MERGED,
|
||||
g_param_spec_boolean ("sample-merged",
|
||||
NULL, NULL,
|
||||
|
@ -306,31 +318,6 @@ gimp_cursor_view_init (GimpCursorView *view)
|
|||
_("H"), 0.5, 0.5,
|
||||
view->priv->selection_height_label, 1);
|
||||
|
||||
|
||||
/* color information */
|
||||
|
||||
view->priv->color_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,
|
||||
content_spacing);
|
||||
gtk_box_set_homogeneous (GTK_BOX (view->priv->color_hbox), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (view), view->priv->color_hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (view->priv->color_hbox);
|
||||
|
||||
view->priv->color_frame_1 = gimp_color_frame_new ();
|
||||
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->priv->color_frame_1),
|
||||
GIMP_COLOR_PICK_MODE_PIXEL);
|
||||
gimp_color_frame_set_ellipsize (GIMP_COLOR_FRAME (view->priv->color_frame_1),
|
||||
PANGO_ELLIPSIZE_END);
|
||||
gtk_box_pack_start (GTK_BOX (view->priv->color_hbox), view->priv->color_frame_1,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (view->priv->color_frame_1);
|
||||
|
||||
view->priv->color_frame_2 = gimp_color_frame_new ();
|
||||
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->priv->color_frame_2),
|
||||
GIMP_COLOR_PICK_MODE_RGB_PERCENT);
|
||||
gtk_box_pack_start (GTK_BOX (view->priv->color_hbox), view->priv->color_frame_2,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (view->priv->color_frame_2);
|
||||
|
||||
/* sample merged toggle */
|
||||
|
||||
toggle = gimp_prop_check_button_new (G_OBJECT (view), "sample-merged",
|
||||
|
@ -351,6 +338,41 @@ gimp_cursor_view_docked_iface_init (GimpDockedInterface *iface)
|
|||
iface->set_context = gimp_cursor_view_set_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cursor_view_constructed (GObject *object)
|
||||
{
|
||||
GimpCursorView *view = GIMP_CURSOR_VIEW (object);
|
||||
gint content_spacing;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (view),
|
||||
"content-spacing", &content_spacing,
|
||||
NULL);
|
||||
|
||||
/* color information */
|
||||
view->priv->color_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,
|
||||
content_spacing);
|
||||
gtk_box_set_homogeneous (GTK_BOX (view->priv->color_hbox), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (view), view->priv->color_hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (view->priv->color_hbox);
|
||||
|
||||
view->priv->color_frame_1 = gimp_color_frame_new (view->priv->gimp);
|
||||
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->priv->color_frame_1),
|
||||
GIMP_COLOR_PICK_MODE_PIXEL);
|
||||
gimp_color_frame_set_ellipsize (GIMP_COLOR_FRAME (view->priv->color_frame_1),
|
||||
PANGO_ELLIPSIZE_END);
|
||||
gtk_box_pack_start (GTK_BOX (view->priv->color_hbox), view->priv->color_frame_1,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (view->priv->color_frame_1);
|
||||
|
||||
view->priv->color_frame_2 = gimp_color_frame_new (view->priv->gimp);
|
||||
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->priv->color_frame_2),
|
||||
GIMP_COLOR_PICK_MODE_RGB_PERCENT);
|
||||
gtk_box_pack_start (GTK_BOX (view->priv->color_hbox), view->priv->color_frame_2,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (view->priv->color_frame_2);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cursor_view_dispose (GObject *object)
|
||||
{
|
||||
|
@ -365,6 +387,9 @@ gimp_cursor_view_dispose (GObject *object)
|
|||
view->priv->cursor_idle_id = 0;
|
||||
}
|
||||
|
||||
view->priv->color_frame_1 = NULL;
|
||||
view->priv->color_frame_2 = NULL;
|
||||
|
||||
g_clear_object (&view->priv->cursor_image);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
|
@ -380,6 +405,10 @@ gimp_cursor_view_set_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
view->priv->gimp = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SAMPLE_MERGED:
|
||||
view->priv->sample_merged = g_value_get_boolean (value);
|
||||
break;
|
||||
|
@ -400,6 +429,10 @@ gimp_cursor_view_get_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, view->priv->gimp);
|
||||
break;
|
||||
|
||||
case PROP_SAMPLE_MERGED:
|
||||
g_value_set_boolean (value, view->priv->sample_merged);
|
||||
break;
|
||||
|
@ -810,11 +843,13 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
|
|||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_cursor_view_new (GimpMenuFactory *menu_factory)
|
||||
gimp_cursor_view_new (Gimp *gimp,
|
||||
GimpMenuFactory *menu_factory)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_CURSOR_VIEW,
|
||||
"gimp", gimp,
|
||||
"menu-factory", menu_factory,
|
||||
"menu-identifier", "<CursorInfo>",
|
||||
"ui-path", "/cursor-info-popup",
|
||||
|
|
|
@ -51,7 +51,8 @@ struct _GimpCursorViewClass
|
|||
|
||||
GType gimp_cursor_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_cursor_view_new (GimpMenuFactory *menu_factory);
|
||||
GtkWidget * gimp_cursor_view_new (Gimp *gimp,
|
||||
GimpMenuFactory *menu_factory);
|
||||
|
||||
void gimp_cursor_view_set_sample_merged (GimpCursorView *view,
|
||||
gboolean sample_merged);
|
||||
|
|
|
@ -330,6 +330,7 @@ static void
|
|||
gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
Gimp *gimp = gimp_display_get_gimp (display);
|
||||
GimpTool *tool = GIMP_TOOL (picker_tool);
|
||||
GimpToolOptions *options = GIMP_TOOL_GET_OPTIONS (tool);
|
||||
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
|
||||
|
@ -364,7 +365,7 @@ gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
|||
hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
picker_tool->color_frame1 = gimp_color_frame_new ();
|
||||
picker_tool->color_frame1 = gimp_color_frame_new (gimp);
|
||||
gimp_color_frame_set_color_config (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
||||
context->gimp->config->color_management);
|
||||
gimp_color_frame_set_has_coords (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
||||
|
@ -377,7 +378,7 @@ gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
|||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (picker_tool->color_frame1);
|
||||
|
||||
picker_tool->color_frame2 = gimp_color_frame_new ();
|
||||
picker_tool->color_frame2 = gimp_color_frame_new (gimp);
|
||||
gimp_color_frame_set_color_config (GIMP_COLOR_FRAME (picker_tool->color_frame2),
|
||||
context->gimp->config->color_management);
|
||||
g_object_bind_property (options, "frame2-mode",
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
|
||||
#include "gegl/gimp-babl.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-color-profile.h"
|
||||
|
||||
#include "gimpcolorframe.h"
|
||||
|
||||
|
@ -42,6 +45,7 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP,
|
||||
PROP_MODE,
|
||||
PROP_HAS_NUMBER,
|
||||
PROP_NUMBER,
|
||||
|
@ -53,28 +57,32 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_color_frame_dispose (GObject *object);
|
||||
static void gimp_color_frame_finalize (GObject *object);
|
||||
static void gimp_color_frame_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_frame_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_frame_dispose (GObject *object);
|
||||
static void gimp_color_frame_finalize (GObject *object);
|
||||
static void gimp_color_frame_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_frame_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_color_frame_style_updated (GtkWidget *widget);
|
||||
static gboolean gimp_color_frame_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gimp_color_frame_style_updated (GtkWidget *widget);
|
||||
static gboolean gimp_color_frame_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
|
||||
static void gimp_color_frame_combo_callback (GtkWidget *widget,
|
||||
GimpColorFrame *frame);
|
||||
static void gimp_color_frame_update (GimpColorFrame *frame);
|
||||
static void gimp_color_frame_combo_callback (GtkWidget *widget,
|
||||
GimpColorFrame *frame);
|
||||
static void gimp_color_frame_update (GimpColorFrame *frame);
|
||||
|
||||
static void gimp_color_frame_create_transform (GimpColorFrame *frame);
|
||||
static void gimp_color_frame_destroy_transform (GimpColorFrame *frame);
|
||||
static void gimp_color_frame_image_changed (GimpColorFrame *frame,
|
||||
GimpImage *image,
|
||||
GimpContext *context);
|
||||
|
||||
static void gimp_color_frame_update_simulation_profile
|
||||
(GimpImage *image,
|
||||
GimpColorFrame *frame);
|
||||
|
||||
G_DEFINE_TYPE (GimpColorFrame, gimp_color_frame, GIMP_TYPE_FRAME)
|
||||
|
||||
|
@ -95,6 +103,13 @@ gimp_color_frame_class_init (GimpColorFrameClass *klass)
|
|||
widget_class->style_updated = gimp_color_frame_style_updated;
|
||||
widget_class->draw = gimp_color_frame_draw;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_MODE,
|
||||
g_param_spec_enum ("mode",
|
||||
NULL, NULL,
|
||||
|
@ -206,6 +221,8 @@ gimp_color_frame_init (GimpColorFrame *frame)
|
|||
frame->value_labels[i] = gtk_label_new (" ");
|
||||
gtk_label_set_selectable (GTK_LABEL (frame->value_labels[i]), TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (frame->value_labels[i]), 1.0);
|
||||
gtk_label_set_ellipsize (GTK_LABEL (frame->value_labels[i]),
|
||||
PANGO_ELLIPSIZE_END);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), frame->value_labels[i],
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame->value_labels[i]);
|
||||
|
@ -245,6 +262,16 @@ gimp_color_frame_dispose (GObject *object)
|
|||
{
|
||||
GimpColorFrame *frame = GIMP_COLOR_FRAME (object);
|
||||
|
||||
if (frame->gimp)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (gimp_get_user_context (frame->gimp),
|
||||
gimp_color_frame_image_changed,
|
||||
frame);
|
||||
frame->gimp = NULL;
|
||||
}
|
||||
|
||||
gimp_color_frame_set_image (frame, NULL);
|
||||
|
||||
gimp_color_frame_set_color_config (frame, NULL);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
|
@ -270,6 +297,10 @@ gimp_color_frame_get_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, frame->gimp);
|
||||
break;
|
||||
|
||||
case PROP_MODE:
|
||||
g_value_set_enum (value, frame->pick_mode);
|
||||
break;
|
||||
|
@ -307,9 +338,25 @@ gimp_color_frame_set_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
GimpColorFrame *frame = GIMP_COLOR_FRAME (object);
|
||||
GimpContext *context;
|
||||
GimpImage *image;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
frame->gimp = g_value_get_object (value);
|
||||
if (frame->gimp)
|
||||
{
|
||||
context = gimp_get_user_context (frame->gimp);
|
||||
image = gimp_context_get_image (context);
|
||||
|
||||
g_signal_connect_swapped (context, "image-changed",
|
||||
G_CALLBACK (gimp_color_frame_image_changed),
|
||||
frame);
|
||||
gimp_color_frame_image_changed (frame, image, context);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_MODE:
|
||||
gimp_color_frame_set_mode (frame, g_value_get_enum (value));
|
||||
break;
|
||||
|
@ -423,15 +470,18 @@ gimp_color_frame_draw (GtkWidget *widget,
|
|||
|
||||
/**
|
||||
* gimp_color_frame_new:
|
||||
* @gimp: A #Gimp object.
|
||||
*
|
||||
* Creates a new #GimpColorFrame widget.
|
||||
*
|
||||
* Returns: The new #GimpColorFrame widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_frame_new (void)
|
||||
gimp_color_frame_new (Gimp *gimp)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_COLOR_FRAME, NULL);
|
||||
return g_object_new (GIMP_TYPE_COLOR_FRAME,
|
||||
"gimp", gimp,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -622,30 +672,53 @@ gimp_color_frame_set_color_config (GimpColorFrame *frame,
|
|||
{
|
||||
if (frame->config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (frame->config,
|
||||
gimp_color_frame_destroy_transform,
|
||||
frame);
|
||||
g_object_unref (frame->config);
|
||||
|
||||
gimp_color_frame_destroy_transform (frame);
|
||||
gimp_color_frame_update (frame);
|
||||
}
|
||||
|
||||
frame->config = config;
|
||||
|
||||
if (frame->config)
|
||||
{
|
||||
g_object_ref (frame->config);
|
||||
|
||||
g_signal_connect_swapped (frame->config, "notify",
|
||||
G_CALLBACK (gimp_color_frame_destroy_transform),
|
||||
frame);
|
||||
}
|
||||
|
||||
gimp_color_area_set_color_config (GIMP_COLOR_AREA (frame->color_area),
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_frame_set_image (GimpColorFrame *frame,
|
||||
GimpImage *image)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
|
||||
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
||||
|
||||
if (image != frame->image)
|
||||
{
|
||||
if (frame->image)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (frame->image,
|
||||
gimp_color_frame_update_simulation_profile,
|
||||
frame);
|
||||
g_object_unref (frame->image);
|
||||
}
|
||||
}
|
||||
|
||||
frame->image = image;
|
||||
|
||||
if (frame->image)
|
||||
{
|
||||
g_object_ref (frame->image);
|
||||
|
||||
g_signal_connect (frame->image, "simulation-profile-changed",
|
||||
G_CALLBACK (gimp_color_frame_update_simulation_profile),
|
||||
frame);
|
||||
|
||||
gimp_color_frame_update_simulation_profile (frame->image,
|
||||
frame);
|
||||
}
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -667,10 +740,14 @@ gimp_color_frame_combo_callback (GtkWidget *widget,
|
|||
static void
|
||||
gimp_color_frame_update (GimpColorFrame *frame)
|
||||
{
|
||||
const gchar *names[GIMP_COLOR_FRAME_ROWS] = { NULL, };
|
||||
gchar **values = NULL;
|
||||
gboolean has_alpha;
|
||||
gint i;
|
||||
const gchar *names[GIMP_COLOR_FRAME_ROWS] = { NULL, };
|
||||
gchar **values = NULL;
|
||||
const gchar *tooltip[GIMP_COLOR_FRAME_ROWS] = { NULL, };
|
||||
gboolean has_alpha;
|
||||
GimpColorProfile *color_profile = NULL;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
|
||||
|
||||
has_alpha = babl_format_has_alpha (frame->sample_format);
|
||||
|
||||
|
@ -1006,62 +1083,68 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
break;
|
||||
|
||||
case GIMP_COLOR_PICK_MODE_CMYK:
|
||||
/* TRANSLATORS: C for Cyan (CMYK) */
|
||||
names[0] = C_("CMYK", "C:");
|
||||
/* TRANSLATORS: M for Magenta (CMYK) */
|
||||
names[1] = C_("CMYK", "M:");
|
||||
/* TRANSLATORS: Y for Yellow (CMYK) */
|
||||
names[2] = C_("CMYK", "Y:");
|
||||
/* TRANSLATORS: K for Key/black (CMYK) */
|
||||
names[3] = C_("CMYK", "K:");
|
||||
{
|
||||
const Babl *space = NULL;
|
||||
|
||||
if (has_alpha)
|
||||
/* TRANSLATORS: A for Alpha (color transparency) */
|
||||
names[4] = C_("Alpha channel", "A:");
|
||||
/* Try to load CMYK profile in the following order:
|
||||
* 1) Soft-Proof Profile set in the View Menu
|
||||
* 2) Preferred CMYK Profile set in Preferences
|
||||
* 3) No CMYK Profile (Default Values)
|
||||
*/
|
||||
color_profile = frame->view_profile;
|
||||
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
GimpCMYK cmyk;
|
||||
if (! color_profile && frame->config)
|
||||
color_profile = gimp_color_config_get_cmyk_color_profile (frame->config,
|
||||
NULL);
|
||||
if (color_profile)
|
||||
space = gimp_color_profile_get_space (color_profile,
|
||||
gimp_color_config_get_simulation_intent (frame->config),
|
||||
NULL);
|
||||
|
||||
if (! frame->transform)
|
||||
gimp_color_frame_create_transform (frame);
|
||||
/* TRANSLATORS: C for Cyan (CMYK) */
|
||||
names[0] = C_("CMYK", "C:");
|
||||
/* TRANSLATORS: M for Magenta (CMYK) */
|
||||
names[1] = C_("CMYK", "M:");
|
||||
/* TRANSLATORS: Y for Yellow (CMYK) */
|
||||
names[2] = C_("CMYK", "Y:");
|
||||
/* TRANSLATORS: K for Key/black (CMYK) */
|
||||
names[3] = C_("CMYK", "K:");
|
||||
if (has_alpha)
|
||||
/* TRANSLATORS: A for Alpha (color transparency) */
|
||||
names[4] = C_("Alpha channel", "A:");
|
||||
if (color_profile)
|
||||
names[5] = C_("Color", "Profile:");
|
||||
else
|
||||
names[5] = C_("Color", "No Profile");
|
||||
|
||||
if (frame->transform)
|
||||
{
|
||||
gdouble rgb_values[3];
|
||||
gdouble cmyk_values[4];
|
||||
if (frame->sample_valid)
|
||||
{
|
||||
const Babl *fish = NULL;
|
||||
gfloat cmyk[4];
|
||||
const gchar *profile_label;
|
||||
|
||||
rgb_values[0] = frame->color.r;
|
||||
rgb_values[1] = frame->color.g;
|
||||
rgb_values[2] = frame->color.b;
|
||||
/* User may swap CMYK color profiles at runtime */
|
||||
fish = babl_fish (babl_format ("R'G'B'A double"),
|
||||
babl_format_with_space ("CMYK float", space));
|
||||
|
||||
gimp_color_transform_process_pixels (frame->transform,
|
||||
babl_format ("R'G'B' double"),
|
||||
rgb_values,
|
||||
babl_format ("CMYK double"),
|
||||
cmyk_values,
|
||||
1);
|
||||
babl_process (fish, &frame->color, cmyk, 1);
|
||||
|
||||
cmyk.c = cmyk_values[0] / 100.0;
|
||||
cmyk.m = cmyk_values[1] / 100.0;
|
||||
cmyk.y = cmyk_values[2] / 100.0;
|
||||
cmyk.k = cmyk_values[3] / 100.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_rgb_to_cmyk (&frame->color, 1.0, &cmyk);
|
||||
}
|
||||
values = g_new0 (gchar *, 6);
|
||||
|
||||
cmyk.a = frame->color.a;
|
||||
|
||||
values = g_new0 (gchar *, 6);
|
||||
|
||||
values[0] = g_strdup_printf ("%.01f %%", cmyk.c * 100.0);
|
||||
values[1] = g_strdup_printf ("%.01f %%", cmyk.m * 100.0);
|
||||
values[2] = g_strdup_printf ("%.01f %%", cmyk.y * 100.0);
|
||||
values[3] = g_strdup_printf ("%.01f %%", cmyk.k * 100.0);
|
||||
values[4] = g_strdup_printf ("%.01f %%", cmyk.a * 100.0);
|
||||
}
|
||||
values[0] = g_strdup_printf ("%.0f %%", cmyk[0] * 100.0);
|
||||
values[1] = g_strdup_printf ("%.0f %%", cmyk[1] * 100.0);
|
||||
values[2] = g_strdup_printf ("%.0f %%", cmyk[2] * 100.0);
|
||||
values[3] = g_strdup_printf ("%.0f %%", cmyk[3] * 100.0);
|
||||
if (has_alpha)
|
||||
values[4] = g_strdup_printf ("%.01f %%", frame->color.a * 100.0);
|
||||
if (color_profile)
|
||||
{
|
||||
profile_label = gimp_color_profile_get_label (color_profile);
|
||||
values[5] = g_strdup_printf (_("%s"), profile_label);
|
||||
tooltip[5] = g_strdup_printf (_("%s"), profile_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1082,44 +1165,37 @@ gimp_color_frame_update (GimpColorFrame *frame)
|
|||
gtk_label_set_text (GTK_LABEL (frame->name_labels[i]), " ");
|
||||
gtk_label_set_text (GTK_LABEL (frame->value_labels[i]), " ");
|
||||
}
|
||||
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (frame->value_labels[i]),
|
||||
tooltip[i]);
|
||||
}
|
||||
|
||||
g_strfreev (values);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_frame_create_transform (GimpColorFrame *frame)
|
||||
gimp_color_frame_image_changed (GimpColorFrame *frame,
|
||||
GimpImage *image,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (frame->config)
|
||||
{
|
||||
GimpColorProfile *cmyk_profile;
|
||||
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
|
||||
|
||||
cmyk_profile = gimp_color_config_get_cmyk_color_profile (frame->config,
|
||||
NULL);
|
||||
if (image == frame->image)
|
||||
return;
|
||||
|
||||
if (cmyk_profile)
|
||||
{
|
||||
static GimpColorProfile *rgb_profile = NULL;
|
||||
|
||||
if (G_UNLIKELY (! rgb_profile))
|
||||
rgb_profile = gimp_color_profile_new_rgb_srgb ();
|
||||
|
||||
frame->transform =
|
||||
gimp_color_transform_new (rgb_profile,
|
||||
babl_format ("R'G'B' double"),
|
||||
cmyk_profile,
|
||||
babl_format ("CMYK double"),
|
||||
GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
|
||||
GIMP_COLOR_TRANSFORM_FLAGS_NOOPTIMIZE |
|
||||
GIMP_COLOR_TRANSFORM_FLAGS_BLACK_POINT_COMPENSATION);
|
||||
}
|
||||
}
|
||||
gimp_color_frame_set_image (frame, image);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_frame_destroy_transform (GimpColorFrame *frame)
|
||||
gimp_color_frame_update_simulation_profile (GimpImage *image,
|
||||
GimpColorFrame *frame)
|
||||
{
|
||||
g_clear_object (&frame->transform);
|
||||
g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
|
||||
|
||||
gimp_color_frame_update (frame);
|
||||
}
|
||||
if (image && GIMP_IS_COLOR_FRAME (frame))
|
||||
{
|
||||
frame->view_profile = gimp_image_get_simulation_profile (image);
|
||||
|
||||
gimp_color_frame_update (frame);
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_COLOR_FRAME_H__
|
||||
|
||||
|
||||
#define GIMP_COLOR_FRAME_ROWS 5
|
||||
#define GIMP_COLOR_FRAME_ROWS 6
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_FRAME (gimp_color_frame_get_type ())
|
||||
|
@ -36,6 +36,8 @@ struct _GimpColorFrame
|
|||
{
|
||||
GimpFrame parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
|
||||
gboolean sample_valid;
|
||||
gboolean sample_average;
|
||||
const Babl *sample_format;
|
||||
|
@ -65,8 +67,10 @@ struct _GimpColorFrame
|
|||
|
||||
PangoLayout *number_layout;
|
||||
|
||||
GimpImage *image;
|
||||
|
||||
GimpColorConfig *config;
|
||||
GimpColorTransform *transform;
|
||||
GimpColorProfile *view_profile;
|
||||
};
|
||||
|
||||
struct _GimpColorFrameClass
|
||||
|
@ -77,7 +81,7 @@ struct _GimpColorFrameClass
|
|||
|
||||
GType gimp_color_frame_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_color_frame_new (void);
|
||||
GtkWidget * gimp_color_frame_new (Gimp *gimp);
|
||||
|
||||
void gimp_color_frame_set_mode (GimpColorFrame *frame,
|
||||
GimpColorPickMode mode);
|
||||
|
@ -107,5 +111,8 @@ void gimp_color_frame_set_invalid (GimpColorFrame *frame);
|
|||
void gimp_color_frame_set_color_config (GimpColorFrame *frame,
|
||||
GimpColorConfig *config);
|
||||
|
||||
void gimp_color_frame_set_image (GimpColorFrame *frame,
|
||||
GimpImage *image);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_FRAME_H__ */
|
||||
|
|
|
@ -462,6 +462,7 @@ gimp_sample_point_editor_points_changed (GimpSamplePointEditor *editor)
|
|||
|
||||
editor->color_frames[i] =
|
||||
g_object_new (GIMP_TYPE_COLOR_FRAME,
|
||||
"gimp", GIMP (image_editor->image->gimp),
|
||||
"mode", GIMP_COLOR_PICK_MODE_PIXEL,
|
||||
"has-number", TRUE,
|
||||
"number", i + 1,
|
||||
|
|
Loading…
Reference in New Issue