static cmsHPROFILE cdisplay_lcms_get_rgb_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_rgb (profile)) { cmsCloseProfile (profile); profile = NULL; } } if (! profile) { config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); if (config->rgb_profile) profile = cmsOpenProfileFromFile (config->rgb_profile, "r"); } return profile; }
static void cdisplay_lcms_update_profile_label (CdisplayLcms *lcms, const gchar *name) { GimpColorConfig *config; GimpColorManaged *managed; GtkWidget *label; GimpColorProfile *profile = NULL; const gchar *text; const gchar *tooltip; config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms)); label = g_object_get_data (G_OBJECT (lcms), name); if (! label) return; if (strcmp (name, "rgb-profile") == 0) { profile = gimp_color_managed_get_color_profile (managed); if (profile) g_object_ref (profile); } else if (g_str_has_prefix (name, "display-profile")) { profile = cdisplay_lcms_get_display_profile (lcms); } else if (strcmp (name, "printer-profile") == 0) { profile = gimp_color_config_get_simulation_color_profile (config, NULL); } else { g_return_if_reached (); } if (profile) { text = gimp_color_profile_get_label (profile); tooltip = gimp_color_profile_get_summary (profile); } else { text = _("None"); tooltip = NULL; } gtk_label_set_text (GTK_LABEL (label), text); gimp_help_set_help_data (label, tooltip, NULL); if (profile) g_object_unref (profile); }
static GdkScreen * cdisplay_lcms_get_screen (CdisplayLcms *lcms, gint *monitor) { GimpColorManaged *managed; GdkScreen *screen; managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms)); if (GTK_IS_WIDGET (managed)) screen = gtk_widget_get_screen (GTK_WIDGET (managed)); else screen = gdk_screen_get_default (); g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); if (GTK_IS_WIDGET (managed) && gtk_widget_get_window (GTK_WIDGET (managed))) { GtkWidget *widget = GTK_WIDGET (managed); *monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget)); } else { *monitor = 0; } return screen; }
static void cdisplay_proof_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { CdisplayProof *proof = CDISPLAY_PROOF (object); switch (property_id) { case PROP_INTENT: proof->intent = g_value_get_enum (value); break; case PROP_BPC: proof->bpc = g_value_get_boolean (value); break; case PROP_PROFILE: g_free (proof->profile); proof->profile = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof)); }
static void cdisplay_gamma_set_gamma (CdisplayGamma *gamma, gdouble value) { if (value <= 0.0) value = 1.0; if (value != gamma->gamma) { gdouble one_over_gamma = 1.0 / value; gint i; gamma->gamma = value; for (i = 0; i < 256; i++) { gdouble ind = (gdouble) i / 255.0; gamma->lookup[i] = (guchar) (gint) (255 * pow (ind, one_over_gamma)); } g_object_notify (G_OBJECT (gamma), "gamma"); gimp_color_display_changed (GIMP_COLOR_DISPLAY (gamma)); } }
static cmsHPROFILE cdisplay_lcms_get_printer_profile (CdisplayLcms *lcms) { GimpColorConfig *config; config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); if (config->printer_profile) return cmsOpenProfileFromFile (config->printer_profile, "r"); return NULL; }
static GimpColorDisplay * cdisplay_colorblind_clone (GimpColorDisplay *display) { CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display); CdisplayColorblind *copy; copy = CDISPLAY_COLORBLIND (gimp_color_display_new (G_TYPE_FROM_INSTANCE (colorblind))); copy->deficiency = colorblind->deficiency; return GIMP_COLOR_DISPLAY (copy); }
static GimpColorProfile * cdisplay_lcms_get_display_profile (CdisplayLcms *lcms) { GimpColorConfig *config; GimpColorManaged *managed; GtkWidget *widget = NULL; GimpColorProfile *profile = NULL; config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms)); if (GTK_IS_WIDGET (managed)) widget = gtk_widget_get_toplevel (GTK_WIDGET (managed)); if (gimp_color_config_get_display_profile_from_gdk (config)) profile = gimp_widget_get_color_profile (widget); if (! profile) profile = gimp_color_config_get_display_color_profile (config, NULL); return profile; }
static void cdisplay_gamma_set_gamma (CdisplayGamma *gamma, gdouble value) { if (value <= 0.0) value = 1.0; if (value != gamma->gamma) { gamma->gamma = value; g_object_notify (G_OBJECT (gamma), "gamma"); gimp_color_display_changed (GIMP_COLOR_DISPLAY (gamma)); } }
static cmsHPROFILE cdisplay_lcms_get_display_profile (CdisplayLcms *lcms) { GimpColorConfig *config; cmsHPROFILE profile = NULL; config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms)); #if defined GDK_WINDOWING_X11 if (config->display_profile_from_gdk) { GdkScreen *screen; GdkAtom type = GDK_NONE; gint format = 0; gint nitems = 0; gint monitor = 0; gchar *atom_name; guchar *data = NULL; screen = cdisplay_lcms_get_screen (lcms, &monitor); if (monitor > 0) atom_name = g_strdup_printf ("_ICC_PROFILE_%d", monitor); else atom_name = g_strdup ("_ICC_PROFILE"); if (gdk_property_get (gdk_screen_get_root_window (screen), gdk_atom_intern (atom_name, FALSE), GDK_NONE, 0, 64 * 1024 * 1024, FALSE, &type, &format, &nitems, &data) && nitems > 0) { profile = cmsOpenProfileFromMem (data, nitems); g_free (data); } g_free (atom_name); } #elif defined GDK_WINDOWING_QUARTZ if (config->display_profile_from_gdk) { CMProfileRef prof = NULL; gint monitor = 0; cdisplay_lcms_get_screen (lcms, &monitor); CMGetProfileByAVID (monitor, &prof); if (prof) { CFDataRef data; data = CMProfileCopyICCData (NULL, prof); CMCloseProfile (prof); if (data) { UInt8 *buffer = g_malloc (CFDataGetLength (data)); /* We cannot use CFDataGetBytesPtr(), because that returns * a const pointer where cmsOpenProfileFromMem wants a * non-const pointer. */ CFDataGetBytes (data, CFRangeMake (0, CFDataGetLength (data)), buffer); profile = cmsOpenProfileFromMem (buffer, CFDataGetLength (data)); g_free (buffer); CFRelease (data); } } } #elif defined G_OS_WIN32 if (config->display_profile_from_gdk) { HDC hdc = GetDC (NULL); if (hdc) { gchar *path; gint32 len = 0; GetICMProfile (hdc, &len, NULL); path = g_new (gchar, len); if (GetICMProfile (hdc, &len, path)) profile = cmsOpenProfileFromFile (path, "r"); g_free (path); ReleaseDC (NULL, hdc); } } #endif if (! profile && config->display_profile) profile = cmsOpenProfileFromFile (config->display_profile, "r"); return profile; }