2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-11-21 14:44:00 +00:00
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-11-21 14:44:00 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-11-21 14:44:00 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-11-21 14:44:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 03:36:22 +02:00
|
|
|
#include <gegl.h>
|
2003-11-21 14:44:00 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2007-09-17 13:37:47 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2011-04-28 15:50:39 +02:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2005-02-05 14:10:20 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-11-21 14:44:00 +00:00
|
|
|
#include "libgimpmodule/gimpmodule.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
2008-01-09 22:22:10 +00:00
|
|
|
#define CDISPLAY_TYPE_PROOF (cdisplay_proof_get_type ())
|
2003-11-21 14:44:00 +00:00
|
|
|
#define CDISPLAY_PROOF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_PROOF, CdisplayProof))
|
|
|
|
#define CDISPLAY_PROOF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_PROOF, CdisplayProofClass))
|
|
|
|
#define CDISPLAY_IS_PROOF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_PROOF))
|
|
|
|
#define CDISPLAY_IS_PROOF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CDISPLAY_TYPE_PROOF))
|
|
|
|
|
|
|
|
|
2011-01-23 07:28:33 +00:00
|
|
|
typedef struct _CdisplayProof CdisplayProof;
|
2003-11-21 14:44:00 +00:00
|
|
|
typedef struct _CdisplayProofClass CdisplayProofClass;
|
|
|
|
|
|
|
|
struct _CdisplayProof
|
|
|
|
{
|
2016-05-26 22:18:50 +02:00
|
|
|
GimpColorDisplay parent_instance;
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2016-05-26 22:18:50 +02:00
|
|
|
gint intent;
|
|
|
|
gboolean bpc;
|
|
|
|
gchar *profile;
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2016-05-26 22:18:50 +02:00
|
|
|
GimpColorTransform *transform;
|
2003-11-21 14:44:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _CdisplayProofClass
|
|
|
|
{
|
|
|
|
GimpColorDisplayClass parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-07-05 11:26:30 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_INTENT,
|
|
|
|
PROP_BPC,
|
|
|
|
PROP_PROFILE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-17 20:57:50 +01:00
|
|
|
static GType cdisplay_proof_get_type (void);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2011-01-23 07:28:33 +00:00
|
|
|
static void cdisplay_proof_finalize (GObject *object);
|
|
|
|
static void cdisplay_proof_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void cdisplay_proof_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-07-05 11:26:30 +00:00
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2013-11-02 14:53:48 +01:00
|
|
|
static void cdisplay_proof_convert_buffer (GimpColorDisplay *display,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
GeglRectangle *area);
|
2011-01-23 07:28:33 +00:00
|
|
|
static GtkWidget * cdisplay_proof_configure (GimpColorDisplay *display);
|
|
|
|
static void cdisplay_proof_changed (GimpColorDisplay *display);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const GimpModuleInfo cdisplay_proof_info =
|
|
|
|
{
|
|
|
|
GIMP_MODULE_ABI_VERSION,
|
|
|
|
N_("Color proof filter using ICC color profile"),
|
|
|
|
"Banlu Kemiyatorn <id@project-ile.net>",
|
|
|
|
"v0.1",
|
|
|
|
"(c) 2002-2003, released under the GPL",
|
|
|
|
"November 14, 2003"
|
|
|
|
};
|
|
|
|
|
2013-01-17 20:57:50 +01:00
|
|
|
|
2008-01-09 22:22:10 +00:00
|
|
|
G_DEFINE_DYNAMIC_TYPE (CdisplayProof, cdisplay_proof,
|
|
|
|
GIMP_TYPE_COLOR_DISPLAY)
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2013-01-17 20:57:50 +01:00
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
G_MODULE_EXPORT const GimpModuleInfo *
|
|
|
|
gimp_module_query (GTypeModule *module)
|
|
|
|
{
|
|
|
|
return &cdisplay_proof_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_MODULE_EXPORT gboolean
|
|
|
|
gimp_module_register (GTypeModule *module)
|
|
|
|
{
|
2008-01-09 22:22:10 +00:00
|
|
|
cdisplay_proof_register_type (module);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cdisplay_proof_class_init (CdisplayProofClass *klass)
|
|
|
|
{
|
2004-07-04 00:21:03 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2011-01-23 07:28:33 +00:00
|
|
|
object_class->finalize = cdisplay_proof_finalize;
|
|
|
|
object_class->get_property = cdisplay_proof_get_property;
|
|
|
|
object_class->set_property = cdisplay_proof_set_property;
|
2004-07-05 11:26:30 +00:00
|
|
|
|
2016-04-17 00:11:39 +01:00
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_INTENT,
|
|
|
|
"intent",
|
|
|
|
_("Intent"),
|
|
|
|
NULL,
|
|
|
|
GIMP_TYPE_COLOR_RENDERING_INTENT,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
|
|
|
|
0);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_BPC,
|
|
|
|
"black-point-compensation",
|
|
|
|
_("Black point compensation"),
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_PATH (object_class, PROP_PROFILE,
|
|
|
|
"profile",
|
|
|
|
_("Profile"),
|
|
|
|
NULL,
|
|
|
|
GIMP_CONFIG_PATH_FILE, NULL,
|
|
|
|
0);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2011-01-23 07:28:33 +00:00
|
|
|
display_class->name = _("Color Proof");
|
|
|
|
display_class->help_id = "gimp-colordisplay-proof";
|
2014-05-10 11:53:07 +02:00
|
|
|
display_class->icon_name = GIMP_STOCK_DISPLAY_FILTER_PROOF;
|
2006-10-01 17:31:42 +00:00
|
|
|
|
2013-11-02 14:53:48 +01:00
|
|
|
display_class->convert_buffer = cdisplay_proof_convert_buffer;
|
2011-01-23 07:28:33 +00:00
|
|
|
display_class->configure = cdisplay_proof_configure;
|
|
|
|
display_class->changed = cdisplay_proof_changed;
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
|
|
|
|
2008-01-09 22:22:10 +00:00
|
|
|
static void
|
|
|
|
cdisplay_proof_class_finalize (CdisplayProofClass *klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
static void
|
|
|
|
cdisplay_proof_init (CdisplayProof *proof)
|
|
|
|
{
|
|
|
|
proof->transform = NULL;
|
2004-07-05 11:26:30 +00:00
|
|
|
proof->profile = NULL;
|
2004-07-04 00:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cdisplay_proof_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
CdisplayProof *proof = CDISPLAY_PROOF (object);
|
|
|
|
|
2004-07-05 11:26:30 +00:00
|
|
|
if (proof->profile)
|
2003-11-21 14:44:00 +00:00
|
|
|
{
|
2004-07-05 11:26:30 +00:00
|
|
|
g_free (proof->profile);
|
|
|
|
proof->profile = NULL;
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
2008-01-09 22:22:10 +00:00
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
if (proof->transform)
|
|
|
|
{
|
2016-05-26 22:18:50 +02:00
|
|
|
g_object_unref (proof->transform);
|
2003-11-21 14:44:00 +00:00
|
|
|
proof->transform = NULL;
|
|
|
|
}
|
|
|
|
|
2008-01-09 22:22:10 +00:00
|
|
|
G_OBJECT_CLASS (cdisplay_proof_parent_class)->finalize (object);
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 11:26:30 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
static void
|
2013-11-02 14:53:48 +01:00
|
|
|
cdisplay_proof_convert_buffer (GimpColorDisplay *display,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
GeglRectangle *area)
|
2003-11-21 14:44:00 +00:00
|
|
|
{
|
2016-05-26 22:18:50 +02:00
|
|
|
CdisplayProof *proof = CDISPLAY_PROOF (display);
|
2011-01-23 07:28:33 +00:00
|
|
|
|
2016-05-26 22:18:50 +02:00
|
|
|
if (proof->transform)
|
|
|
|
gimp_color_transform_process_buffer (proof->transform,
|
|
|
|
buffer, area,
|
|
|
|
buffer, area);
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 13:37:47 +00:00
|
|
|
static void
|
|
|
|
cdisplay_proof_profile_changed (GtkWidget *combo,
|
|
|
|
CdisplayProof *proof)
|
|
|
|
{
|
2015-08-01 16:11:37 +02:00
|
|
|
GFile *file;
|
|
|
|
gchar *path = NULL;
|
2007-09-17 13:37:47 +00:00
|
|
|
|
2015-08-01 16:11:37 +02:00
|
|
|
file = gimp_color_profile_combo_box_get_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo));
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
path = g_file_get_path (file);
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
2007-09-17 13:37:47 +00:00
|
|
|
|
|
|
|
g_object_set (proof,
|
2015-08-01 16:11:37 +02:00
|
|
|
"profile", path,
|
2007-09-17 13:37:47 +00:00
|
|
|
NULL);
|
|
|
|
|
2015-08-01 16:11:37 +02:00
|
|
|
g_free (path);
|
2007-09-17 13:37:47 +00:00
|
|
|
}
|
|
|
|
|
2003-11-21 14:44:00 +00:00
|
|
|
static GtkWidget *
|
|
|
|
cdisplay_proof_configure (GimpColorDisplay *display)
|
|
|
|
{
|
2003-11-21 16:41:13 +00:00
|
|
|
CdisplayProof *proof = CDISPLAY_PROOF (display);
|
2005-02-05 21:51:47 +00:00
|
|
|
GtkWidget *table;
|
2005-02-05 14:10:20 +00:00
|
|
|
GtkWidget *combo;
|
|
|
|
GtkWidget *toggle;
|
2007-09-17 13:37:47 +00:00
|
|
|
GtkWidget *dialog;
|
|
|
|
gchar *history;
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2005-02-05 21:51:47 +00:00
|
|
|
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);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2016-05-07 01:19:26 +02:00
|
|
|
dialog = gimp_color_profile_chooser_dialog_new (_("Choose an ICC Color Profile"),
|
|
|
|
NULL,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
2007-09-17 13:37:47 +00:00
|
|
|
|
|
|
|
history = gimp_personal_rc_file ("profilerc");
|
|
|
|
combo = gimp_color_profile_combo_box_new (dialog, history);
|
|
|
|
g_free (history);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (cdisplay_proof_profile_changed),
|
|
|
|
proof);
|
|
|
|
|
|
|
|
if (proof->profile)
|
2015-08-01 16:11:37 +02:00
|
|
|
{
|
|
|
|
GFile *file = g_file_new_for_path (proof->profile);
|
|
|
|
|
|
|
|
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
|
|
|
file, NULL);
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2005-02-05 21:51:47 +00:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2007-09-17 13:37:47 +00:00
|
|
|
_("_Profile:"), 0.0, 0.5,
|
2005-02-05 14:10:20 +00:00
|
|
|
combo, 1, FALSE);
|
2003-11-21 19:27:06 +00:00
|
|
|
|
2007-09-17 13:37:47 +00:00
|
|
|
combo = gimp_prop_enum_combo_box_new (G_OBJECT (proof), "intent", 0, 0);
|
|
|
|
|
2005-02-05 21:51:47 +00:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2007-09-17 13:37:47 +00:00
|
|
|
_("_Intent:"), 0.0, 0.5,
|
|
|
|
combo, 1, FALSE);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2005-02-05 14:10:20 +00:00
|
|
|
toggle = gimp_prop_check_button_new (G_OBJECT (proof),
|
|
|
|
"black-point-compensation",
|
|
|
|
_("_Black Point Compensation"));
|
2005-02-05 21:51:47 +00:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), toggle, 1, 2, 2, 3);
|
2005-02-05 14:10:20 +00:00
|
|
|
gtk_widget_show (toggle);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2005-02-05 22:04:40 +00:00
|
|
|
return table;
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cdisplay_proof_changed (GimpColorDisplay *display)
|
|
|
|
{
|
2015-05-06 16:38:57 +02:00
|
|
|
CdisplayProof *proof = CDISPLAY_PROOF (display);
|
2015-07-10 22:43:53 +02:00
|
|
|
GimpColorProfile *rgb_profile;
|
|
|
|
GimpColorProfile *proof_profile;
|
2015-05-06 16:38:57 +02:00
|
|
|
GFile *file;
|
2003-11-21 14:44:00 +00:00
|
|
|
|
|
|
|
if (proof->transform)
|
|
|
|
{
|
2016-05-26 22:18:50 +02:00
|
|
|
g_object_unref (proof->transform);
|
2003-11-21 14:44:00 +00:00
|
|
|
proof->transform = NULL;
|
|
|
|
}
|
|
|
|
|
2004-07-05 11:26:30 +00:00
|
|
|
if (! proof->profile)
|
2003-11-21 16:41:13 +00:00
|
|
|
return;
|
|
|
|
|
2015-12-16 00:22:39 +01:00
|
|
|
rgb_profile = gimp_color_profile_new_rgb_srgb ();
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2015-05-06 16:38:57 +02:00
|
|
|
file = g_file_new_for_path (proof->profile);
|
2015-07-10 22:43:53 +02:00
|
|
|
proof_profile = gimp_color_profile_new_from_file (file, NULL);
|
2015-05-06 16:38:57 +02:00
|
|
|
g_object_unref (file);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2014-03-15 21:44:52 +01:00
|
|
|
if (proof_profile)
|
2003-11-21 14:44:00 +00:00
|
|
|
{
|
2016-05-26 22:18:50 +02:00
|
|
|
GimpColorTransformFlags flags = 0;
|
2015-07-10 22:43:53 +02:00
|
|
|
|
2007-10-04 14:21:55 +00:00
|
|
|
if (proof->bpc)
|
2016-05-26 22:18:50 +02:00
|
|
|
flags |= GIMP_COLOR_TRANSFORM_FLAGS_BLACK_POINT_COMPENSATION;
|
|
|
|
|
|
|
|
proof->transform =
|
|
|
|
gimp_color_transform_new_proofing (rgb_profile,
|
|
|
|
babl_format ("R'G'B'A float"),
|
|
|
|
rgb_profile,
|
|
|
|
babl_format ("R'G'B'A float"),
|
|
|
|
proof_profile,
|
|
|
|
proof->intent,
|
|
|
|
proof->intent,
|
|
|
|
flags);
|
2003-11-21 14:44:00 +00:00
|
|
|
|
2015-07-10 22:43:53 +02:00
|
|
|
g_object_unref (proof_profile);
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 22:43:53 +02:00
|
|
|
g_object_unref (rgb_profile);
|
2003-11-21 14:44:00 +00:00
|
|
|
}
|