--- gimp-2.6.8.orig/app/config/gimpdisplayconfig.h 2009-07-21 05:20:50 +0900 +++ gimp-2.6.8/app/config/gimpdisplayconfig.h 2010-03-15 09:22:36 +0900 @@ -27,7 +27,7 @@ #include "config/gimpcoreconfig.h" -#define GIMP_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT "%D*%f-%p.%i (%t, %L) %wx%h" +#define GIMP_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT "%D*%f-%p.%i (%t[%c], %L) %wx%h" #define GIMP_CONFIG_DEFAULT_IMAGE_STATUS_FORMAT "%n (%m)" --- gimp-2.6.8.orig/app/core/gimpimage-convert.c 2009-07-21 05:46:25 +0900 +++ gimp-2.6.8/app/core/gimpimage-convert.c 2010-03-16 11:07:15 +0900 @@ -1068,6 +1068,27 @@ break; } + + /* TODO: attach or remove the ICC profile */ + switch (new_type) + { + case GIMP_RGB: + case GIMP_INDEXED: + if (gimp_image_parasite_find (image, "icc-profile") && old_type == GIMP_GRAY) + gimp_image_parasite_detach (image, "icc-profile"); + else + gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image)); + break; + case GIMP_GRAY: + if (gimp_image_parasite_find (image, "icc-profile")) + gimp_image_parasite_detach (image, "icc-profile"); + else + gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image)); + break; + default: + break; + } + /* Delete the quantizer object, if there is one */ if (quantobj) quantobj->delete_func (quantobj); --- gimp-2.6.8.orig/app/core/gimpimage.c 2009-07-21 05:20:50 +0900 +++ gimp-2.6.8/app/core/gimpimage.c 2010-03-15 09:22:36 +0900 @@ -194,6 +194,7 @@ static const guint8 * gimp_image_get_icc_profile (GimpColorManaged *managed, gsize *len); +static GimpImageBaseType gimp_image_get_base_type (GimpColorManaged *managed); static const gint valid_combinations[][MAX_CHANNELS + 1] = @@ -581,6 +582,7 @@ gimp_color_managed_iface_init (GimpColorManagedInterface *iface) { iface->get_icc_profile = gimp_image_get_icc_profile; + iface->get_base_type = gimp_image_base_type; } static void --- gimp-2.6.8.orig/app/dialogs/preferences-dialog.c 2009-07-21 05:20:50 +0900 +++ gimp-2.6.8/app/dialogs/preferences-dialog.c 2010-03-15 17:49:15 +0900 @@ -2439,13 +2439,15 @@ profiles[] = { { N_("_RGB profile:"), - N_("Select RGB Color Profile"), "rgb-profile" }, + N_("Select RGB Color Profile"), "rgb-profile" }, + { N_("_Grayscale profile:"), + N_("Select Grayscale Color Profile"), "gray-profile" }, { N_("_CMYK profile:"), - N_("Select CMYK Color Profile"), "cmyk-profile" }, + N_("Select CMYK Color Profile"), "cmyk-profile" }, { N_("_Monitor profile:"), - N_("Select Monitor Color Profile"), "display-profile" }, + N_("Select Monitor Color Profile"), "display-profile" }, { N_("_Print simulation profile:"), - N_("Select Printer Color Profile"), "printer-profile" } + N_("Select Printer Color Profile"), "printer-profile" } }; GObject *color_config; --- gimp-2.6.8.orig/app/display/gimpdisplayshell-title.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/app/display/gimpdisplayshell-title.c 2010-03-15 17:20:31 +0900 @@ -188,6 +188,53 @@ title[i++] = '%'; break; + case 'c': /* attached color profile */ + { + GimpParasite *p; + + p = gimp_image_parasite_find (image, "icc-profile"); + + if (shell->icc_profile != p) + { + g_free (shell->profile_desc); + shell->profile_desc = NULL; + + if (p) + { + GError *error = NULL; + + if (plug_in_icc_profile_info (image, + gimp_get_user_context (image->gimp), + NULL, + NULL, &shell->profile_desc, NULL, + &error)) + { + gchar *tmp; + GRegex *regex = g_regex_new ("%", 0, 0, NULL); + + tmp = g_regex_replace (regex, shell->profile_desc, -1, 0, "%%", 0, NULL); + + if (tmp) + { + g_free (shell->profile_desc); + shell->profile_desc = tmp; + } + + g_regex_unref (regex); + } + else + shell->profile_desc = g_strdup (_("Unknown")); + } + else + shell->profile_desc = g_strdup (_("No profiles embedded")); + + shell->icc_profile = p; + } + + i += print (title, title_len, i, shell->profile_desc); + } + break; + case 'f': /* pruned filename */ { const gchar *uri = gimp_image_get_uri (image); --- gimp-2.6.8.orig/app/display/gimpdisplayshell.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/app/display/gimpdisplayshell.c 2010-03-15 09:22:36 +0900 @@ -141,6 +141,8 @@ static const guint8 * gimp_display_shell_get_icc_profile (GimpColorManaged *managed, gsize *len); +static GimpImageBaseType gimp_display_shell_get_base_type + (GimpColorManaged *managed); G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell, GIMP_TYPE_WINDOW, @@ -353,6 +355,9 @@ shell->last_motion_distance = 0.0; shell->last_motion_delta_time = 0.0; + shell->icc_profile = NULL; + shell->profile_desc = g_strdup (_("No profiles embedded")); + gtk_window_set_role (GTK_WINDOW (shell), "gimp-image-window"); gtk_window_set_resizable (GTK_WINDOW (shell), TRUE); @@ -389,6 +394,7 @@ gimp_color_managed_iface_init (GimpColorManagedInterface *iface) { iface->get_icc_profile = gimp_display_shell_get_icc_profile; + iface->get_base_type = gimp_display_shell_get_base_type; } static void @@ -407,6 +413,8 @@ if (shell->no_image_options) g_object_unref (shell->no_image_options); + g_free (shell->profile_desc); + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -764,6 +772,18 @@ return NULL; } +static GimpImageBaseType +gimp_display_shell_get_base_type (GimpColorManaged *managed) +{ + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed); + GimpImage *image = shell->display->image; + + if (image) + return gimp_color_managed_get_base_type (GIMP_COLOR_MANAGED (image)); + + return GIMP_RGB; +} + static void gimp_display_shell_zoom_button_callback (GimpDisplayShell *shell, GtkWidget *zoom_button) --- gimp-2.6.8.orig/app/display/gimpdisplayshell.h 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/app/display/gimpdisplayshell.h 2010-03-15 09:22:36 +0900 @@ -198,6 +198,8 @@ gdouble last_motion_delta_y; gdouble last_motion_distance; + GimpParasite *icc_profile; + gchar *profile_desc; }; struct _GimpDisplayShellClass --- gimp-2.6.8.orig/docs/gimprc.5.in 2009-08-14 04:36:18 +0900 +++ gimp-2.6.8/docs/gimprc.5.in 2010-03-16 11:38:32 +0900 @@ -418,7 +418,7 @@ paint tool. Possible values are yes and no. .TP -(image-title-format "%D*%f-%p.%i (%t, %L) %wx%h") +(image-title-format "%D*%f-%p.%i (%t[%c], %L) %wx%h") Sets the text to appear in image window titles. This is a format string; certain % character sequences are recognised and expanded as follows: @@ -473,6 +473,8 @@ .br %U unit abbreviation .br +%c attached color profile +.br .br --- gimp-2.6.8.orig/etc/gimprc 2009-08-14 04:36:18 +0900 +++ gimp-2.6.8/etc/gimprc 2010-03-16 11:52:10 +0900 @@ -367,9 +367,10 @@ # %H image height in real-world units # %u unit symbol # %U unit abbreviation +# %c attached color profile # # -# (image-title-format "%D*%f-%p.%i (%t, %L) %wx%h") +# (image-title-format "%D*%f-%p.%i (%t[%c], %L) %wx%h") # Sets the text to appear in image window status bars. This is a format # string; certain % character sequences are recognised and expanded as @@ -399,6 +400,7 @@ # %H image height in real-world units # %u unit symbol # %U unit abbreviation +# %c attached color profile # # # (image-status-format "%n (%m)") --- gimp-2.6.8.orig/libgimpcolor/gimpcolor.def 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/libgimpcolor/gimpcolor.def 2010-03-15 10:08:39 +0900 @@ -17,6 +17,7 @@ gimp_cmyka_set gimp_cmyka_set_uchar gimp_color_managed_get_icc_profile + gimp_color_managed_get_base_type gimp_color_managed_interface_get_type gimp_color_managed_profile_changed gimp_hsl_get_type --- gimp-2.6.8.orig/libgimpcolor/gimpcolormanaged.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/libgimpcolor/gimpcolormanaged.c 2010-03-15 09:25:42 +0900 @@ -120,6 +120,29 @@ } /** + * gimp_color_managed_get_base_type: + * @managed: an object the implements the #GimpColorManaged interface + * + * Return value: Base type of GimpImage. + * + * Since: GIMP 2.6 + **/ +GimpImageBaseType +gimp_color_managed_get_base_type (GimpColorManaged *managed) +{ + GimpColorManagedInterface *iface; + + g_return_val_if_fail (GIMP_IS_COLOR_MANAGED (managed), 0); + + iface = GIMP_COLOR_MANAGED_GET_INTERFACE (managed); + + if (iface->get_base_type) + return iface->get_base_type (managed); + + return 0; +} + +/** * gimp_color_managed_profile_changed: * @managed: an object the implements the #GimpColorManaged interface * --- gimp-2.6.8.orig/libgimpcolor/gimpcolormanaged.h 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/libgimpcolor/gimpcolormanaged.h 2010-03-15 09:22:30 +0900 @@ -23,6 +23,8 @@ #ifndef __GIMP_COLOR_MANAGED_H__ #define __GIMP_COLOR_MANAGED_H__ +#include + G_BEGIN_DECLS /* For information look into the C source or the html documentation */ @@ -41,19 +43,21 @@ GTypeInterface base_iface; /* virtual functions */ - const guint8 * (* get_icc_profile) (GimpColorManaged *managed, - gsize *len); + const guint8 * (* get_icc_profile) (GimpColorManaged *managed, + gsize *len); + GimpImageBaseType (* get_base_type) (GimpColorManaged *managed); /* signals */ - void (* profile_changed) (GimpColorManaged *managed); + void (* profile_changed) (GimpColorManaged *managed); }; -GType gimp_color_managed_interface_get_type (void) G_GNUC_CONST; +GType gimp_color_managed_interface_get_type (void) G_GNUC_CONST; -const guint8 * gimp_color_managed_get_icc_profile (GimpColorManaged *managed, - gsize *len); -void gimp_color_managed_profile_changed (GimpColorManaged *managed); +const guint8 * gimp_color_managed_get_icc_profile (GimpColorManaged *managed, + gsize *len); +GimpImageBaseType gimp_color_managed_get_base_type (GimpColorManaged *managed); +void gimp_color_managed_profile_changed (GimpColorManaged *managed); G_END_DECLS --- gimp-2.6.8.orig/libgimpconfig/gimpcolorconfig.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/libgimpconfig/gimpcolorconfig.c 2010-03-15 17:49:15 +0900 @@ -48,6 +48,8 @@ "used as a fallback.") #define RGB_PROFILE_BLURB \ N_("The default RGB working space color profile.") +#define GRAY_PROFILE_BLURB \ + N_("The default Grayscale working space color profile.") #define CMYK_PROFILE_BLURB \ N_("The CMYK color profile used to convert between RGB and CMYK.") #define PRINTER_PROFILE_BLURB \ @@ -69,6 +71,7 @@ PROP_0, PROP_MODE, PROP_RGB_PROFILE, + PROP_GRAY_PROFILE, PROP_CMYK_PROFILE, PROP_DISPLAY_PROFILE, PROP_DISPLAY_PROFILE_FROM_GDK, @@ -121,6 +124,10 @@ "rgb-profile", RGB_PROFILE_BLURB, GIMP_CONFIG_PATH_FILE, NULL, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_GRAY_PROFILE, + "gray-profile", GRAY_PROFILE_BLURB, + GIMP_CONFIG_PATH_FILE, NULL, + GIMP_PARAM_STATIC_STRINGS); GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_CMYK_PROFILE, "cmyk-profile", CMYK_PROFILE_BLURB, GIMP_CONFIG_PATH_FILE, NULL, @@ -180,6 +187,9 @@ if (color_config->rgb_profile) g_free (color_config->rgb_profile); + if (color_config->gray_profile) + g_free (color_config->gray_profile); + if (color_config->cmyk_profile) g_free (color_config->cmyk_profile); @@ -212,6 +222,10 @@ g_free (color_config->rgb_profile); color_config->rgb_profile = g_value_dup_string (value); break; + case PROP_GRAY_PROFILE: + g_free (color_config->gray_profile); + color_config->gray_profile = g_value_dup_string (value); + break; case PROP_CMYK_PROFILE: g_free (color_config->cmyk_profile); color_config->cmyk_profile = g_value_dup_string (value); @@ -266,6 +280,9 @@ case PROP_RGB_PROFILE: g_value_set_string (value, color_config->rgb_profile); break; + case PROP_GRAY_PROFILE: + g_value_set_string (value, color_config->gray_profile); + break; case PROP_CMYK_PROFILE: g_value_set_string (value, color_config->cmyk_profile); break; --- gimp-2.6.8.orig/libgimpconfig/gimpcolorconfig.h 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/libgimpconfig/gimpcolorconfig.h 2010-03-15 17:49:15 +0900 @@ -40,6 +40,7 @@ /*< public >*/ GimpColorManagementMode mode; gchar *rgb_profile; + gchar *gray_profile; gchar *cmyk_profile; gchar *display_profile; gboolean display_profile_from_gdk; --- gimp-2.6.8.orig/modules/display-filter-lcms.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/modules/display-filter-lcms.c 2010-03-16 04:01:30 +0900 @@ -20,14 +20,14 @@ #include /* lcms.h uses the "inline" keyword */ +#include + #ifdef G_OS_WIN32 #define STRICT #include #define LCMS_WIN_TYPES_ALREADY_DEFINED #endif -#include - #include #ifdef GDK_WINDOWING_QUARTZ @@ -81,29 +81,31 @@ gint bpl); static void cdisplay_lcms_changed (GimpColorDisplay *display); -static cmsHPROFILE cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms); -static cmsHPROFILE cdisplay_lcms_get_display_profile (CdisplayLcms *lcms); -static cmsHPROFILE cdisplay_lcms_get_printer_profile (CdisplayLcms *lcms); - -static void cdisplay_lcms_attach_labelled (GtkTable *table, - gint row, - const gchar *text, - GtkWidget *widget); -static void cdisplay_lcms_update_profile_label (CdisplayLcms *lcms, - const gchar *name); -static void cdisplay_lcms_notify_profile (GObject *config, - GParamSpec *pspec, - CdisplayLcms *lcms); +static cmsHPROFILE cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms); +static cmsHPROFILE cdisplay_lcms_get_gray_profile (CdisplayLcms *lcms); +static cmsHPROFILE cdisplay_lcms_create_gray22_profile (void); +static cmsHPROFILE cdisplay_lcms_get_display_profile (CdisplayLcms *lcms); +static cmsHPROFILE cdisplay_lcms_get_printer_profile (CdisplayLcms *lcms); + +static void cdisplay_lcms_attach_labelled (GtkTable *table, + gint row, + const gchar *text, + GtkWidget *widget); +static void cdisplay_lcms_update_profile_label (CdisplayLcms *lcms, + const gchar *name); +static void cdisplay_lcms_notify_profile (GObject *config, + GParamSpec *pspec, + CdisplayLcms *lcms); static const GimpModuleInfo cdisplay_lcms_info = { GIMP_MODULE_ABI_VERSION, N_("Color management display filter using ICC color profiles"), - "Sven Neumann", - "v0.3", - "(c) 2005 - 2007, released under the GPL", - "2005 - 2007" + "Sven Neumann, Yoshinori Yamakawa", + "v0.3.1", + "(c) 2005 - 2010, released under the GPL", + "2005 - 2010" }; G_DEFINE_DYNAMIC_TYPE (CdisplayLcms, cdisplay_lcms, @@ -172,6 +174,7 @@ const gchar **name, const gchar **info) { + /* You should free name and info after use */ if (profile) { *name = cmsTakeProductDesc (profile); @@ -179,16 +182,16 @@ if (! *name) *name = cmsTakeProductName (profile); - if (*name && ! g_utf8_validate (*name, -1, NULL)) - *name = _("(invalid UTF-8 string)"); + if (*name) + *name = gimp_any_to_utf8 (*name, -1, NULL); *info = cmsTakeProductInfo (profile); - if (*name && ! g_utf8_validate (*info, -1, NULL)) - *info = NULL; + if (*info) + *info = gimp_any_to_utf8 (*info, -1, NULL); } else { - *name = _("None"); + *name = g_strdup (_("None")); *info = NULL; } } @@ -229,10 +232,12 @@ label = gtk_label_new (NULL); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); g_object_set_data (G_OBJECT (lcms), "rgb-profile", label); + g_object_set_data (G_OBJECT (lcms), "gray-profile", label); cdisplay_lcms_attach_labelled (GTK_TABLE (table), row++, _("Image profile:"), label); cdisplay_lcms_update_profile_label (lcms, "rgb-profile"); + cdisplay_lcms_update_profile_label (lcms, "gray-profile"); label = gtk_label_new (NULL); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); @@ -281,13 +286,17 @@ static void cdisplay_lcms_changed (GimpColorDisplay *display) { - CdisplayLcms *lcms = CDISPLAY_LCMS (display); - GimpColorConfig *config = gimp_color_display_get_config (display); + CdisplayLcms *lcms = CDISPLAY_LCMS (display); + GimpColorManaged *managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms)); + GimpColorConfig *config = gimp_color_display_get_config (display); + + cmsHPROFILE src_profile = NULL; + cmsHPROFILE dest_profile = NULL; + cmsHPROFILE proof_profile = NULL; + DWORD flags = 0; + DWORD src_format; - cmsHPROFILE src_profile = NULL; - cmsHPROFILE dest_profile = NULL; - cmsHPROFILE proof_profile = NULL; - DWORD flags = 0; + GimpImageBaseType base_type = gimp_color_managed_get_base_type (managed); if (lcms->transform) { @@ -308,7 +317,7 @@ /* fallthru */ case GIMP_COLOR_MANAGEMENT_DISPLAY: - src_profile = cdisplay_lcms_get_rgb_profile (lcms); + src_profile = base_type == GIMP_GRAY ? cdisplay_lcms_get_gray_profile (lcms) : cdisplay_lcms_get_rgb_profile (lcms); dest_profile = cdisplay_lcms_get_display_profile (lcms); break; } @@ -319,10 +328,13 @@ flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; } + src_format = base_type == GIMP_GRAY ? + COLORSPACE_SH (PT_GRAY) | EXTRA_SH (2) | CHANNELS_SH (1) | BYTES_SH (1) : TYPE_RGB_8; + if (proof_profile) { if (! src_profile) - src_profile = cmsCreate_sRGBProfile (); + src_profile = base_type == GIMP_GRAY ? cdisplay_lcms_create_gray22_profile () : cmsCreate_sRGBProfile (); if (! dest_profile) dest_profile = cmsCreate_sRGBProfile (); @@ -340,7 +352,7 @@ cmsSetAlarmCodes (r, g, b); } - lcms->transform = cmsCreateProofingTransform (src_profile, TYPE_RGB_8, + lcms->transform = cmsCreateProofingTransform (src_profile, src_format, dest_profile, TYPE_RGB_8, proof_profile, config->simulation_intent, @@ -351,12 +363,12 @@ else if (src_profile || dest_profile) { if (! src_profile) - src_profile = cmsCreate_sRGBProfile (); + src_profile = base_type == GIMP_GRAY ? cdisplay_lcms_create_gray22_profile () : cmsCreate_sRGBProfile (); if (! dest_profile) dest_profile = cmsCreate_sRGBProfile (); - lcms->transform = cmsCreateTransform (src_profile, TYPE_RGB_8, + lcms->transform = cmsCreateTransform (src_profile, src_format, dest_profile, TYPE_RGB_8, config->display_intent, flags); @@ -375,6 +387,12 @@ return (cmsGetColorSpace (profile) == icSigRgbData); } +static gboolean +cdisplay_lcms_profile_is_gray (cmsHPROFILE profile) +{ + return (cmsGetColorSpace (profile) == icSigGrayData); +} + static cmsHPROFILE cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms) { @@ -405,9 +423,79 @@ config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); if (config->rgb_profile) - profile = cmsOpenProfileFromFile (config->rgb_profile, "r"); + { + profile = cmsOpenProfileFromFile (config->rgb_profile, "r"); + + if (! cdisplay_lcms_profile_is_rgb (profile)) + { + cmsCloseProfile (profile); + profile = NULL; + } + } + } + + return profile; +} + +static cmsHPROFILE +cdisplay_lcms_get_gray_profile (CdisplayLcms *lcms) +{ + GimpColorConfig *config; + GimpColorManaged *managed; + cmsHPROFILE profile = NULL; + + managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms)); + + if (managed) + { + gsize len; + const guint8 *data = gimp_color_managed_get_icc_profile (managed, &len); + + if (data) + profile = cmsOpenProfileFromMem ((gpointer) data, len); + + if (profile && + ! cdisplay_lcms_profile_is_gray (profile)) + { + cmsCloseProfile (profile); + profile = NULL; + } } + if (! profile) + { + config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); + + if (config->gray_profile) + { + profile = cmsOpenProfileFromFile (config->gray_profile, "r"); + + if (! cdisplay_lcms_profile_is_gray (profile)) + { + cmsCloseProfile (profile); + profile = NULL; + } + + } + } + + return profile; +} + +static cmsHPROFILE +cdisplay_lcms_create_gray22_profile (void) +{ + cmsCIExyY wp = { 0.312705, 0.328990, 1.0 }; + LPGAMMATABLE transfer_func; + cmsHPROFILE profile; + + transfer_func = cmsBuildGamma (256, 2.2); + + profile = cmsCreateGrayProfile (&wp, transfer_func); + cmsAddTag (profile, icSigProfileDescriptionTag, "Gray Gamma 2.2"); + + cmsFreeGamma (transfer_func); + return profile; } @@ -631,17 +719,27 @@ { GtkWidget *label; cmsHPROFILE profile = NULL; - const gchar *text; - const gchar *tooltip; + gchar *text; + gchar *tooltip; + + GimpImageBaseType base_type; label = g_object_get_data (G_OBJECT (lcms), name); if (! label) return; + base_type = gimp_color_managed_get_base_type (gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms))); + if (strcmp (name, "rgb-profile") == 0) { - profile = cdisplay_lcms_get_rgb_profile (lcms); + if (base_type == GIMP_RGB || base_type == GIMP_INDEXED) + profile = cdisplay_lcms_get_rgb_profile (lcms); + } + else if (strcmp (name, "gray-profile") == 0) + { + if (base_type == GIMP_GRAY) + profile = cdisplay_lcms_get_gray_profile (lcms); } else if (g_str_has_prefix (name, "display-profile")) { @@ -661,6 +759,9 @@ gtk_label_set_text (GTK_LABEL (label), text); gimp_help_set_help_data (label, tooltip, NULL); + g_free (text); + g_free (tooltip); + if (profile) cmsCloseProfile (profile); } --- gimp-2.6.8.orig/plug-ins/common/lcms.c 2009-07-21 05:20:51 +0900 +++ gimp-2.6.8/plug-ins/common/lcms.c 2010-03-16 05:50:11 +0900 @@ -107,7 +107,8 @@ static cmsHPROFILE lcms_image_get_profile (GimpColorConfig *config, gint32 image, - guchar *checksum); + guchar *checksum, + gboolean *embedded); static gboolean lcms_image_set_profile (gint32 image, cmsHPROFILE profile, const gchar *filename, @@ -517,6 +518,12 @@ return (cmsGetColorSpace (profile) == icSigRgbData); } +static gboolean +lcms_icc_profile_is_gray (cmsHPROFILE profile) +{ + return (cmsGetColorSpace (profile) == icSigGrayData); +} + static GimpPDBStatusType lcms_icc_set (GimpColorConfig *config, gint32 image, @@ -577,7 +584,7 @@ } } - src_profile = lcms_image_get_profile (config, image, src_md5); + src_profile = lcms_image_get_profile (config, image, src_md5, NULL); if (src_profile && ! lcms_icc_profile_is_rgb (src_profile)) { @@ -648,35 +655,88 @@ gchar **desc, gchar **info) { - cmsHPROFILE profile; + cmsHPROFILE profile; + gboolean embedded; + GimpImageBaseType base_type; g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), GIMP_PDB_CALLING_ERROR); g_return_val_if_fail (image != -1, GIMP_PDB_CALLING_ERROR); - profile = lcms_image_get_profile (config, image, NULL); + base_type = gimp_image_base_type (image); + profile = lcms_image_get_profile (config, image, NULL, &embedded); - if (profile && ! lcms_icc_profile_is_rgb (profile)) + if (profile) { - g_printerr ("lcms: attached color profile is not for RGB color space " - "(skipping)\n"); + if (embedded) + { + if (name) *name = lcms_icc_profile_get_name (profile); + if (desc) *desc = lcms_icc_profile_get_desc (profile); + if (info) + { + if (base_type == GIMP_GRAY) + { + if (lcms_icc_profile_is_gray (profile)) + *info = lcms_icc_profile_get_info (profile); + else + { + gchar *tmp = lcms_icc_profile_get_info (profile); - cmsCloseProfile (profile); - profile = NULL; - } + *info = g_strdup_printf (_("%s\n\nWarning : this profile is not Grayscale colorspace!"), tmp); - if (profile) - { - if (name) *name = lcms_icc_profile_get_name (profile); - if (desc) *desc = lcms_icc_profile_get_desc (profile); - if (info) *info = lcms_icc_profile_get_info (profile); + g_free (tmp); + } + } + else + { + if (lcms_icc_profile_is_rgb (profile)) + *info = lcms_icc_profile_get_info (profile); + else + { + gchar *tmp = lcms_icc_profile_get_info (profile); + + *info = g_strdup_printf (_("%s\n\nWarning : this profile is not RGB colorspace!"), tmp); + + g_free (tmp); + } + } + } + } + else + { + if (name) *name = g_strdup (_("No profiles embedded")); + if (desc) *desc = g_strdup (_("No profiles embedded")); + if (info) + { + gchar *tmp = lcms_icc_profile_get_desc (profile); + + if ((base_type == GIMP_GRAY && ! lcms_icc_profile_is_gray (profile)) || + ((base_type == GIMP_RGB || base_type == GIMP_INDEXED) && ! lcms_icc_profile_is_rgb (profile))) + { + *info = g_strdup_printf (_("Warning : current workspace is \"%s\", but it doesn't match the document mode!"), tmp); + } + else + *info = g_strdup_printf (_("GIMP assumes that \"%s\" (workspace profile) is embedded."), tmp); + + g_free (tmp); + } + } cmsCloseProfile (profile); } else { - if (name) *name = g_strdup ("sRGB"); - if (desc) *desc = g_strdup ("sRGB built-in"); - if (info) *info = g_strdup (_("Default RGB working space")); + if (base_type == GIMP_GRAY) + { + if (name) *name = g_strdup ("Gray gamma 2.2"); + if (desc) *desc = g_strdup ("Gamma 2.2 built-in"); + if (info) *info = g_strdup (_("Default Grayscale working space")); + } + else + { + if (name) *name = g_strdup ("sRGB"); + if (desc) *desc = g_strdup ("sRGB built-in"); + if (info) *info = g_strdup (_("Default RGB working space")); + } } return GIMP_PDB_SUCCESS; @@ -750,10 +810,13 @@ static cmsHPROFILE lcms_image_get_profile (GimpColorConfig *config, gint32 image, - guchar *checksum) + guchar *checksum, + gboolean *embedded) { - GimpParasite *parasite; - cmsHPROFILE profile = NULL; + GimpParasite *parasite; + cmsHPROFILE profile = NULL; + gboolean _embedded = TRUE; + GimpImageBaseType base_type = gimp_image_base_type (image); g_return_val_if_fail (image != -1, NULL); @@ -778,11 +841,19 @@ gimp_parasite_free (parasite); } - else if (config->rgb_profile) + else { - profile = lcms_load_profile (config->rgb_profile, checksum); + gchar *profile_path = base_type == GIMP_GRAY ? config->gray_profile : config->rgb_profile; + + _embedded = FALSE; + + if (profile_path) + profile = lcms_load_profile (profile_path, checksum); } + if (embedded) + *embedded = _embedded; + return profile; } @@ -1432,7 +1503,7 @@ gboolean success = FALSE; gboolean run; - src_profile = lcms_image_get_profile (config, image, NULL); + src_profile = lcms_image_get_profile (config, image, NULL, NULL); if (src_profile && ! lcms_icc_profile_is_rgb (src_profile)) {