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 GtkWidget * cdisplay_proof_configure (GimpColorDisplay *display) { CdisplayProof *proof = CDISPLAY_PROOF (display); GtkWidget *table; GtkWidget *combo; GtkWidget *toggle; GtkWidget *dialog; gchar *history; table = gtk_table_new (3, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); dialog = cdisplay_proof_file_chooser_dialog_new (); history = gimp_personal_rc_file ("profilerc"); combo = gimp_color_profile_combo_box_new (dialog, history); g_free (history); g_signal_connect (dialog, "response", G_CALLBACK (cdisplay_proof_file_chooser_dialog_response), combo); g_signal_connect (combo, "changed", G_CALLBACK (cdisplay_proof_profile_changed), proof); if (proof->profile) cdisplay_proof_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), proof->profile); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Profile:"), 0.0, 0.5, combo, 1, FALSE); combo = gimp_prop_enum_combo_box_new (G_OBJECT (proof), "intent", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Intent:"), 0.0, 0.5, combo, 1, FALSE); toggle = gimp_prop_check_button_new (G_OBJECT (proof), "black-point-compensation", _("_Black Point Compensation")); gtk_table_attach_defaults (GTK_TABLE (table), toggle, 1, 2, 2, 3); gtk_widget_show (toggle); return table; }
static void cdisplay_proof_finalize (GObject *object) { CdisplayProof *proof = CDISPLAY_PROOF (object); if (proof->profile) { g_free (proof->profile); proof->profile = NULL; } if (proof->transform) { cmsDeleteTransform (proof->transform); proof->transform = NULL; } G_OBJECT_CLASS (cdisplay_proof_parent_class)->finalize (object); }
static void cdisplay_proof_convert (GimpColorDisplay *display, guchar *buf, gint width, gint height, gint bpp, gint bpl) { CdisplayProof *proof = CDISPLAY_PROOF (display); gint y; if (bpp != 3) return; if (! proof->transform) return; for (y = 0; y < height; y++, buf += bpl) cmsDoTransform (proof->transform, buf, buf, width); }
static void cdisplay_proof_changed (GimpColorDisplay *display) { CdisplayProof *proof = CDISPLAY_PROOF (display); cmsHPROFILE rgbProfile; cmsHPROFILE proofProfile; if (proof->transform) { cmsDeleteTransform (proof->transform); proof->transform = NULL; } if (! proof->profile) return; rgbProfile = cmsCreate_sRGBProfile (); proofProfile = cmsOpenProfileFromFile (proof->profile, "r"); if (proofProfile) { DWORD flags = cmsFLAGS_SOFTPROOFING; if (proof->bpc) flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; proof->transform = cmsCreateProofingTransform (rgbProfile, TYPE_RGB_8, rgbProfile, TYPE_RGB_8, proofProfile, proof->intent, proof->intent, flags); cmsCloseProfile (proofProfile); } cmsCloseProfile (rgbProfile); }
static void cdisplay_proof_convert_buffer (GimpColorDisplay *display, GeglBuffer *buffer, GeglRectangle *area) { CdisplayProof *proof = CDISPLAY_PROOF (display); GeglBufferIterator *iter; if (! proof->transform) return; iter = gegl_buffer_iterator_new (buffer, area, 0, babl_format ("R'G'B'A float"), GEGL_ACCESS_READWRITE, GEGL_ABYSS_NONE); while (gegl_buffer_iterator_next (iter)) { gfloat *data = iter->data[0]; cmsDoTransform (proof->transform, data, data, iter->length); } }
static void cdisplay_proof_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { CdisplayProof *proof = CDISPLAY_PROOF (object); switch (property_id) { case PROP_INTENT: g_value_set_enum (value, proof->intent); break; case PROP_BPC: g_value_set_boolean (value, proof->bpc); break; case PROP_PROFILE: g_value_set_string (value, proof->profile); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }