Exemplo n.º 1
0
static void
colorsel_cmyk_config_changed (ColorselCmyk *module)
{
  GimpColorSelector *selector     = GIMP_COLOR_SELECTOR (module);
  GimpColorConfig   *config       = module->config;
  cmsUInt32Number    flags        = 0;
  GimpColorProfile   rgb_profile  = NULL;
  GimpColorProfile   cmyk_profile = NULL;
  gchar             *label;
  gchar             *summary;
  gchar             *text;

  if (module->rgb2cmyk)
    {
      cmsDeleteTransform (module->rgb2cmyk);
      module->rgb2cmyk = NULL;
    }

  if (module->cmyk2rgb)
    {
      cmsDeleteTransform (module->cmyk2rgb);
      module->cmyk2rgb = NULL;
    }

  gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
  gimp_help_set_help_data (module->name_label, NULL, NULL);

  if (! config)
    goto out;

  rgb_profile  = gimp_color_config_get_rgb_color_profile (config, NULL);
  cmyk_profile = gimp_color_config_get_cmyk_color_profile (config, NULL);

  if (! rgb_profile)
    rgb_profile = gimp_color_profile_new_srgb ();

  if (! cmyk_profile)
    goto out;

  label   = gimp_color_profile_get_label (cmyk_profile);
  summary = gimp_color_profile_get_summary (cmyk_profile);

  text = g_strdup_printf (_("Profile: %s"), label);
  gtk_label_set_text (GTK_LABEL (module->name_label), text);
  gimp_help_set_help_data (module->name_label, summary, NULL);

  g_free (text);
  g_free (label);
  g_free (summary);

  if (config->display_intent ==
      GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC)
    {
      flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
    }

  module->rgb2cmyk = cmsCreateTransform (rgb_profile,  TYPE_RGB_DBL,
                                         cmyk_profile, TYPE_CMYK_DBL,
                                         config->display_intent,
                                         flags);
  module->cmyk2rgb = cmsCreateTransform (cmyk_profile, TYPE_CMYK_DBL,
                                         rgb_profile,  TYPE_RGB_DBL,
                                         config->display_intent,
                                         flags);

 out:

  if (rgb_profile)
    gimp_color_profile_close (rgb_profile);

  if (cmyk_profile)
    gimp_color_profile_close (cmyk_profile);

  if (! module->in_destruction)
    colorsel_cmyk_set_color (selector, &selector->rgb, &selector->hsv);
}
Exemplo n.º 2
0
static GtkWidget *
color_profile_combo_box_new (ProfileDialog *dialog)
{
  GtkWidget        *combo;
  GtkWidget        *chooser;
  gchar            *history;
  GimpColorProfile *profile;
  gboolean          to_gray;
  gchar            *label;
  GError           *error = NULL;

  chooser =
    gimp_color_profile_chooser_dialog_new (_("Select Destination Profile"),
                                           NULL,
                                           GTK_FILE_CHOOSER_ACTION_OPEN);

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (chooser, history);
  g_free (history);

  switch (dialog->dialog_type)
    {
    case COLOR_PROFILE_DIALOG_ASSIGN_PROFILE:
    case COLOR_PROFILE_DIALOG_CONVERT_TO_PROFILE:
      to_gray = (gimp_image_get_base_type (dialog->image) == GIMP_GRAY);
      break;

    case COLOR_PROFILE_DIALOG_CONVERT_TO_RGB:
      to_gray = FALSE;
      break;

    case COLOR_PROFILE_DIALOG_CONVERT_TO_GRAY:
      to_gray = TRUE;
      break;

    default:
      g_return_val_if_reached (NULL);
    }

  profile = dialog->builtin_profile;

  if (to_gray)
    {
      label = g_strdup_printf (_("Built-in grayscale (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_gray_color_profile (dialog->config, &error);
    }
  else
    {
      label = g_strdup_printf (_("Built-in RGB (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_rgb_color_profile (dialog->config, &error);
    }

  gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         NULL, label);
  g_free (label);

  if (profile)
    {
      GFile *file;

      if (to_gray)
        {
          file = g_file_new_for_path (dialog->config->gray_profile);

          label = g_strdup_printf (_("Preferred grayscale (%s)"),
                                   gimp_color_profile_get_label (profile));
        }
      else
        {
          file = g_file_new_for_path (dialog->config->rgb_profile);

          label = g_strdup_printf (_("Preferred RGB (%s)"),
                                   gimp_color_profile_get_label (profile));
        }

      g_object_unref (profile);

      gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                             file, label);
      g_object_unref (file);
      g_free (label);
    }
  else if (error)
    {
      gimp_message (dialog->image->gimp, G_OBJECT (dialog->dialog),
                    GIMP_MESSAGE_ERROR,
                    "%s", error->message);
      g_clear_error (&error);
    }

  gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                                NULL, NULL);

  return combo;
}
Exemplo n.º 3
0
static GtkWidget *
color_profile_combo_box_new (ProfileDialog *dialog)
{
  GtkWidget        *combo;
  GtkWidget        *chooser;
  gchar            *history;
  GimpColorProfile *profile;
  gchar            *label;
  GError           *error = NULL;

  chooser = gimp_color_profile_chooser_dialog_new (_("Select destination profile"));

  history = gimp_personal_rc_file ("profilerc");
  combo = gimp_color_profile_combo_box_new (chooser, history);
  g_free (history);

  profile = gimp_image_get_builtin_color_profile (dialog->image);

  if (gimp_image_get_base_type (dialog->image) == GIMP_GRAY)
    {
      label = g_strdup_printf (_("Built-in grayscale (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_gray_color_profile (dialog->config, &error);
    }
  else
    {
      label = g_strdup_printf (_("Built-in RGB (%s)"),
                               gimp_color_profile_get_label (profile));

      profile = gimp_color_config_get_rgb_color_profile (dialog->config, &error);
    }

  gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                         NULL, label);
  g_free (label);

  if (profile)
    {
      GFile *file = g_file_new_for_path (dialog->config->rgb_profile);

      if (gimp_image_get_base_type (dialog->image) == GIMP_GRAY)
        {
          label = g_strdup_printf (_("Preferred grayscale (%s)"),
                                   gimp_color_profile_get_label (profile));
        }
      else
        {
          label = g_strdup_printf (_("Preferred RGB (%s)"),
                                   gimp_color_profile_get_label (profile));
        }

      g_object_unref (profile);

      gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                             file, label);
      g_object_unref (file);
      g_free (label);
    }
  else if (error)
    {
      gimp_message (dialog->image->gimp, G_OBJECT (dialog->dialog),
                    GIMP_MESSAGE_ERROR,
                    "%s", error->message);
      g_clear_error (&error);
    }

  gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
                                                NULL, NULL);

  return combo;
}