mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
Modules: Convert CMYK color selector to babl
This commit is contained in:
parent
1291c20f24
commit
1c81c426ae
9 changed files with 261 additions and 116 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include "core/gimp-palettes.h"
|
#include "core/gimp-palettes.h"
|
||||||
#include "core/gimpcontext.h"
|
#include "core/gimpcontext.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
|
#include "core/gimpimage-color-profile.h"
|
||||||
#include "core/gimpimage-colormap.h"
|
#include "core/gimpimage-colormap.h"
|
||||||
#include "core/gimpmarshal.h"
|
#include "core/gimpmarshal.h"
|
||||||
#include "core/gimppalettemru.h"
|
#include "core/gimppalettemru.h"
|
||||||
|
@ -105,6 +106,8 @@ static void gimp_color_dialog_history_selected (GimpColorHistory *history,
|
||||||
static void gimp_color_dialog_image_changed (GimpContext *context,
|
static void gimp_color_dialog_image_changed (GimpContext *context,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GimpColorDialog *dialog);
|
GimpColorDialog *dialog);
|
||||||
|
static void gimp_color_dialog_update_simulation(GimpImage *image,
|
||||||
|
GimpColorDialog *dialog);
|
||||||
static void gimp_color_dialog_update (GimpColorDialog *dialog);
|
static void gimp_color_dialog_update (GimpColorDialog *dialog);
|
||||||
static void gimp_color_dialog_show (GimpColorDialog *dialog);
|
static void gimp_color_dialog_show (GimpColorDialog *dialog);
|
||||||
static void gimp_color_dialog_hide (GimpColorDialog *dialog);
|
static void gimp_color_dialog_hide (GimpColorDialog *dialog);
|
||||||
|
@ -712,6 +715,9 @@ gimp_color_dialog_image_changed (GimpContext *context,
|
||||||
g_signal_handlers_disconnect_by_func (dialog->active_image,
|
g_signal_handlers_disconnect_by_func (dialog->active_image,
|
||||||
G_CALLBACK (gimp_color_dialog_update),
|
G_CALLBACK (gimp_color_dialog_update),
|
||||||
dialog);
|
dialog);
|
||||||
|
g_signal_handlers_disconnect_by_func (dialog->active_image,
|
||||||
|
gimp_color_dialog_update_simulation,
|
||||||
|
dialog);
|
||||||
}
|
}
|
||||||
dialog->active_image = image;
|
dialog->active_image = image;
|
||||||
if (image)
|
if (image)
|
||||||
|
@ -721,11 +727,38 @@ gimp_color_dialog_image_changed (GimpContext *context,
|
||||||
g_signal_connect_swapped (image, "notify::base-type",
|
g_signal_connect_swapped (image, "notify::base-type",
|
||||||
G_CALLBACK (gimp_color_dialog_update),
|
G_CALLBACK (gimp_color_dialog_update),
|
||||||
dialog);
|
dialog);
|
||||||
|
g_signal_connect (image, "simulation-profile-changed",
|
||||||
|
G_CALLBACK (gimp_color_dialog_update_simulation),
|
||||||
|
dialog);
|
||||||
|
g_signal_connect (image, "simulation-intent-changed",
|
||||||
|
G_CALLBACK (gimp_color_dialog_update_simulation),
|
||||||
|
dialog);
|
||||||
|
g_signal_connect (image, "simulation-bpc-changed",
|
||||||
|
G_CALLBACK (gimp_color_dialog_update_simulation),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
gimp_color_dialog_update_simulation (image, dialog);
|
||||||
}
|
}
|
||||||
gimp_color_dialog_update (dialog);
|
gimp_color_dialog_update (dialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_dialog_update_simulation (GimpImage *image,
|
||||||
|
GimpColorDialog *dialog)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||||
|
|
||||||
|
if (image && GIMP_IS_COLOR_DIALOG (dialog))
|
||||||
|
{
|
||||||
|
gimp_color_selection_set_simulation (GIMP_COLOR_SELECTION (dialog->selection),
|
||||||
|
gimp_image_get_simulation_profile (image),
|
||||||
|
gimp_image_get_simulation_intent (image),
|
||||||
|
gimp_image_get_simulation_bpc (image));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_dialog_update (GimpColorDialog *dialog)
|
gimp_color_dialog_update (GimpColorDialog *dialog)
|
||||||
{
|
{
|
||||||
|
|
|
@ -595,3 +595,34 @@ gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook)
|
||||||
|
|
||||||
return notebook->priv->cur_page;
|
return notebook->priv->cur_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_notebook_set_simulation:
|
||||||
|
* @notebook: A #GimpColorNotebook widget.
|
||||||
|
* @profile: A #GimpColorProfile object.
|
||||||
|
* @intent: A #GimpColorRenderingIntent enum.
|
||||||
|
* @bpc: A gboolean.
|
||||||
|
*
|
||||||
|
* Updates all selectors with the current simulation settings.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gimp_color_notebook_set_simulation (GimpColorNotebook *notebook,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook));
|
||||||
|
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
|
||||||
|
|
||||||
|
for (list = notebook->priv->selectors; list; list = g_list_next (list))
|
||||||
|
{
|
||||||
|
GimpColorSelector *selector = list->data;
|
||||||
|
|
||||||
|
if (selector)
|
||||||
|
gimp_color_selector_set_simulation (selector, profile, intent, bpc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -77,6 +77,10 @@ GtkWidget * gimp_color_notebook_set_has_page (GimpColorNotebook
|
||||||
GtkWidget * gimp_color_notebook_get_notebook (GimpColorNotebook *notebook);
|
GtkWidget * gimp_color_notebook_get_notebook (GimpColorNotebook *notebook);
|
||||||
GList * gimp_color_notebook_get_selectors (GimpColorNotebook *notebook);
|
GList * gimp_color_notebook_get_selectors (GimpColorNotebook *notebook);
|
||||||
GimpColorSelector * gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook);
|
GimpColorSelector * gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook);
|
||||||
|
void gimp_color_notebook_set_simulation (GimpColorNotebook *notebook,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -560,6 +560,33 @@ gimp_color_selection_color_changed (GimpColorSelection *selection)
|
||||||
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_selection_set_simulation:
|
||||||
|
* @selection: A #GimpColorSelection widget.
|
||||||
|
* @profile: A #GimpColorProfile object.
|
||||||
|
* @intent: A #GimpColorRenderingIntent enum.
|
||||||
|
* @bpc: A gboolean.
|
||||||
|
*
|
||||||
|
* Sets the simulation options to use with this color selection.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gimp_color_selection_set_simulation (GimpColorSelection *selection,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
|
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (selection->priv->notebook),
|
||||||
|
profile,
|
||||||
|
intent,
|
||||||
|
bpc);
|
||||||
|
|
||||||
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_selection_set_config:
|
* gimp_color_selection_set_config:
|
||||||
* @selection: A #GimpColorSelection widget.
|
* @selection: A #GimpColorSelection widget.
|
||||||
|
|
|
@ -89,6 +89,11 @@ void gimp_color_selection_reset (GimpColorSelection *selection);
|
||||||
|
|
||||||
void gimp_color_selection_color_changed (GimpColorSelection *selection);
|
void gimp_color_selection_color_changed (GimpColorSelection *selection);
|
||||||
|
|
||||||
|
void gimp_color_selection_set_simulation (GimpColorSelection *selection,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc);
|
||||||
|
|
||||||
void gimp_color_selection_set_config (GimpColorSelection *selection,
|
void gimp_color_selection_set_config (GimpColorSelection *selection,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
|
||||||
|
|
|
@ -638,3 +638,31 @@ gimp_color_selector_set_config (GimpColorSelector *selector,
|
||||||
if (selector_class->set_config)
|
if (selector_class->set_config)
|
||||||
selector_class->set_config (selector, config);
|
selector_class->set_config (selector, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_selector_set_simulation
|
||||||
|
* @selector: a #GimpColorSelector widget.
|
||||||
|
* @profile: a #GimpColorProfile object.
|
||||||
|
* @intent: a #GimpColorRenderingIntent enum.
|
||||||
|
* @bpc: a gboolean.
|
||||||
|
*
|
||||||
|
* Sets the simulation options to use with this color selector.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc)
|
||||||
|
{
|
||||||
|
GimpColorSelectorClass *selector_class;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
|
||||||
|
|
||||||
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||||
|
|
||||||
|
if (selector_class->set_simulation)
|
||||||
|
selector_class->set_simulation (selector, profile, intent, bpc);
|
||||||
|
}
|
||||||
|
|
|
@ -105,6 +105,11 @@ struct _GimpColorSelectorClass
|
||||||
void (* set_config) (GimpColorSelector *selector,
|
void (* set_config) (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
|
||||||
|
void (* set_simulation) (GimpColorSelector *selector,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc);
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* color_changed) (GimpColorSelector *selector,
|
void (* color_changed) (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
|
@ -171,6 +176,11 @@ void gimp_color_selector_emit_model_visible_changed (GimpColorSelector *sele
|
||||||
void gimp_color_selector_set_config (GimpColorSelector *selector,
|
void gimp_color_selector_set_config (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
|
||||||
|
void gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ EXPORTS
|
||||||
gimp_color_notebook_get_selectors
|
gimp_color_notebook_get_selectors
|
||||||
gimp_color_notebook_get_type
|
gimp_color_notebook_get_type
|
||||||
gimp_color_notebook_set_has_page
|
gimp_color_notebook_set_has_page
|
||||||
|
gimp_color_notebook_set_simulation
|
||||||
gimp_color_profile_chooser_dialog_get_type
|
gimp_color_profile_chooser_dialog_get_type
|
||||||
gimp_color_profile_chooser_dialog_new
|
gimp_color_profile_chooser_dialog_new
|
||||||
gimp_color_profile_combo_box_add_file
|
gimp_color_profile_combo_box_add_file
|
||||||
|
@ -123,6 +124,7 @@ EXPORTS
|
||||||
gimp_color_selection_set_config
|
gimp_color_selection_set_config
|
||||||
gimp_color_selection_set_old_color
|
gimp_color_selection_set_old_color
|
||||||
gimp_color_selection_set_show_alpha
|
gimp_color_selection_set_show_alpha
|
||||||
|
gimp_color_selection_set_simulation
|
||||||
gimp_color_selector_channel_get_type
|
gimp_color_selector_channel_get_type
|
||||||
gimp_color_selector_emit_channel_changed
|
gimp_color_selector_emit_channel_changed
|
||||||
gimp_color_selector_emit_color_changed
|
gimp_color_selector_emit_color_changed
|
||||||
|
@ -141,6 +143,7 @@ EXPORTS
|
||||||
gimp_color_selector_set_config
|
gimp_color_selector_set_config
|
||||||
gimp_color_selector_set_model_visible
|
gimp_color_selector_set_model_visible
|
||||||
gimp_color_selector_set_show_alpha
|
gimp_color_selector_set_show_alpha
|
||||||
|
gimp_color_selector_set_simulation
|
||||||
gimp_color_selector_set_toggles_sensitive
|
gimp_color_selector_set_toggles_sensitive
|
||||||
gimp_color_selector_set_toggles_visible
|
gimp_color_selector_set_toggles_visible
|
||||||
gimp_context_help
|
gimp_context_help
|
||||||
|
|
|
@ -44,9 +44,10 @@ struct _ColorselCmyk
|
||||||
{
|
{
|
||||||
GimpColorSelector parent_instance;
|
GimpColorSelector parent_instance;
|
||||||
|
|
||||||
GimpColorConfig *config;
|
GimpColorConfig *config;
|
||||||
GimpColorTransform *rgb2cmyk;
|
GimpColorProfile *simulation_profile;
|
||||||
GimpColorTransform *cmyk2rgb;
|
GimpColorRenderingIntent simulation_intent;
|
||||||
|
gboolean simulation_bpc;
|
||||||
|
|
||||||
GimpCMYK cmyk;
|
GimpCMYK cmyk;
|
||||||
GtkWidget *scales[4];
|
GtkWidget *scales[4];
|
||||||
|
@ -70,6 +71,10 @@ static void colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
const GimpHSV *hsv);
|
const GimpHSV *hsv);
|
||||||
static void colorsel_cmyk_set_config (GimpColorSelector *selector,
|
static void colorsel_cmyk_set_config (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
static void colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc);
|
||||||
|
|
||||||
static void colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
static void colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
||||||
ColorselCmyk *module);
|
ColorselCmyk *module);
|
||||||
|
@ -111,13 +116,14 @@ colorsel_cmyk_class_init (ColorselCmykClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
||||||
|
|
||||||
object_class->dispose = colorsel_cmyk_dispose;
|
object_class->dispose = colorsel_cmyk_dispose;
|
||||||
|
|
||||||
selector_class->name = _("CMYK");
|
selector_class->name = _("CMYK");
|
||||||
selector_class->help_id = "gimp-colorselector-cmyk";
|
selector_class->help_id = "gimp-colorselector-cmyk";
|
||||||
selector_class->icon_name = GIMP_ICON_COLOR_SELECTOR_CMYK;
|
selector_class->icon_name = GIMP_ICON_COLOR_SELECTOR_CMYK;
|
||||||
selector_class->set_color = colorsel_cmyk_set_color;
|
selector_class->set_color = colorsel_cmyk_set_color;
|
||||||
selector_class->set_config = colorsel_cmyk_set_config;
|
selector_class->set_config = colorsel_cmyk_set_config;
|
||||||
|
selector_class->set_simulation = colorsel_cmyk_set_simulation;
|
||||||
|
|
||||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "ColorselCmyk");
|
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "ColorselCmyk");
|
||||||
}
|
}
|
||||||
|
@ -152,9 +158,7 @@ colorsel_cmyk_init (ColorselCmyk *module)
|
||||||
N_("Black")
|
N_("Black")
|
||||||
};
|
};
|
||||||
|
|
||||||
module->config = NULL;
|
module->config = NULL;
|
||||||
module->rgb2cmyk = NULL;
|
|
||||||
module->cmyk2rgb = NULL;
|
|
||||||
|
|
||||||
gtk_box_set_spacing (GTK_BOX (module), 6);
|
gtk_box_set_spacing (GTK_BOX (module), 6);
|
||||||
|
|
||||||
|
@ -198,6 +202,7 @@ colorsel_cmyk_dispose (GObject *object)
|
||||||
module->in_destruction = TRUE;
|
module->in_destruction = TRUE;
|
||||||
|
|
||||||
colorsel_cmyk_set_config (GIMP_COLOR_SELECTOR (object), NULL);
|
colorsel_cmyk_set_config (GIMP_COLOR_SELECTOR (object), NULL);
|
||||||
|
g_clear_object (&module->simulation_profile);
|
||||||
|
|
||||||
G_OBJECT_CLASS (colorsel_cmyk_parent_class)->dispose (object);
|
G_OBJECT_CLASS (colorsel_cmyk_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -207,40 +212,34 @@ colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
const GimpHSV *hsv)
|
const GimpHSV *hsv)
|
||||||
{
|
{
|
||||||
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
gdouble values[4];
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||||
gint i;
|
const Babl *fish = NULL;
|
||||||
|
const Babl *space = NULL;
|
||||||
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
||||||
|
gfloat values[4];
|
||||||
|
gint i;
|
||||||
|
|
||||||
if (module->rgb2cmyk)
|
/* Try Image Soft-proofing profile first, then default CMYK profile */
|
||||||
|
if (module->simulation_profile)
|
||||||
|
cmyk_profile = module->simulation_profile;
|
||||||
|
|
||||||
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
||||||
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (cmyk_profile && gimp_color_profile_is_cmyk (cmyk_profile))
|
||||||
{
|
{
|
||||||
gdouble rgb_values[3];
|
intent = module->simulation_intent;
|
||||||
gdouble cmyk_values[4];
|
|
||||||
|
|
||||||
rgb_values[0] = rgb->r;
|
space = gimp_color_profile_get_space (cmyk_profile, intent,
|
||||||
rgb_values[1] = rgb->g;
|
NULL);
|
||||||
rgb_values[2] = rgb->b;
|
|
||||||
|
|
||||||
gimp_color_transform_process_pixels (module->rgb2cmyk,
|
|
||||||
babl_format ("R'G'B' double"),
|
|
||||||
rgb_values,
|
|
||||||
babl_format ("CMYK double"),
|
|
||||||
cmyk_values,
|
|
||||||
1);
|
|
||||||
|
|
||||||
module->cmyk.c = cmyk_values[0] / 100.0;
|
|
||||||
module->cmyk.m = cmyk_values[1] / 100.0;
|
|
||||||
module->cmyk.y = cmyk_values[2] / 100.0;
|
|
||||||
module->cmyk.k = cmyk_values[3] / 100.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_rgb_to_cmyk (rgb, 1.0, &module->cmyk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
values[0] = module->cmyk.c * 100.0;
|
fish = babl_fish (babl_format ("R'G'B'A double"),
|
||||||
values[1] = module->cmyk.m * 100.0;
|
babl_format_with_space ("CMYK float", space));
|
||||||
values[2] = module->cmyk.y * 100.0;
|
|
||||||
values[3] = module->cmyk.k * 100.0;
|
babl_process (fish, rgb, values, 1);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
@ -248,12 +247,16 @@ colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
colorsel_cmyk_scale_update,
|
colorsel_cmyk_scale_update,
|
||||||
module);
|
module);
|
||||||
|
|
||||||
|
values[i] *= 100.0;
|
||||||
gimp_label_spin_set_value (GIMP_LABEL_SPIN (module->scales[i]), values[i]);
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (module->scales[i]), values[i]);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (module->scales[i],
|
g_signal_handlers_unblock_by_func (module->scales[i],
|
||||||
colorsel_cmyk_scale_update,
|
colorsel_cmyk_scale_update,
|
||||||
module);
|
module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmyk_profile && ! module->simulation_profile)
|
||||||
|
g_object_unref (cmyk_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -280,67 +283,91 @@ colorsel_cmyk_set_config (GimpColorSelector *selector,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
||||||
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
|
gboolean bpc)
|
||||||
|
{
|
||||||
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
||||||
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
|
||||||
|
gimp_help_set_help_data (module->name_label, NULL, NULL);
|
||||||
|
|
||||||
|
g_set_object (&module->simulation_profile, profile);
|
||||||
|
|
||||||
|
cmyk_profile = module->simulation_profile;
|
||||||
|
|
||||||
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
||||||
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (cmyk_profile && gimp_color_profile_is_cmyk (cmyk_profile))
|
||||||
|
{
|
||||||
|
text = g_strdup_printf (_("Profile: %s"),
|
||||||
|
gimp_color_profile_get_label (cmyk_profile));
|
||||||
|
gtk_label_set_text (GTK_LABEL (module->name_label), text);
|
||||||
|
g_free (text);
|
||||||
|
|
||||||
|
gimp_help_set_help_data (module->name_label,
|
||||||
|
gimp_color_profile_get_summary (cmyk_profile),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
module->simulation_intent = intent;
|
||||||
|
module->simulation_bpc = bpc;
|
||||||
|
|
||||||
|
if (! module->in_destruction)
|
||||||
|
colorsel_cmyk_set_color (selector, &selector->rgb, &selector->hsv);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
||||||
ColorselCmyk *module)
|
ColorselCmyk *module)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
gint i;
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
||||||
gdouble value;
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||||
|
const Babl *fish = NULL;
|
||||||
|
const Babl *space = NULL;
|
||||||
|
gfloat cmyk_values[4];
|
||||||
|
gfloat rgb_values[3];
|
||||||
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
if (GIMP_LABEL_SPIN (module->scales[i]) == scale)
|
cmyk_values[i] = gimp_label_spin_get_value (GIMP_LABEL_SPIN (module->scales[i])) / 100.0;
|
||||||
break;
|
|
||||||
|
|
||||||
value = gimp_label_spin_get_value (scale) / 100.0;
|
if (module->simulation_profile)
|
||||||
|
cmyk_profile = module->simulation_profile;
|
||||||
|
|
||||||
switch (i)
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
||||||
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
||||||
|
NULL);
|
||||||
|
if (cmyk_profile)
|
||||||
{
|
{
|
||||||
case 0:
|
intent = module->simulation_intent;
|
||||||
module->cmyk.c = value;
|
|
||||||
break;
|
space = gimp_color_profile_get_space (cmyk_profile, intent,
|
||||||
case 1:
|
NULL);
|
||||||
module->cmyk.m = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
module->cmyk.y = value;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
module->cmyk.k = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module->cmyk2rgb)
|
fish = babl_fish (babl_format_with_space ("CMYK float", space),
|
||||||
{
|
babl_format ("R'G'B'A float"));
|
||||||
gdouble cmyk_values[4];
|
|
||||||
gdouble rgb_values[3];
|
|
||||||
|
|
||||||
cmyk_values[0] = module->cmyk.c * 100.0;
|
babl_process (fish, cmyk_values, rgb_values, 1);
|
||||||
cmyk_values[1] = module->cmyk.m * 100.0;
|
|
||||||
cmyk_values[2] = module->cmyk.y * 100.0;
|
|
||||||
cmyk_values[3] = module->cmyk.k * 100.0;
|
|
||||||
|
|
||||||
gimp_color_transform_process_pixels (module->cmyk2rgb,
|
selector->rgb.r = rgb_values[0];
|
||||||
babl_format ("CMYK double"),
|
selector->rgb.g = rgb_values[1];
|
||||||
cmyk_values,
|
selector->rgb.b = rgb_values[2];
|
||||||
babl_format ("R'G'B' double"),
|
|
||||||
rgb_values,
|
|
||||||
1);
|
|
||||||
|
|
||||||
selector->rgb.r = rgb_values[0];
|
|
||||||
selector->rgb.g = rgb_values[1];
|
|
||||||
selector->rgb.b = rgb_values[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_cmyk_to_rgb (&module->cmyk, &selector->rgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
gimp_color_selector_emit_color_changed (selector);
|
||||||
|
|
||||||
|
if (cmyk_profile && ! module->simulation_profile)
|
||||||
|
g_object_unref (cmyk_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -348,30 +375,23 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
||||||
GimpColorConfig *config = module->config;
|
GimpColorConfig *config = module->config;
|
||||||
GimpColorTransformFlags flags = 0;
|
|
||||||
GimpColorProfile *rgb_profile = NULL;
|
GimpColorProfile *rgb_profile = NULL;
|
||||||
GimpColorProfile *cmyk_profile = NULL;
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
if (module->rgb2cmyk)
|
|
||||||
{
|
|
||||||
g_object_unref (module->rgb2cmyk);
|
|
||||||
module->rgb2cmyk = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module->cmyk2rgb)
|
|
||||||
{
|
|
||||||
g_object_unref (module->cmyk2rgb);
|
|
||||||
module->cmyk2rgb = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
|
gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
|
||||||
gimp_help_set_help_data (module->name_label, NULL, NULL);
|
gimp_help_set_help_data (module->name_label, NULL, NULL);
|
||||||
|
|
||||||
if (! config)
|
if (! config)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
cmyk_profile = gimp_color_config_get_cmyk_color_profile (config, NULL);
|
if (module->simulation_profile)
|
||||||
|
cmyk_profile = module->simulation_profile;
|
||||||
|
|
||||||
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
||||||
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (! cmyk_profile)
|
if (! cmyk_profile)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -386,28 +406,12 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
|
||||||
gimp_color_profile_get_summary (cmyk_profile),
|
gimp_color_profile_get_summary (cmyk_profile),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
flags |= GIMP_COLOR_TRANSFORM_FLAGS_NOOPTIMIZE;
|
|
||||||
flags |= GIMP_COLOR_TRANSFORM_FLAGS_BLACK_POINT_COMPENSATION;
|
|
||||||
|
|
||||||
module->rgb2cmyk = gimp_color_transform_new (rgb_profile,
|
|
||||||
babl_format ("R'G'B' double"),
|
|
||||||
cmyk_profile,
|
|
||||||
babl_format ("CMYK double"),
|
|
||||||
GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
|
|
||||||
flags);
|
|
||||||
module->cmyk2rgb = gimp_color_transform_new (cmyk_profile,
|
|
||||||
babl_format ("CMYK double"),
|
|
||||||
rgb_profile,
|
|
||||||
babl_format ("R'G'B' double"),
|
|
||||||
GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
|
|
||||||
flags);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
if (rgb_profile)
|
if (rgb_profile)
|
||||||
g_object_unref (rgb_profile);
|
g_object_unref (rgb_profile);
|
||||||
|
|
||||||
if (cmyk_profile)
|
if (cmyk_profile && ! module->simulation_profile)
|
||||||
g_object_unref (cmyk_profile);
|
g_object_unref (cmyk_profile);
|
||||||
|
|
||||||
if (! module->in_destruction)
|
if (! module->in_destruction)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue