[gimp] libgimpcolor, *: change GimpColorProfile to be a GObject
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpcolor, *: change GimpColorProfile to be a GObject
- Date: Fri, 10 Jul 2015 20:54:23 +0000 (UTC)
commit c102dde92b7bbacc6c6c6acd3aadbd4b0aaa86dd
Author: Michael Natterer <mitch gimp org>
Date: Fri Jul 10 22:43:53 2015 +0200
libgimpcolor, *: change GimpColorProfile to be a GObject
it used to be a typedef to gpointer and actually was a cmsHPROFILE.
Change its API to be more "standard", remove the public close()
function. The object caches both the cmsHPROFILE and the data/length
ICC blob, so conversions between the two become obsolete (simply call
get_lcms_profile() or get_icc_profile()).
Adapt everything to the new API, but port it in a naive way for now,
the code doesn't take advantage of the new possibilities yet (like
refcounting).
app/core/gimpimage-profile.c | 93 +++---
app/core/gimpimage-profile.h | 8 +-
app/core/gimpimage.c | 6 +-
app/display/gimpdisplayshell-title.c | 2 +-
app/display/gimpdisplayshell.c | 4 +-
app/pdb/image-color-profile-cmds.c | 39 ++-
app/pdb/plug-in-compat-cmds.c | 10 +-
app/widgets/gimpimageprofileview.c | 4 +-
libgimp/gimpimagecolorprofile.c | 72 +++---
libgimp/gimpimagecolorprofile.h | 17 +-
libgimpcolor/gimpcolor.def | 9 +-
libgimpcolor/gimpcolormanaged.c | 2 +-
libgimpcolor/gimpcolormanaged.h | 12 +-
libgimpcolor/gimpcolorprofile.c | 356 ++++++++++++++++--------
libgimpcolor/gimpcolorprofile.h | 93 +++++--
libgimpcolor/gimpcolortypes.h | 2 +-
libgimpconfig/gimpcolorconfig.c | 52 ++--
libgimpconfig/gimpcolorconfig.h | 20 +-
libgimpwidgets/gimpcolorprofilechooserdialog.c | 6 +-
libgimpwidgets/gimpcolorprofilecombobox.c | 6 +-
libgimpwidgets/gimpcolorprofileview.c | 68 +++--
libgimpwidgets/gimpcolorprofileview.h | 2 +-
libgimpwidgets/gimpwidgetsutils.c | 57 +++--
libgimpwidgets/gimpwidgetsutils.h | 46 ++--
modules/color-selector-cmyk.c | 21 +-
modules/display-filter-lcms.c | 42 ++--
modules/display-filter-proof.c | 21 +-
plug-ins/common/Makefile.am | 4 -
plug-ins/common/lcms.c | 106 ++++----
plug-ins/common/plugin-defs.pl | 2 +-
plug-ins/file-jpeg/jpeg-load.c | 25 +-
tools/pdbgen/pdb/image_color_profile.pdb | 39 ++-
tools/pdbgen/pdb/plug_in_compat.pdb | 10 +-
33 files changed, 737 insertions(+), 519 deletions(-)
---
diff --git a/app/core/gimpimage-profile.c b/app/core/gimpimage-profile.c
index 870ed10..fd4d9a2 100644
--- a/app/core/gimpimage-profile.c
+++ b/app/core/gimpimage-profile.c
@@ -52,14 +52,14 @@
/* local function prototypes */
static void gimp_image_convert_profile_rgb (GimpImage *image,
- GimpColorProfile src_profile,
- GimpColorProfile dest_profile,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress);
static void gimp_image_convert_profile_indexed (GimpImage *image,
- GimpColorProfile src_profile,
- GimpColorProfile dest_profile,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress);
@@ -133,14 +133,14 @@ gimp_image_validate_icc_profile (GimpImage *image,
gsize length,
GError **error)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (length != 0, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- profile = gimp_color_profile_open_from_data (data, length, error);
+ profile = gimp_color_profile_new_from_icc_profile (data, length, error);
if (! profile)
{
@@ -150,11 +150,11 @@ gimp_image_validate_icc_profile (GimpImage *image,
if (! gimp_image_validate_color_profile (image, profile, error))
{
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
return FALSE;
}
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
return TRUE;
}
@@ -219,11 +219,11 @@ gimp_image_set_icc_profile (GimpImage *image,
gboolean
gimp_image_validate_color_profile (GimpImage *image,
- GimpColorProfile profile,
+ GimpColorProfile *profile,
GError **error)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
- g_return_val_if_fail (profile != NULL, FALSE);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (gimp_image_get_base_type (image) == GIMP_GRAY)
@@ -245,7 +245,7 @@ gimp_image_validate_color_profile (GimpImage *image,
return TRUE;
}
-GimpColorProfile
+GimpColorProfile *
gimp_image_get_color_profile (GimpImage *image)
{
const GimpParasite *parasite;
@@ -255,53 +255,42 @@ gimp_image_get_color_profile (GimpImage *image)
parasite = gimp_image_get_icc_parasite (image);
if (parasite)
- return gimp_color_profile_open_from_data (gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
- NULL);
+ return gimp_color_profile_new_from_icc_profile (gimp_parasite_data (parasite),
+ gimp_parasite_data_size (parasite),
+ NULL);
return NULL;
}
gboolean
gimp_image_set_color_profile (GimpImage *image,
- GimpColorProfile profile,
+ GimpColorProfile *profile,
GError **error)
{
- guint8 *data = NULL;
- gsize length = 0;
+ const guint8 *data = NULL;
+ gsize length = 0;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+ g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
+ FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (profile)
- {
- data = gimp_color_profile_save_to_data (profile, &length, error);
- if (! data)
- return FALSE;
- }
-
- if (! gimp_image_set_icc_profile (image, data, length, error))
- {
- g_free (data);
-
- return FALSE;
- }
+ data = gimp_color_profile_get_icc_profile (profile, &length);
- g_free (data);
-
- return TRUE;
+ return gimp_image_set_icc_profile (image, data, length, error);
}
gboolean
gimp_image_convert_color_profile (GimpImage *image,
- GimpColorProfile dest_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress,
GError **error)
{
- GimpColorProfile src_profile;
- GimpColorProfile builtin_profile;
+ GimpColorProfile *src_profile;
+ GimpColorProfile *builtin_profile;
const Babl *layer_format;
gchar *src_label;
gchar *dest_label;
@@ -318,7 +307,7 @@ gimp_image_convert_color_profile (GimpImage *image,
if (gimp_color_profile_is_equal (src_profile, dest_profile))
{
- gimp_color_profile_close (src_profile);
+ g_object_unref (src_profile);
return TRUE;
}
@@ -353,7 +342,7 @@ gimp_image_convert_color_profile (GimpImage *image,
gimp_image_set_color_profile (image, dest_profile, NULL);
}
- gimp_color_profile_close (builtin_profile);
+ g_object_unref (builtin_profile);
/* omg... */
gimp_image_parasite_detach (image, "icc-profile-name");
@@ -383,7 +372,7 @@ gimp_image_convert_color_profile (GimpImage *image,
if (progress)
gimp_progress_end (progress);
- gimp_color_profile_close (src_profile);
+ g_object_unref (src_profile);
return TRUE;
}
@@ -393,8 +382,8 @@ gimp_image_convert_color_profile (GimpImage *image,
static void
gimp_image_convert_profile_rgb (GimpImage *image,
- GimpColorProfile src_profile,
- GimpColorProfile dest_profile,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress)
@@ -413,6 +402,8 @@ gimp_image_convert_profile_rgb (GimpImage *image,
list = g_list_next (list), nth_drawable++)
{
GimpDrawable *drawable = list->data;
+ cmsHPROFILE src_lcms;
+ cmsHPROFILE dest_lcms;
const Babl *iter_format;
cmsUInt32Number lcms_format;
cmsUInt32Number flags;
@@ -421,6 +412,9 @@ gimp_image_convert_profile_rgb (GimpImage *image,
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
continue;
+ src_lcms = gimp_color_profile_get_lcms_profile (src_profile);
+ dest_lcms = gimp_color_profile_get_lcms_profile (dest_profile);
+
iter_format =
gimp_color_profile_get_format (gimp_drawable_get_format (drawable),
&lcms_format);
@@ -430,8 +424,8 @@ gimp_image_convert_profile_rgb (GimpImage *image,
if (bpc)
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- transform = cmsCreateTransform (src_profile, lcms_format,
- dest_profile, lcms_format,
+ transform = cmsCreateTransform (src_lcms, lcms_format,
+ dest_lcms, lcms_format,
intent, flags);
if (transform)
@@ -474,21 +468,26 @@ gimp_image_convert_profile_rgb (GimpImage *image,
static void
gimp_image_convert_profile_indexed (GimpImage *image,
- GimpColorProfile src_profile,
- GimpColorProfile dest_profile,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress)
{
- GimpColorTransform transform;
+ cmsHPROFILE src_lcms;
+ cmsHPROFILE dest_lcms;
guchar *cmap;
gint n_colors;
+ GimpColorTransform transform;
+
+ src_lcms = gimp_color_profile_get_lcms_profile (src_profile);
+ dest_lcms = gimp_color_profile_get_lcms_profile (dest_profile);
n_colors = gimp_image_get_colormap_size (image);
cmap = g_memdup (gimp_image_get_colormap (image), n_colors * 3);
- transform = cmsCreateTransform (src_profile, TYPE_RGB_8,
- dest_profile, TYPE_RGB_8,
+ transform = cmsCreateTransform (src_lcms, TYPE_RGB_8,
+ dest_lcms, TYPE_RGB_8,
intent,
cmsFLAGS_NOOPTIMIZE |
(bpc ? cmsFLAGS_BLACKPOINTCOMPENSATION : 0));
diff --git a/app/core/gimpimage-profile.h b/app/core/gimpimage-profile.h
index 035f4bf..1b714d2 100644
--- a/app/core/gimpimage-profile.h
+++ b/app/core/gimpimage-profile.h
@@ -44,15 +44,15 @@ gboolean gimp_image_set_icc_profile (GimpImage *ima
GError **error);
gboolean gimp_image_validate_color_profile (GimpImage *image,
- GimpColorProfile profile,
+ GimpColorProfile *profile,
GError **error);
-GimpColorProfile gimp_image_get_color_profile (GimpImage *image);
+GimpColorProfile * gimp_image_get_color_profile (GimpImage *image);
gboolean gimp_image_set_color_profile (GimpImage *image,
- GimpColorProfile profile,
+ GimpColorProfile *profile,
GError **error);
gboolean gimp_image_convert_color_profile (GimpImage *image,
- GimpColorProfile dest_profile,
+ GimpColorProfile *dest_profile,
GimpColorRenderingIntent intent,
gboolean bpc,
GimpProgress *progress,
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index bc71db7..ccbac10 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -180,7 +180,7 @@ static void gimp_image_real_colormap_changed (GimpImage *image,
static const guint8 *
gimp_image_color_managed_get_icc_profile (GimpColorManaged *managed,
gsize *len);
-static GimpColorProfile
+static GimpColorProfile *
gimp_image_color_managed_get_color_profile (GimpColorManaged *managed);
static void gimp_image_projectable_flush (GimpProjectable *projectable,
@@ -1369,11 +1369,11 @@ gimp_image_color_managed_get_icc_profile (GimpColorManaged *managed,
return gimp_image_get_icc_profile (GIMP_IMAGE (managed), len);
}
-static GimpColorProfile
+static GimpColorProfile *
gimp_image_color_managed_get_color_profile (GimpColorManaged *managed)
{
GimpImage *image = GIMP_IMAGE (managed);
- GimpColorProfile profile;
+ GimpColorProfile *profile;
profile = gimp_image_get_color_profile (image);
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index db94eec..8f6e149 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -461,7 +461,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
i += print (title, title_len, i, "%s",
gimp_color_profile_get_label (profile));
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
break;
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 6dc404d..a7b0608 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -150,7 +150,7 @@ static void gimp_display_shell_real_rotated (GimpDisplayShell *shell);
static const guint8 *
gimp_display_shell_get_icc_profile(GimpColorManaged *managed,
gsize *len);
-static GimpColorProfile
+static GimpColorProfile *
gimp_display_shell_get_color_profile(GimpColorManaged *managed);
static void gimp_display_shell_profile_changed(GimpColorManaged *managed);
@@ -1138,7 +1138,7 @@ gimp_display_shell_get_icc_profile (GimpColorManaged *managed,
return NULL;
}
-static GimpColorProfile
+static GimpColorProfile *
gimp_display_shell_get_color_profile (GimpColorManaged *managed)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed);
diff --git a/app/pdb/image-color-profile-cmds.c b/app/pdb/image-color-profile-cmds.c
index 818e05d..0515cda 100644
--- a/app/pdb/image-color-profile-cmds.c
+++ b/app/pdb/image-color-profile-cmds.c
@@ -60,18 +60,21 @@ image_get_color_profile_invoker (GimpProcedure *procedure,
if (success)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
profile = gimp_image_get_color_profile (image);
if (profile)
{
- gsize length;
+ const guint8 *data;
+ gsize length;
- profile_data = gimp_color_profile_save_to_data (profile, &length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ profile_data = g_memdup (data, length);
num_bytes = length;
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
}
@@ -108,15 +111,16 @@ image_set_color_profile_invoker (GimpProcedure *procedure,
{
if (color_profile)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (color_profile, num_bytes,
- error);
+ profile = gimp_color_profile_new_from_icc_profile (color_profile,
+ num_bytes,
+ error);
if (profile)
{
success = gimp_image_set_color_profile (image, profile, error);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
success = FALSE;
@@ -149,15 +153,18 @@ image_get_effective_color_profile_invoker (GimpProcedure *procedure,
if (success)
{
- GimpColorProfile profile;
- gsize length;
+ GimpColorProfile *profile;
+ const guint8 *data;
+ gsize length;
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
- profile_data = gimp_color_profile_save_to_data (profile, &length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ profile_data = g_memdup (data, length);
num_bytes = length;
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
return_vals = gimp_procedure_get_return_values (procedure, success,
@@ -197,16 +204,18 @@ image_convert_color_profile_invoker (GimpProcedure *procedure,
{
if (color_profile)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (color_profile, num_bytes,
- error);
+ profile = gimp_color_profile_new_from_icc_profile (color_profile,
+ num_bytes,
+ error);
if (profile)
{
success = gimp_image_convert_color_profile (image, profile,
intent, bpc,
progress, error);
+ g_object_unref (profile);
}
else
success = FALSE;
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 15346f6..2ff59f8 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -1880,7 +1880,7 @@ plug_in_icc_profile_info_invoker (GimpProcedure *procedure,
if (success)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
@@ -1888,7 +1888,7 @@ plug_in_icc_profile_info_invoker (GimpProcedure *procedure,
profile_desc = gimp_color_profile_get_description (profile);
profile_info = gimp_color_profile_get_summary (profile);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
@@ -1928,9 +1928,9 @@ plug_in_icc_profile_file_info_invoker (GimpProcedure *procedure,
if (file)
{
- GimpColorProfile p;
+ GimpColorProfile *p;
- p = gimp_color_profile_open_from_file (file, error);
+ p = gimp_color_profile_new_from_file (file, error);
g_object_unref (file);
if (p)
@@ -1939,7 +1939,7 @@ plug_in_icc_profile_file_info_invoker (GimpProcedure *procedure,
profile_desc = gimp_color_profile_get_description (p);
profile_info = gimp_color_profile_get_summary (p);
- gimp_color_profile_close (p);
+ g_object_unref (p);
}
else
success = FALSE;
diff --git a/app/widgets/gimpimageprofileview.c b/app/widgets/gimpimageprofileview.c
index a276ccc..90f05e6 100644
--- a/app/widgets/gimpimageprofileview.c
+++ b/app/widgets/gimpimageprofileview.c
@@ -103,7 +103,7 @@ gimp_image_profile_view_update (GimpImageParasiteView *view)
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
GimpImage *image;
GimpColorManaged *managed;
- GimpColorProfile profile;
+ GimpColorProfile *profile;
image = gimp_image_parasite_view_get_image (view);
managed = GIMP_COLOR_MANAGED (image);
@@ -112,5 +112,5 @@ gimp_image_profile_view_update (GimpImageParasiteView *view)
gimp_color_profile_view_set_profile (profile_view->profile_view, profile);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
diff --git a/libgimp/gimpimagecolorprofile.c b/libgimp/gimpimagecolorprofile.c
index 200ab00..806d7a3 100644
--- a/libgimp/gimpimagecolorprofile.c
+++ b/libgimp/gimpimagecolorprofile.c
@@ -33,11 +33,11 @@
* image has no color profile assigned.
*
* Returns: The image's color profile. The returned value
- * must be freed with gimp_color_profile_close().
+ * must be freed with g_object_unref().
*
* Since: 2.10
**/
-GimpColorProfile
+GimpColorProfile *
gimp_image_get_color_profile (gint32 image_ID)
{
guint8 *data;
@@ -47,9 +47,9 @@ gimp_image_get_color_profile (gint32 image_ID)
if (data)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (data, length, NULL);
+ profile = gimp_color_profile_new_from_icc_profile (data, length, NULL);
g_free (data);
return profile;
@@ -72,28 +72,24 @@ gimp_image_get_color_profile (gint32 image_ID)
* Since: 2.10
**/
gboolean
-gimp_image_set_color_profile (gint32 image_ID,
- GimpColorProfile profile)
+gimp_image_set_color_profile (gint32 image_ID,
+ GimpColorProfile *profile)
{
- guint8 *data = NULL;
- gint length = 0;
- gboolean success;
+ const guint8 *data = NULL;
+ gint length = 0;
+
+ g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
+ NULL);
if (profile)
{
gsize l;
- data = gimp_color_profile_save_to_data (profile, &l, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &l);
length = l;
-
- if (! data)
- return FALSE;
}
- success = _gimp_image_set_color_profile (image_ID, length, data);
- g_free (data);
-
- return success;
+ return _gimp_image_set_color_profile (image_ID, length, data);
}
/**
@@ -110,11 +106,11 @@ gimp_image_set_color_profile (gint32 image_ID,
* in preferences either, a generated default RGB profile is returned.
*
* Returns: The color profile. The returned value
- * must be freed with gimp_color_profile_close().
+ * must be freed with g_object_unref().
*
* Since: 2.10
**/
-GimpColorProfile
+GimpColorProfile *
gimp_image_get_effective_color_profile (gint32 image_ID)
{
guint8 *data;
@@ -124,9 +120,9 @@ gimp_image_get_effective_color_profile (gint32 image_ID)
if (data)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (data, length, NULL);
+ profile = gimp_color_profile_new_from_icc_profile (data, length, NULL);
g_free (data);
return profile;
@@ -138,9 +134,9 @@ gimp_image_get_effective_color_profile (gint32 image_ID)
/**
* gimp_image_convert_color_profile:
* @image_ID: The image.
- * @profile: The color profile to convert to.
- * @intent: Rendering intent.
- * @bpc: Black point compensation.
+ * @profile: The color profile to convert to.
+ * @intent: Rendering intent.
+ * @bpc: Black point compensation.
*
* Convert the image's layers to a color profile
*
@@ -153,29 +149,25 @@ gimp_image_get_effective_color_profile (gint32 image_ID)
* Since: 2.10
**/
gboolean
-gimp_image_convert_color_profile (gint32 image_ID,
- GimpColorProfile profile,
- GimpColorRenderingIntent intent,
- gboolean bpc)
+gimp_image_convert_color_profile (gint32 image_ID,
+ GimpColorProfile *profile,
+ GimpColorRenderingIntent intent,
+ gboolean bpc)
{
- guint8 *data = NULL;
- gint length = 0;
- gboolean success;
+ const guint8 *data = NULL;
+ gint length = 0;
+
+ g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
+ NULL);
if (profile)
{
gsize l;
- data = gimp_color_profile_save_to_data (profile, &l, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &l);
length = l;
-
- if (! data)
- return FALSE;
}
- success = _gimp_image_convert_color_profile (image_ID, length, data,
- intent, bpc);
- g_free (data);
-
- return success;
+ return _gimp_image_convert_color_profile (image_ID, length, data,
+ intent, bpc);
}
diff --git a/libgimp/gimpimagecolorprofile.h b/libgimp/gimpimagecolorprofile.h
index 33e7cc5..b70051e 100644
--- a/libgimp/gimpimagecolorprofile.h
+++ b/libgimp/gimpimagecolorprofile.h
@@ -30,16 +30,17 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-GimpColorProfile gimp_image_get_color_profile (gint32 image_ID);
-gboolean gimp_image_set_color_profile (gint32 image_ID,
- GimpColorProfile profile);
+GimpColorProfile * gimp_image_get_color_profile (gint32 image_ID);
+gboolean gimp_image_set_color_profile (gint32 image_ID,
+ GimpColorProfile *profile);
-GimpColorProfile gimp_image_get_effective_color_profile (gint32 image_ID);
+GimpColorProfile * gimp_image_get_effective_color_profile (gint32 image_ID);
+
+gboolean gimp_image_convert_color_profile (gint32 image_ID,
+ GimpColorProfile *profile,
+ GimpColorRenderingIntent intent,
+ gboolean bpc);
-gboolean gimp_image_convert_color_profile (gint32 image_ID,
- GimpColorProfile profile,
- GimpColorRenderingIntent intent,
- gboolean bpc);
G_END_DECLS
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 79e64dd..33b8ebe 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -25,22 +25,23 @@ EXPORTS
gimp_color_managed_get_icc_profile
gimp_color_managed_interface_get_type
gimp_color_managed_profile_changed
- gimp_color_profile_close
gimp_color_profile_get_copyright
gimp_color_profile_get_description
gimp_color_profile_get_format
+ gimp_color_profile_get_icc_profile
gimp_color_profile_get_label
+ gimp_color_profile_get_lcms_profile
gimp_color_profile_get_manufacturer
gimp_color_profile_get_model
gimp_color_profile_get_summary
gimp_color_profile_is_cmyk
gimp_color_profile_is_equal
gimp_color_profile_is_rgb
+ gimp_color_profile_new_from_file
+ gimp_color_profile_new_from_icc_profile
+ gimp_color_profile_new_from_lcms_profile
gimp_color_profile_new_linear_rgb
gimp_color_profile_new_srgb
- gimp_color_profile_open_from_data
- gimp_color_profile_open_from_file
- gimp_color_profile_save_to_data
gimp_hsl_get_type
gimp_hsl_set
gimp_hsl_set_alpha
diff --git a/libgimpcolor/gimpcolormanaged.c b/libgimpcolor/gimpcolormanaged.c
index 6803483..f52308f 100644
--- a/libgimpcolor/gimpcolormanaged.c
+++ b/libgimpcolor/gimpcolormanaged.c
@@ -141,7 +141,7 @@ gimp_color_managed_get_icc_profile (GimpColorManaged *managed,
*
* Since: 2.10
**/
-GimpColorProfile
+GimpColorProfile *
gimp_color_managed_get_color_profile (GimpColorManaged *managed)
{
GimpColorManagedInterface *iface;
diff --git a/libgimpcolor/gimpcolormanaged.h b/libgimpcolor/gimpcolormanaged.h
index 1dc0149..9948b8c 100644
--- a/libgimpcolor/gimpcolormanaged.h
+++ b/libgimpcolor/gimpcolormanaged.h
@@ -51,17 +51,17 @@ struct _GimpColorManagedInterface
void (* profile_changed) (GimpColorManaged *managed);
/* virtual functions */
- GimpColorProfile (* get_color_profile) (GimpColorManaged *managed);
+ GimpColorProfile * (* get_color_profile) (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);
-GimpColorProfile gimp_color_managed_get_color_profile (GimpColorManaged *managed);
+const guint8 * gimp_color_managed_get_icc_profile (GimpColorManaged *managed,
+ gsize *len);
+GimpColorProfile * gimp_color_managed_get_color_profile (GimpColorManaged *managed);
-void gimp_color_managed_profile_changed (GimpColorManaged *managed);
+void gimp_color_managed_profile_changed (GimpColorManaged *managed);
G_END_DECLS
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index 3d9f210..f57a27d 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -58,6 +58,23 @@
#define GIMP_LCMS_MD5_DIGEST_LENGTH 16
+struct _GimpColorProfilePrivate
+{
+ cmsHPROFILE lcms_profile;
+ guint8 *data;
+ gsize length;
+};
+
+
+static void gimp_color_profile_finalize (GObject *object);
+
+
+G_DEFINE_TYPE (GimpColorProfile, gimp_color_profile,
+ G_TYPE_OBJECT);
+
+#define parent_class gimp_color_profile_parent_class
+
+
static GQuark
gimp_color_profile_error_quark (void)
{
@@ -69,8 +86,48 @@ gimp_color_profile_error_quark (void)
return quark;
}
+static void
+gimp_color_profile_class_init (GimpColorProfileClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gimp_color_profile_finalize;
+
+ g_type_class_add_private (klass, sizeof (GimpColorProfilePrivate));
+}
+
+static void
+gimp_color_profile_init (GimpColorProfile *profile)
+{
+ profile->priv = G_TYPE_INSTANCE_GET_PRIVATE (profile,
+ GIMP_TYPE_COLOR_PROFILE,
+ GimpColorProfilePrivate);
+}
+
+static void
+gimp_color_profile_finalize (GObject *object)
+{
+ GimpColorProfile *profile = GIMP_COLOR_PROFILE (object);
+
+ if (profile->priv->lcms_profile)
+ {
+ cmsCloseProfile (profile->priv->lcms_profile);
+ profile->priv->lcms_profile = NULL;
+ }
+
+ if (profile->priv->data)
+ {
+ g_free (profile->priv->data);
+ profile->priv->data = NULL;
+ profile->priv->length = 0;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
/**
- * gimp_color_profile_open_from_file:
+ * gimp_color_profile_new_from_file:
* @file: a #GFile
* @error: return location for #GError
*
@@ -81,11 +138,14 @@ gimp_color_profile_error_quark (void)
*
* Since: 2.10
**/
-GimpColorProfile
-gimp_color_profile_open_from_file (GFile *file,
- GError **error)
+GimpColorProfile *
+gimp_color_profile_new_from_file (GFile *file,
+ GError **error)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
+ cmsHPROFILE lcms_profile = NULL;
+ guint8 *data = NULL;
+ gsize length = 0;
gchar *path;
g_return_val_if_fail (G_IS_FILE (file), NULL);
@@ -96,18 +156,16 @@ gimp_color_profile_open_from_file (GFile *file,
if (path)
{
GMappedFile *mapped;
- const guint8 *data;
- gsize length;
mapped = g_mapped_file_new (path, FALSE, error);
if (! mapped)
return NULL;
- data = (const guint8 *) g_mapped_file_get_contents (mapped);
length = g_mapped_file_get_length (mapped);
+ data = g_memdup (g_mapped_file_get_contents (mapped), length);
- profile = cmsOpenProfileFromMem (data, length);
+ lcms_profile = cmsOpenProfileFromMem (data, length);
g_mapped_file_unref (mapped);
}
@@ -122,8 +180,9 @@ gimp_color_profile_open_from_file (GFile *file,
if (info)
{
GInputStream *input;
- goffset length = g_file_info_get_size (info);
- guint8 *data = g_malloc (length);
+
+ length = g_file_info_get_size (info);
+ data = g_malloc (length);
g_object_unref (info);
@@ -137,26 +196,40 @@ gimp_color_profile_open_from_file (GFile *file,
&bytes_read, NULL, error) &&
bytes_read == length)
{
- profile = cmsOpenProfileFromMem (data, length);
+ lcms_profile = cmsOpenProfileFromMem (data, length);
}
g_object_unref (input);
}
-
- g_free (data);
}
}
- if (! profile && error && *error == NULL)
- g_set_error (error, gimp_color_profile_error_quark (), 0,
- _("'%s' does not appear to be an ICC color profile"),
- gimp_file_get_utf8_name (file));
+ if (lcms_profile)
+ {
+ profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
+
+ profile->priv->lcms_profile = lcms_profile;
+ profile->priv->data = data;
+ profile->priv->length = length;
+ }
+ else
+ {
+ if (data)
+ g_free (data);
+
+ if (error && *error == NULL)
+ {
+ g_set_error (error, gimp_color_profile_error_quark (), 0,
+ _("'%s' does not appear to be an ICC color profile"),
+ gimp_file_get_utf8_name (file));
+ }
+ }
return profile;
}
/**
- * gimp_color_profile_open_from_data:
+ * gimp_color_profile_new_from_icc_profile:
* @data: pointer to memory containing an ICC profile
* @length: lenght of the profile in memory, in bytes
* @error: return location for #GError
@@ -168,60 +241,82 @@ gimp_color_profile_open_from_file (GFile *file,
*
* Since: 2.10
**/
-GimpColorProfile
-gimp_color_profile_open_from_data (const guint8 *data,
- gsize length,
- GError **error)
+GimpColorProfile *
+gimp_color_profile_new_from_icc_profile (const guint8 *data,
+ gsize length,
+ GError **error)
{
- GimpColorProfile profile;
+ cmsHPROFILE lcms_profile;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (length > 0, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- profile = cmsOpenProfileFromMem (data, length);
+ lcms_profile = cmsOpenProfileFromMem (data, length);
+
+ if (lcms_profile)
+ {
+ profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
- if (! profile)
- g_set_error_literal (error, gimp_color_profile_error_quark (), 0,
- _("Data does not appear to be an ICC color profile"));
+ profile->priv->lcms_profile = lcms_profile;
+ profile->priv->data = g_memdup (data, length);
+ profile->priv->length = length;
+ }
+ else
+ {
+ g_set_error_literal (error, gimp_color_profile_error_quark (), 0,
+ _("Data does not appear to be an ICC color profile"));
+ }
return profile;
}
/**
- * gimp_color_profile_dave_to_data:
- * @profile: a #GimpColorProfile
- * @length: return location for the number of bytes written
- * @error: return location for #GError
+ * gimp_color_profile_new_from_lcms_profile:
+ * @lcms_profile: an LCMS cmsHPROFILE pointer
+ * @error: return location for #GError
*
- * This function saves @profile to an ICC color profile in newly
- * allocated memory. On error, %NULL is returned and @error is set.
+ * This function creates a GimpColorProfile from a cmsHPROFILE. On
+ * error, %NULL is returned and @error is set. The passed
+ * @lcms_profile pointer is not retained by the created
+ * #GimpColorProfile.
*
- * Return value: a pointer to the written IIC profile in memory, or
- * %NULL. Free with g_free().
+ * Return value: the #GimpColorProfile, or %NULL.
*
* Since: 2.10
**/
-guint8 *
-gimp_color_profile_save_to_data (GimpColorProfile profile,
- gsize *length,
- GError **error)
+GimpColorProfile *
+gimp_color_profile_new_from_lcms_profile (gpointer lcms_profile,
+ GError **error)
{
cmsUInt32Number size;
- g_return_val_if_fail (profile != NULL, NULL);
- g_return_val_if_fail (length != NULL, NULL);
+ g_return_val_if_fail (lcms_profile != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- if (cmsSaveProfileToMem (profile, NULL, &size))
+ if (cmsSaveProfileToMem (lcms_profile, NULL, &size))
{
guint8 *data = g_malloc (size);
- if (cmsSaveProfileToMem (profile, data, &size))
+ if (cmsSaveProfileToMem (lcms_profile, data, &size))
{
- *length = size;
+ gsize length = size;
+
+ lcms_profile = cmsOpenProfileFromMem (data, length);
+
+ if (lcms_profile)
+ {
+ GimpColorProfile *profile;
+
+ profile = g_object_new (GIMP_TYPE_COLOR_PROFILE, NULL);
- return data;
+ profile->priv->lcms_profile = lcms_profile;
+ profile->priv->data = data;
+ profile->priv->length = length;
+
+ return profile;
+ }
}
g_free (data);
@@ -234,37 +329,65 @@ gimp_color_profile_save_to_data (GimpColorProfile profile,
}
/**
- * gimp_color_profile_close:
+ * gimp_color_profile_get_icc_profile:
* @profile: a #GimpColorProfile
+ * @length: return location for the number of bytes
+ * @error: return location for #GError
*
- * This function closes a #GimpColorProfile and frees its memory.
+ * This function returns @profile as ICC profile data. The returned
+ * memory belongs to @profile and must not be modified or freed.
+ *
+ * Return value: a pointer to the IIC profile data.
*
* Since: 2.10
**/
-void
-gimp_color_profile_close (GimpColorProfile profile)
+const guint8 *
+gimp_color_profile_get_icc_profile (GimpColorProfile *profile,
+ gsize *length)
{
- g_return_if_fail (profile != NULL);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
+ g_return_val_if_fail (length != NULL, NULL);
+
+ *length = profile->priv->length;
- cmsCloseProfile (profile);
+ return profile->priv->data;
+}
+
+/**
+ * gimp_color_profile_get_lcms_profile:
+ * @profile: a #GimpColorProfile
+ *
+ * This function returns @profile's cmsHPROFILE. The returned
+ * value belongs to @profile and must not be modified or freed.
+ *
+ * Return value: a pointer to the cmsHPROFILE.
+ *
+ * Since: 2.10
+ **/
+gpointer
+gimp_color_profile_get_lcms_profile (GimpColorProfile *profile)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
+
+ return profile->priv->lcms_profile;
}
static gchar *
-gimp_color_profile_get_info (GimpColorProfile profile,
- cmsInfoType info)
+gimp_color_profile_get_info (GimpColorProfile *profile,
+ cmsInfoType info)
{
cmsUInt32Number size;
gchar *text = NULL;
- g_return_val_if_fail (profile != NULL, NULL);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
- size = cmsGetProfileInfoASCII (profile, info,
+ size = cmsGetProfileInfoASCII (profile->priv->lcms_profile, info,
"en", "US", NULL, 0);
if (size > 0)
{
gchar *data = g_new (gchar, size + 1);
- size = cmsGetProfileInfoASCII (profile, info,
+ size = cmsGetProfileInfoASCII (profile->priv->lcms_profile, info,
"en", "US", data, size);
if (size > 0)
text = gimp_any_to_utf8 (data, -1, NULL);
@@ -285,7 +408,7 @@ gimp_color_profile_get_info (GimpColorProfile profile,
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_description (GimpColorProfile profile)
+gimp_color_profile_get_description (GimpColorProfile *profile)
{
return gimp_color_profile_get_info (profile, cmsInfoDescription);
}
@@ -300,7 +423,7 @@ gimp_color_profile_get_description (GimpColorProfile profile)
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_manufacturer (GimpColorProfile profile)
+gimp_color_profile_get_manufacturer (GimpColorProfile *profile)
{
return gimp_color_profile_get_info (profile, cmsInfoManufacturer);
}
@@ -315,7 +438,7 @@ gimp_color_profile_get_manufacturer (GimpColorProfile profile)
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_model (GimpColorProfile profile)
+gimp_color_profile_get_model (GimpColorProfile *profile)
{
return gimp_color_profile_get_info (profile, cmsInfoModel);
}
@@ -330,7 +453,7 @@ gimp_color_profile_get_model (GimpColorProfile profile)
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_copyright (GimpColorProfile profile)
+gimp_color_profile_get_copyright (GimpColorProfile *profile)
{
return gimp_color_profile_get_info (profile, cmsInfoCopyright);
}
@@ -348,11 +471,11 @@ gimp_color_profile_get_copyright (GimpColorProfile profile)
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_label (GimpColorProfile profile)
+gimp_color_profile_get_label (GimpColorProfile *profile)
{
gchar *label;
- g_return_val_if_fail (profile != NULL, NULL);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
label = gimp_color_profile_get_description (profile);
@@ -391,12 +514,12 @@ gimp_color_profile_get_label (GimpColorProfile profile)
* Since: 2.10
**/
gchar *
-gimp_color_profile_get_summary (GimpColorProfile profile)
+gimp_color_profile_get_summary (GimpColorProfile *profile)
{
GString *string;
gchar *text;
- g_return_val_if_fail (profile != NULL, NULL);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
string = g_string_new (NULL);
@@ -414,6 +537,7 @@ gimp_color_profile_get_summary (GimpColorProfile profile)
g_string_append (string, "\n");
g_string_append (string, text);
+ g_free (text);
}
text = gimp_color_profile_get_manufacturer (profile);
@@ -423,6 +547,7 @@ gimp_color_profile_get_summary (GimpColorProfile profile)
g_string_append (string, "\n");
g_string_append (string, text);
+ g_free (text);
}
text = gimp_color_profile_get_copyright (profile);
@@ -432,6 +557,7 @@ gimp_color_profile_get_summary (GimpColorProfile profile)
g_string_append (string, "\n");
g_string_append (string, text);
+ g_free (text);
}
return g_string_free (string, FALSE);
@@ -449,23 +575,23 @@ gimp_color_profile_get_summary (GimpColorProfile profile)
* Since: 2.10
**/
gboolean
-gimp_color_profile_is_equal (GimpColorProfile profile1,
- GimpColorProfile profile2)
+gimp_color_profile_is_equal (GimpColorProfile *profile1,
+ GimpColorProfile *profile2)
{
cmsUInt8Number digest1[GIMP_LCMS_MD5_DIGEST_LENGTH];
cmsUInt8Number digest2[GIMP_LCMS_MD5_DIGEST_LENGTH];
- g_return_val_if_fail (profile1 != NULL, FALSE);
- g_return_val_if_fail (profile2 != NULL, FALSE);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile1), FALSE);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile1), FALSE);
- if (! cmsMD5computeID (profile1) ||
- ! cmsMD5computeID (profile2))
+ if (! cmsMD5computeID (profile1->priv->lcms_profile) ||
+ ! cmsMD5computeID (profile2->priv->lcms_profile))
{
return FALSE;
}
- cmsGetHeaderProfileID (profile1, digest1);
- cmsGetHeaderProfileID (profile2, digest2);
+ cmsGetHeaderProfileID (profile1->priv->lcms_profile, digest1);
+ cmsGetHeaderProfileID (profile2->priv->lcms_profile, digest2);
return (memcmp (digest1, digest2, GIMP_LCMS_MD5_DIGEST_LENGTH) == 0);
}
@@ -480,11 +606,11 @@ gimp_color_profile_is_equal (GimpColorProfile profile1,
* Since: 2.10
**/
gboolean
-gimp_color_profile_is_rgb (GimpColorProfile profile)
+gimp_color_profile_is_rgb (GimpColorProfile *profile)
{
- g_return_val_if_fail (profile != NULL, FALSE);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
- return (cmsGetColorSpace (profile) == cmsSigRgbData);
+ return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigRgbData);
}
/**
@@ -497,11 +623,11 @@ gimp_color_profile_is_rgb (GimpColorProfile profile)
* Since: 2.10
**/
gboolean
-gimp_color_profile_is_cmyk (GimpColorProfile profile)
+gimp_color_profile_is_cmyk (GimpColorProfile *profile)
{
- g_return_val_if_fail (profile != NULL, FALSE);
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
- return (cmsGetColorSpace (profile) == cmsSigCmykData);
+ return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigCmykData);
}
static void
@@ -517,10 +643,10 @@ gimp_color_profile_set_tag (cmsHPROFILE profile,
cmsMLUfree (mlu);
}
-static GimpColorProfile
+static cmsHPROFILE *
gimp_color_profile_new_srgb_internal (void)
{
- cmsHPROFILE srgb_profile;
+ cmsHPROFILE profile;
cmsCIExyY d65_srgb_specs = { 0.3127, 0.3290, 1.0 };
cmsCIExyYTRIPLE srgb_primaries_pre_quantized =
@@ -540,19 +666,19 @@ gimp_color_profile_new_srgb_internal (void)
tone_curve[0] = tone_curve[1] = tone_curve[2] = srgb_parametric_curve;
- srgb_profile = cmsCreateRGBProfile (&d65_srgb_specs,
- &srgb_primaries_pre_quantized,
- tone_curve);
+ profile = cmsCreateRGBProfile (&d65_srgb_specs,
+ &srgb_primaries_pre_quantized,
+ tone_curve);
cmsFreeToneCurve (srgb_parametric_curve);
- gimp_color_profile_set_tag (srgb_profile, cmsSigProfileDescriptionTag,
+ gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
"GIMP built-in sRGB");
- gimp_color_profile_set_tag (srgb_profile, cmsSigDeviceMfgDescTag,
+ gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
"GIMP");
- gimp_color_profile_set_tag (srgb_profile, cmsSigDeviceModelDescTag,
+ gimp_color_profile_set_tag (profile, cmsSigDeviceModelDescTag,
"sRGB");
- gimp_color_profile_set_tag (srgb_profile, cmsSigCopyrightTag,
+ gimp_color_profile_set_tag (profile, cmsSigCopyrightTag,
"Public Domain");
/* The following line produces a V2 profile with a point curve TRC.
@@ -565,7 +691,7 @@ gimp_color_profile_new_srgb_internal (void)
* cmsSetProfileVersion (srgb_profile, 2.1);
*/
- return srgb_profile;
+ return profile;
}
/**
@@ -595,32 +721,33 @@ gimp_color_profile_new_srgb_internal (void)
* ArgyllCMS sRGB.icm profile. The resulting sRGB profile's colorants
* exactly matches the ArgyllCMS sRGB.icm profile colorants.
*
- * Return value: the sRGB cmsHPROFILE.
+ * Return value: the sRGB #GimpColorProfile.
*
* Since: 2.10
**/
-GimpColorProfile
+GimpColorProfile *
gimp_color_profile_new_srgb (void)
{
- static guint8 *profile_data = NULL;
- static gsize profile_length = 0;
+ static GimpColorProfile *profile = NULL;
- if (G_UNLIKELY (profile_data == NULL))
- {
- GimpColorProfile profile;
+ const guint8 *data;
+ gsize length;
- profile = gimp_color_profile_new_srgb_internal ();
+ if (G_UNLIKELY (profile == NULL))
+ {
+ cmsHPROFILE lcms_profile = gimp_color_profile_new_srgb_internal ();
- profile_data = gimp_color_profile_save_to_data (profile, &profile_length,
- NULL);
+ profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
- gimp_color_profile_close (profile);
+ cmsCloseProfile (lcms_profile);
}
- return gimp_color_profile_open_from_data (profile_data, profile_length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ return gimp_color_profile_new_from_icc_profile (data, length, NULL);
}
-static GimpColorProfile
+static cmsHPROFILE
gimp_color_profile_new_linear_rgb_internal (void)
{
cmsHPROFILE profile;
@@ -669,29 +796,30 @@ gimp_color_profile_new_linear_rgb_internal (void)
* This function creates a profile for babl_model("RGB"). Please
* somebody write someting smarter here.
*
- * Return value: the linear RGB cmsHPROFILE.
+ * Return value: the linear RGB #GimpColorProfile.
*
* Since: 2.10
**/
-GimpColorProfile
+GimpColorProfile *
gimp_color_profile_new_linear_rgb (void)
{
- static guint8 *profile_data = NULL;
- static gsize profile_length = 0;
+ static GimpColorProfile *profile = NULL;
- if (G_UNLIKELY (profile_data == NULL))
- {
- GimpColorProfile profile;
+ const guint8 *data;
+ gsize length;
- profile = gimp_color_profile_new_linear_rgb_internal ();
+ if (G_UNLIKELY (profile == NULL))
+ {
+ cmsHPROFILE lcms_profile = gimp_color_profile_new_linear_rgb_internal ();
- profile_data = gimp_color_profile_save_to_data (profile, &profile_length,
- NULL);
+ profile = gimp_color_profile_new_from_lcms_profile (lcms_profile, NULL);
- gimp_color_profile_close (profile);
+ cmsCloseProfile (lcms_profile);
}
- return gimp_color_profile_open_from_data (profile_data, profile_length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ return gimp_color_profile_new_from_icc_profile (data, length, NULL);
}
/**
diff --git a/libgimpcolor/gimpcolorprofile.h b/libgimpcolor/gimpcolorprofile.h
index c043075..895501a 100644
--- a/libgimpcolor/gimpcolorprofile.h
+++ b/libgimpcolor/gimpcolorprofile.h
@@ -32,35 +32,70 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-GimpColorProfile gimp_color_profile_open_from_file (GFile *file,
- GError **error);
-GimpColorProfile gimp_color_profile_open_from_data (const guint8 *data,
- gsize length,
- GError **error);
-guint8 * gimp_color_profile_save_to_data (GimpColorProfile profile,
- gsize *length,
- GError **error);
-void gimp_color_profile_close (GimpColorProfile profile);
-
-gchar * gimp_color_profile_get_description (GimpColorProfile profile);
-gchar * gimp_color_profile_get_manufacturer (GimpColorProfile profile);
-gchar * gimp_color_profile_get_model (GimpColorProfile profile);
-gchar * gimp_color_profile_get_copyright (GimpColorProfile profile);
-
-gchar * gimp_color_profile_get_label (GimpColorProfile profile);
-gchar * gimp_color_profile_get_summary (GimpColorProfile profile);
-
-gboolean gimp_color_profile_is_equal (GimpColorProfile profile1,
- GimpColorProfile profile2);
-
-gboolean gimp_color_profile_is_rgb (GimpColorProfile profile);
-gboolean gimp_color_profile_is_cmyk (GimpColorProfile profile);
-
-GimpColorProfile gimp_color_profile_new_srgb (void);
-GimpColorProfile gimp_color_profile_new_linear_rgb (void);
-
-const Babl * gimp_color_profile_get_format (const Babl *format,
- guint32 *lcms_format);
+#define GIMP_TYPE_COLOR_PROFILE (gimp_color_profile_get_type ())
+#define GIMP_COLOR_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_PROFILE,
GimpColorProfile))
+#define GIMP_COLOR_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PROFILE,
GimpColorProfileClass))
+#define GIMP_IS_COLOR_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_PROFILE))
+#define GIMP_IS_COLOR_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PROFILE))
+#define GIMP_COLOR_PROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PROFILE,
GimpColorProfileClass))
+
+
+typedef struct _GimpColorProfileClass GimpColorProfileClass;
+typedef struct _GimpColorProfilePrivate GimpColorProfilePrivate;
+
+struct _GimpColorProfile
+{
+ GObject parent_instance;
+
+ GimpColorProfilePrivate *priv;
+};
+
+struct _GimpColorProfileClass
+{
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (* _gimp_reserved1) (void);
+ void (* _gimp_reserved2) (void);
+ void (* _gimp_reserved3) (void);
+ void (* _gimp_reserved4) (void);
+};
+
+
+GType gimp_color_profile_get_type (void) G_GNUC_CONST;
+
+GimpColorProfile * gimp_color_profile_new_srgb (void);
+GimpColorProfile * gimp_color_profile_new_linear_rgb (void);
+
+GimpColorProfile * gimp_color_profile_new_from_file (GFile *file,
+ GError **error);
+
+GimpColorProfile * gimp_color_profile_new_from_icc_profile (const guint8 *data,
+ gsize length,
+ GError **error);
+GimpColorProfile * gimp_color_profile_new_from_lcms_profile (gpointer lcms_profile,
+ GError **error);
+
+const guint8 * gimp_color_profile_get_icc_profile (GimpColorProfile *profile,
+ gsize *length);
+gpointer gimp_color_profile_get_lcms_profile (GimpColorProfile *profile);
+
+gchar * gimp_color_profile_get_description (GimpColorProfile *profile);
+gchar * gimp_color_profile_get_manufacturer (GimpColorProfile *profile);
+gchar * gimp_color_profile_get_model (GimpColorProfile *profile);
+gchar * gimp_color_profile_get_copyright (GimpColorProfile *profile);
+
+gchar * gimp_color_profile_get_label (GimpColorProfile *profile);
+gchar * gimp_color_profile_get_summary (GimpColorProfile *profile);
+
+gboolean gimp_color_profile_is_equal (GimpColorProfile *profile1,
+ GimpColorProfile *profile2);
+
+gboolean gimp_color_profile_is_rgb (GimpColorProfile *profile);
+gboolean gimp_color_profile_is_cmyk (GimpColorProfile *profile);
+
+const Babl * gimp_color_profile_get_format (const Babl *format,
+ guint32 *lcms_format);
G_END_DECLS
diff --git a/libgimpcolor/gimpcolortypes.h b/libgimpcolor/gimpcolortypes.h
index dc661ca..0022202 100644
--- a/libgimpcolor/gimpcolortypes.h
+++ b/libgimpcolor/gimpcolortypes.h
@@ -29,8 +29,8 @@ G_BEGIN_DECLS
typedef struct _GimpColorManaged GimpColorManaged; /* dummy typedef */
+typedef struct _GimpColorProfile GimpColorProfile;
-typedef gpointer GimpColorProfile;
typedef gpointer GimpColorTransform;
diff --git a/libgimpconfig/gimpcolorconfig.c b/libgimpconfig/gimpcolorconfig.c
index ef61114..5ad5c06 100644
--- a/libgimpconfig/gimpcolorconfig.c
+++ b/libgimpconfig/gimpcolorconfig.c
@@ -370,11 +370,11 @@ gimp_color_config_get_property (GObject *object,
}
}
-GimpColorProfile
+GimpColorProfile *
gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
GError **error)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -383,11 +383,11 @@ gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
{
GFile *file = g_file_new_for_path (config->rgb_profile);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile && ! gimp_color_profile_is_rgb (profile))
{
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
profile = NULL;
g_set_error (error, GIMP_CONFIG_ERROR, 0,
@@ -401,11 +401,11 @@ gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
return profile;
}
-GimpColorProfile
+GimpColorProfile *
gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
GError **error)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -414,11 +414,11 @@ gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
{
GFile *file = g_file_new_for_path (config->cmyk_profile);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile && ! gimp_color_profile_is_cmyk (profile))
{
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
profile = NULL;
g_set_error (error, GIMP_CONFIG_ERROR, 0,
@@ -432,11 +432,11 @@ gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
return profile;
}
-GimpColorProfile
+GimpColorProfile *
gimp_color_config_get_display_color_profile (GimpColorConfig *config,
GError **error)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -445,18 +445,18 @@ gimp_color_config_get_display_color_profile (GimpColorConfig *config,
{
GFile *file = g_file_new_for_path (config->display_profile);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
g_object_unref (file);
}
return profile;
}
-GimpColorProfile
+GimpColorProfile *
gimp_color_config_get_printer_color_profile (GimpColorConfig *config,
GError **error)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -465,7 +465,7 @@ gimp_color_config_get_printer_color_profile (GimpColorConfig *config,
{
GFile *file = g_file_new_for_path (config->printer_profile);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
g_object_unref (file);
}
@@ -484,10 +484,10 @@ gimp_color_config_set_rgb_profile (GimpColorConfig *config,
if (filename)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GFile *file = g_file_new_for_path (filename);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile)
{
@@ -499,7 +499,7 @@ gimp_color_config_set_rgb_profile (GimpColorConfig *config,
success = FALSE;
}
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
{
@@ -525,10 +525,10 @@ gimp_color_config_set_cmyk_profile (GimpColorConfig *config,
if (filename)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GFile *file = g_file_new_for_path (filename);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile)
{
@@ -540,7 +540,7 @@ gimp_color_config_set_cmyk_profile (GimpColorConfig *config,
success = FALSE;
}
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
{
@@ -566,14 +566,14 @@ gimp_color_config_set_display_profile (GimpColorConfig *config,
if (filename)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GFile *file = g_file_new_for_path (filename);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile)
{
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
{
@@ -599,14 +599,14 @@ gimp_color_config_set_printer_profile (GimpColorConfig *config,
if (filename)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GFile *file = g_file_new_for_path (filename);
- profile = gimp_color_profile_open_from_file (file, error);
+ profile = gimp_color_profile_new_from_file (file, error);
if (profile)
{
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
{
diff --git a/libgimpconfig/gimpcolorconfig.h b/libgimpconfig/gimpcolorconfig.h
index 7b68df1..ef0a3d8 100644
--- a/libgimpconfig/gimpcolorconfig.h
+++ b/libgimpconfig/gimpcolorconfig.h
@@ -77,16 +77,16 @@ struct _GimpColorConfigClass
};
-GType gimp_color_config_get_type (void) G_GNUC_CONST;
-
-GimpColorProfile gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
- GError **error);
-GimpColorProfile gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
- GError **error);
-GimpColorProfile gimp_color_config_get_display_color_profile (GimpColorConfig *config,
- GError **error);
-GimpColorProfile gimp_color_config_get_printer_color_profile (GimpColorConfig *config,
- GError **error);
+GType gimp_color_config_get_type (void) G_GNUC_CONST;
+
+GimpColorProfile * gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
+ GError **error);
+GimpColorProfile * gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
+ GError **error);
+GimpColorProfile * gimp_color_config_get_display_color_profile (GimpColorConfig *config,
+ GError **error);
+GimpColorProfile * gimp_color_config_get_printer_color_profile (GimpColorConfig *config,
+ GError **error);
#endif /* GIMP_COLOR_CONFIG_H__ */
diff --git a/libgimpwidgets/gimpcolorprofilechooserdialog.c b/libgimpwidgets/gimpcolorprofilechooserdialog.c
index 343e329..1d029a3 100644
--- a/libgimpwidgets/gimpcolorprofilechooserdialog.c
+++ b/libgimpwidgets/gimpcolorprofilechooserdialog.c
@@ -183,7 +183,7 @@ gimp_color_profile_chooser_dialog_add_shortcut (GimpColorProfileChooserDialog *d
static void
gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog *dialog)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GFile *file;
GError *error = NULL;
@@ -198,7 +198,7 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
switch (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL))
{
case G_FILE_TYPE_REGULAR:
- profile = gimp_color_profile_open_from_file (file, &error);
+ profile = gimp_color_profile_new_from_file (file, &error);
if (! profile)
{
@@ -210,7 +210,7 @@ gimp_color_profile_chooser_dialog_update_preview (GimpColorProfileChooserDialog
{
gimp_color_profile_view_set_profile (dialog->priv->profile_view,
profile);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
break;
diff --git a/libgimpwidgets/gimpcolorprofilecombobox.c b/libgimpwidgets/gimpcolorprofilecombobox.c
index d5b5042..1a75b19 100644
--- a/libgimpwidgets/gimpcolorprofilecombobox.c
+++ b/libgimpwidgets/gimpcolorprofilecombobox.c
@@ -424,11 +424,11 @@ gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo,
if (filename && ! (label && *label))
{
GFile *file;
- GimpColorProfile profile;
+ GimpColorProfile *profile;
GError *error = NULL;
file = g_file_new_for_path (filename);
- profile = gimp_color_profile_open_from_file (file, &error);
+ profile = gimp_color_profile_new_from_file (file, &error);
g_object_unref (file);
if (! profile)
@@ -439,7 +439,7 @@ gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo,
else
{
l = gimp_color_profile_get_label (profile);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
}
else
diff --git a/libgimpwidgets/gimpcolorprofileview.c b/libgimpwidgets/gimpcolorprofileview.c
index d267a60..68b138d 100644
--- a/libgimpwidgets/gimpcolorprofileview.c
+++ b/libgimpwidgets/gimpcolorprofileview.c
@@ -34,11 +34,12 @@
struct _GimpColorProfileViewPrivate
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
};
static void gimp_color_profile_view_constructed (GObject *object);
+static void gimp_color_profile_view_finalize (GObject *object);
G_DEFINE_TYPE (GimpColorProfileView, gimp_color_profile_view,
@@ -53,6 +54,7 @@ gimp_color_profile_view_class_init (GimpColorProfileViewClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gimp_color_profile_view_constructed;
+ object_class->finalize = gimp_color_profile_view_finalize;
g_type_class_add_private (klass, sizeof (GimpColorProfileViewPrivate));
}
@@ -90,6 +92,20 @@ gimp_color_profile_view_constructed (GObject *object)
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (object), 6);
}
+static void
+gimp_color_profile_view_finalize (GObject *object)
+{
+ GimpColorProfileView *view = GIMP_COLOR_PROFILE_VIEW (object);
+
+ if (view->priv->profile)
+ {
+ g_object_unref (view->priv->profile);
+ view->priv->profile = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
GtkWidget *
gimp_color_profile_view_new (void)
{
@@ -98,42 +114,52 @@ gimp_color_profile_view_new (void)
void
gimp_color_profile_view_set_profile (GimpColorProfileView *view,
- GimpColorProfile profile)
+ GimpColorProfile *profile)
{
GtkTextBuffer *buffer;
- GtkTextIter iter;
- gchar *label;
- gchar *summary;
g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view));
+ g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
+
+ if (profile == view->priv->profile)
+ return;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "", 0);
+ if (view->priv->profile)
+ g_object_unref (view->priv->profile);
+
view->priv->profile = profile;
- if (! profile)
- return;
+ if (view->priv->profile)
+ {
+ GtkTextIter iter;
+ gchar *label;
+ gchar *summary;
- gtk_text_buffer_get_start_iter (buffer, &iter);
+ g_object_ref (view->priv->profile);
- label = gimp_color_profile_get_label (profile);
- summary = gimp_color_profile_get_summary (profile);
+ gtk_text_buffer_get_start_iter (buffer, &iter);
- if (label && strlen (label))
- {
- gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
- label, -1,
- "strong", NULL);
- gtk_text_buffer_insert (buffer, &iter, "\n", 1);
- }
+ label = gimp_color_profile_get_label (profile);
+ summary = gimp_color_profile_get_summary (profile);
- if (summary)
- gtk_text_buffer_insert (buffer, &iter, summary, -1);
+ if (label && strlen (label))
+ {
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
+ label, -1,
+ "strong", NULL);
+ gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+ }
- g_free (label);
- g_free (summary);
+ if (summary)
+ gtk_text_buffer_insert (buffer, &iter, summary, -1);
+
+ g_free (label);
+ g_free (summary);
+ }
}
void
diff --git a/libgimpwidgets/gimpcolorprofileview.h b/libgimpwidgets/gimpcolorprofileview.h
index 71a7724..bccffe0 100644
--- a/libgimpwidgets/gimpcolorprofileview.h
+++ b/libgimpwidgets/gimpcolorprofileview.h
@@ -59,7 +59,7 @@ GType gimp_color_profile_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_view_new (void);
void gimp_color_profile_view_set_profile (GimpColorProfileView *view,
- GimpColorProfile profile);
+ GimpColorProfile *profile);
void gimp_color_profile_view_set_error (GimpColorProfileView *view,
const gchar *message);
diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c
index 55920ac..bd211a8 100644
--- a/libgimpwidgets/gimpwidgetsutils.c
+++ b/libgimpwidgets/gimpwidgetsutils.c
@@ -352,10 +352,10 @@ gimp_get_monitor_at_pointer (GdkScreen **screen)
return gdk_screen_get_monitor_at_point (*screen, x, y);
}
-GimpColorProfile
+GimpColorProfile *
gimp_widget_get_color_profile (GtkWidget *widget)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
GdkScreen *screen;
gint monitor;
@@ -391,7 +391,8 @@ gimp_widget_get_color_profile (GtkWidget *widget)
0, 64 * 1024 * 1024, FALSE,
&type, &format, &nitems, &data) && nitems > 0)
{
- profile = gimp_color_profile_open_from_data (data, nitems, NULL);
+ profile = gimp_color_profile_new_from_icc_profile (data, nitems,
+ NULL);
g_free (data);
}
@@ -421,9 +422,9 @@ gimp_widget_get_color_profile (GtkWidget *widget)
CFDataGetBytes (data, CFRangeMake (0, CFDataGetLength (data)),
buffer);
- profile = gimp_color_profile_open_from_data (data,
- CFDataGetLength (data),
- NULL);
+ profile = gimp_color_profile_new_from_icc_profile (data,
+ CFDataGetLength (data),
+ NULL);
g_free (buffer);
CFRelease (data);
@@ -446,7 +447,7 @@ gimp_widget_get_color_profile (GtkWidget *widget)
{
GFile *file = g_file_new_for_path (path);
- profile = gimp_color_profile_open_from_file (file, NULL);
+ profile = gimp_color_profile_new_from_file (file, NULL);
g_object_unref (file);
}
@@ -459,11 +460,11 @@ gimp_widget_get_color_profile (GtkWidget *widget)
return profile;
}
-static GimpColorProfile
+static GimpColorProfile *
get_display_profile (GtkWidget *widget,
GimpColorConfig *config)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
if (config->display_profile_from_gdk)
profile = gimp_widget_get_color_profile (widget);
@@ -484,13 +485,15 @@ gimp_widget_get_color_transform (GtkWidget *widget,
const Babl **src_format,
const Babl **dest_format)
{
- GimpColorTransform transform = NULL;
- GimpColorProfile src_profile = NULL;
- GimpColorProfile dest_profile = NULL;
- GimpColorProfile proof_profile = NULL;
- cmsUInt32Number lcms_src_format;
- cmsUInt32Number lcms_dest_format;
- cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0, };
+ GimpColorTransform transform = NULL;
+ GimpColorProfile *src_profile = NULL;
+ GimpColorProfile *dest_profile = NULL;
+ GimpColorProfile *proof_profile = NULL;
+ cmsHPROFILE src_lcms;
+ cmsHPROFILE dest_lcms;
+ cmsUInt32Number lcms_src_format;
+ cmsUInt32Number lcms_dest_format;
+ cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0, };
g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (GIMP_IS_COLOR_MANAGED (managed), NULL);
@@ -513,13 +516,19 @@ gimp_widget_get_color_transform (GtkWidget *widget,
break;
}
+ src_lcms = gimp_color_profile_get_lcms_profile (src_profile);
+ dest_lcms = gimp_color_profile_get_lcms_profile (dest_profile);
+
*src_format = gimp_color_profile_get_format (*src_format, &lcms_src_format);
*dest_format = gimp_color_profile_get_format (*dest_format, &lcms_dest_format);
if (proof_profile)
{
+ cmsHPROFILE proof_lcms;
cmsUInt32Number softproof_flags = cmsFLAGS_SOFTPROOFING;
+ proof_lcms = gimp_color_profile_get_lcms_profile (proof_profile);
+
if (config->simulation_use_black_point_compensation)
{
softproof_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
@@ -540,14 +549,14 @@ gimp_widget_get_color_transform (GtkWidget *widget,
cmsSetAlarmCodes (alarmCodes);
}
- transform = cmsCreateProofingTransform (src_profile, lcms_src_format,
- dest_profile, lcms_dest_format,
- proof_profile,
+ transform = cmsCreateProofingTransform (src_lcms, lcms_src_format,
+ dest_lcms, lcms_dest_format,
+ proof_lcms,
config->simulation_intent,
config->display_intent,
softproof_flags);
- gimp_color_profile_close (proof_profile);
+ g_object_unref (proof_profile);
}
else if (! gimp_color_profile_is_equal (src_profile, dest_profile))
{
@@ -558,14 +567,14 @@ gimp_widget_get_color_transform (GtkWidget *widget,
display_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
}
- transform = cmsCreateTransform (src_profile, lcms_src_format,
- dest_profile, lcms_dest_format,
+ transform = cmsCreateTransform (src_lcms, lcms_src_format,
+ dest_lcms, lcms_dest_format,
config->display_intent,
display_flags);
}
- gimp_color_profile_close (src_profile);
- gimp_color_profile_close (dest_profile);
+ g_object_unref (src_profile);
+ g_object_unref (dest_profile);
return transform;
}
diff --git a/libgimpwidgets/gimpwidgetsutils.h b/libgimpwidgets/gimpwidgetsutils.h
index 80da51d..8cbc44f 100644
--- a/libgimpwidgets/gimpwidgetsutils.h
+++ b/libgimpwidgets/gimpwidgetsutils.h
@@ -30,29 +30,29 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-GtkWidget * gimp_table_attach_aligned (GtkTable *table,
- gint column,
- gint row,
- const gchar *label_text,
- gfloat xalign,
- gfloat yalign,
- GtkWidget *widget,
- gint colspan,
- gboolean left_align);
-
-void gimp_label_set_attributes (GtkLabel *label,
- ...);
-
-gint gimp_widget_get_monitor (GtkWidget *widget);
-gint gimp_get_monitor_at_pointer (GdkScreen **screen);
-
-GimpColorProfile gimp_widget_get_color_profile (GtkWidget *widget);
-
-GimpColorTransform gimp_widget_get_color_transform (GtkWidget *widget,
- GimpColorManaged *managed,
- GimpColorConfig *config,
- const Babl **src_format,
- const Babl **dest_format);
+GtkWidget * gimp_table_attach_aligned (GtkTable *table,
+ gint column,
+ gint row,
+ const gchar *label_text,
+ gfloat xalign,
+ gfloat yalign,
+ GtkWidget *widget,
+ gint colspan,
+ gboolean left_align);
+
+void gimp_label_set_attributes (GtkLabel *label,
+ ...);
+
+gint gimp_widget_get_monitor (GtkWidget *widget);
+gint gimp_get_monitor_at_pointer (GdkScreen **screen);
+
+GimpColorProfile * gimp_widget_get_color_profile (GtkWidget *widget);
+
+GimpColorTransform gimp_widget_get_color_transform (GtkWidget *widget,
+ GimpColorManaged *managed,
+ GimpColorConfig *config,
+ const Babl **src_format,
+ const Babl **dest_format);
G_END_DECLS
diff --git a/modules/color-selector-cmyk.c b/modules/color-selector-cmyk.c
index 7aa1e5a..e24754a 100644
--- a/modules/color-selector-cmyk.c
+++ b/modules/color-selector-cmyk.c
@@ -353,8 +353,10 @@ 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;
+ GimpColorProfile *rgb_profile = NULL;
+ GimpColorProfile *cmyk_profile = NULL;
+ cmsHPROFILE rgb_lcms;
+ cmsHPROFILE cmyk_lcms;
gchar *label;
gchar *summary;
gchar *text;
@@ -397,28 +399,31 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
g_free (label);
g_free (summary);
+ rgb_lcms = gimp_color_profile_get_lcms_profile (rgb_profile);
+ cmyk_lcms = gimp_color_profile_get_lcms_profile (cmyk_profile);
+
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,
+ module->rgb2cmyk = cmsCreateTransform (rgb_lcms, TYPE_RGB_DBL,
+ cmyk_lcms, TYPE_CMYK_DBL,
config->display_intent,
flags);
- module->cmyk2rgb = cmsCreateTransform (cmyk_profile, TYPE_CMYK_DBL,
- rgb_profile, TYPE_RGB_DBL,
+ module->cmyk2rgb = cmsCreateTransform (cmyk_lcms, TYPE_CMYK_DBL,
+ rgb_lcms, TYPE_RGB_DBL,
config->display_intent,
flags);
out:
if (rgb_profile)
- gimp_color_profile_close (rgb_profile);
+ g_object_unref (rgb_profile);
if (cmyk_profile)
- gimp_color_profile_close (cmyk_profile);
+ g_object_unref (cmyk_profile);
if (! module->in_destruction)
colorsel_cmyk_set_color (selector, &selector->rgb, &selector->hsv);
diff --git a/modules/display-filter-lcms.c b/modules/display-filter-lcms.c
index ce05195..b8a5c75 100644
--- a/modules/display-filter-lcms.c
+++ b/modules/display-filter-lcms.c
@@ -73,27 +73,27 @@ struct _CdisplayLcmsClass
};
-GType cdisplay_lcms_get_type (void);
+GType cdisplay_lcms_get_type (void);
-static void cdisplay_lcms_finalize (GObject *object);
+static void cdisplay_lcms_finalize (GObject *object);
-static GtkWidget * cdisplay_lcms_configure (GimpColorDisplay *display);
-static void cdisplay_lcms_convert_buffer (GimpColorDisplay *display,
- GeglBuffer *buffer,
- GeglRectangle *area);
-static void cdisplay_lcms_changed (GimpColorDisplay *display);
+static GtkWidget * cdisplay_lcms_configure (GimpColorDisplay *display);
+static void cdisplay_lcms_convert_buffer (GimpColorDisplay *display,
+ GeglBuffer *buffer,
+ GeglRectangle *area);
+static void cdisplay_lcms_changed (GimpColorDisplay *display);
-static GimpColorProfile cdisplay_lcms_get_display_profile (CdisplayLcms *lcms);
+static GimpColorProfile * cdisplay_lcms_get_display_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 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 =
@@ -284,13 +284,13 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
&lcms->dest_format);
}
-static GimpColorProfile
+static GimpColorProfile *
cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
{
GimpColorConfig *config;
GimpColorManaged *managed;
GtkWidget *widget = NULL;
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms));
managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms));
@@ -342,7 +342,7 @@ cdisplay_lcms_update_profile_label (CdisplayLcms *lcms,
GimpColorConfig *config;
GimpColorManaged *managed;
GtkWidget *label;
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
gchar *text;
gchar *tooltip;
@@ -389,7 +389,7 @@ cdisplay_lcms_update_profile_label (CdisplayLcms *lcms,
g_free (tooltip);
if (profile)
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
static void
diff --git a/modules/display-filter-proof.c b/modules/display-filter-proof.c
index 4b96292..640a230 100644
--- a/modules/display-filter-proof.c
+++ b/modules/display-filter-proof.c
@@ -323,8 +323,8 @@ static void
cdisplay_proof_changed (GimpColorDisplay *display)
{
CdisplayProof *proof = CDISPLAY_PROOF (display);
- GimpColorProfile rgb_profile;
- GimpColorProfile proof_profile;
+ GimpColorProfile *rgb_profile;
+ GimpColorProfile *proof_profile;
GFile *file;
if (proof->transform)
@@ -339,25 +339,30 @@ cdisplay_proof_changed (GimpColorDisplay *display)
rgb_profile = gimp_color_profile_new_srgb ();
file = g_file_new_for_path (proof->profile);
- proof_profile = gimp_color_profile_open_from_file (file, NULL);
+ proof_profile = gimp_color_profile_new_from_file (file, NULL);
g_object_unref (file);
if (proof_profile)
{
+ cmsHPROFILE rgb_lcms;
+ cmsHPROFILE proof_lcms;
cmsUInt32Number flags = cmsFLAGS_SOFTPROOFING;
+ rgb_lcms = gimp_color_profile_get_lcms_profile (rgb_profile);
+ proof_lcms = gimp_color_profile_get_lcms_profile (proof_profile);
+
if (proof->bpc)
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- proof->transform = cmsCreateProofingTransform (rgb_profile, TYPE_RGBA_FLT,
- rgb_profile, TYPE_RGBA_FLT,
- proof_profile,
+ proof->transform = cmsCreateProofingTransform (rgb_lcms, TYPE_RGBA_FLT,
+ rgb_lcms, TYPE_RGBA_FLT,
+ proof_lcms,
proof->intent,
proof->intent,
flags);
- gimp_color_profile_close (proof_profile);
+ g_object_unref (proof_profile);
}
- gimp_color_profile_close (rgb_profile);
+ g_object_unref (rgb_profile);
}
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 977d822..ef78dd8 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -143,7 +143,6 @@ libexec_PROGRAMS = \
web-browser \
$(WEB_PAGE)
-
EXTRA_PROGRAMS = \
file-aa \
file-jp2-load \
@@ -1432,8 +1431,6 @@ jigsaw_LDADD = \
$(INTLLIBS) \
$(jigsaw_RC)
-lcms_CFLAGS = $(LCMS_CFLAGS)
-
lcms_SOURCES = \
lcms.c
@@ -1448,7 +1445,6 @@ lcms_LDADD = \
$(libgimpbase) \
$(GTK_LIBS) \
$(GEGL_LIBS) \
- $(LCMS_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(lcms_RC)
diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c
index b5d55f6..5fa877b 100644
--- a/plug-ins/common/lcms.c
+++ b/plug-ins/common/lcms.c
@@ -22,8 +22,6 @@
#include <string.h>
-#include <lcms2.h>
-
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
@@ -69,29 +67,29 @@ static void run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals);
-static GimpPDBStatusType lcms_icc_set (GimpColorConfig *config,
- gint32 image,
- GFile *file);
-static GimpPDBStatusType lcms_icc_apply (GimpColorConfig *config,
- GimpRunMode run_mode,
- gint32 image,
- GFile *file,
+static GimpPDBStatusType lcms_icc_set (GimpColorConfig *config,
+ gint32 image,
+ GFile *file);
+static GimpPDBStatusType lcms_icc_apply (GimpColorConfig *config,
+ GimpRunMode run_mode,
+ gint32 image,
+ GFile *file,
GimpColorRenderingIntent intent,
- gboolean bpc,
- gboolean *dont_ask);
+ gboolean bpc,
+ gboolean *dont_ask);
-static gboolean lcms_image_set_profile (gint32 image,
- GFile *file);
+static gboolean lcms_image_set_profile (gint32 image,
+ GFile *file);
-static gboolean lcms_icc_apply_dialog (gint32 image,
- cmsHPROFILE src_profile,
- cmsHPROFILE dest_profile,
- gboolean *dont_ask);
+static gboolean lcms_icc_apply_dialog (gint32 image,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
+ gboolean *dont_ask);
-static GimpPDBStatusType lcms_dialog (GimpColorConfig *config,
- gint32 image,
- gboolean apply,
- LcmsValues *values);
+static GimpPDBStatusType lcms_dialog (GimpColorConfig *config,
+ gint32 image,
+ gboolean apply,
+ LcmsValues *values);
static const GimpParamDef set_args[] =
@@ -384,9 +382,9 @@ lcms_icc_apply (GimpColorConfig *config,
gboolean bpc,
gboolean *dont_ask)
{
- GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- GimpColorProfile src_profile = NULL;
- GimpColorProfile dest_profile = NULL;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ GimpColorProfile *src_profile = NULL;
+ GimpColorProfile *dest_profile = NULL;
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);
@@ -400,7 +398,7 @@ lcms_icc_apply (GimpColorConfig *config,
{
GError *error = NULL;
- dest_profile = gimp_color_profile_open_from_file (file, &error);
+ dest_profile = gimp_color_profile_new_from_file (file, &error);
if (! dest_profile)
{
@@ -415,7 +413,7 @@ lcms_icc_apply (GimpColorConfig *config,
g_message (_("Color profile '%s' is not for RGB color space."),
gimp_file_get_utf8_name (file));
- gimp_color_profile_close (dest_profile);
+ g_object_unref (dest_profile);
g_object_unref (file);
return GIMP_PDB_EXECUTION_ERROR;
}
@@ -431,8 +429,8 @@ lcms_icc_apply (GimpColorConfig *config,
gchar *src_label = gimp_color_profile_get_label (src_profile);
gchar *dest_label = gimp_color_profile_get_label (dest_profile);
- gimp_color_profile_close (src_profile);
- gimp_color_profile_close (dest_profile);
+ g_object_unref (src_profile);
+ g_object_unref (dest_profile);
g_printerr ("lcms: skipping conversion because profiles seem to be equal:\n");
g_printerr (" %s\n", src_label);
@@ -459,8 +457,8 @@ lcms_icc_apply (GimpColorConfig *config,
status = GIMP_PDB_EXECUTION_ERROR;
}
- gimp_color_profile_close (src_profile);
- gimp_color_profile_close (dest_profile);
+ g_object_unref (src_profile);
+ g_object_unref (dest_profile);
if (file)
g_object_unref (file);
@@ -472,7 +470,7 @@ static gboolean
lcms_image_set_profile (gint32 image,
GFile *file)
{
- GimpColorProfile profile = NULL;
+ GimpColorProfile *profile = NULL;
g_return_val_if_fail (image != -1, FALSE);
@@ -480,7 +478,7 @@ lcms_image_set_profile (gint32 image,
{
GError *error = NULL;
- profile = gimp_color_profile_open_from_file (file, &error);
+ profile = gimp_color_profile_new_from_file (file, &error);
if (! profile)
{
@@ -499,14 +497,14 @@ lcms_image_set_profile (gint32 image,
gimp_image_undo_group_end (image);
if (profile)
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
return TRUE;
}
static GtkWidget *
-lcms_icc_profile_src_label_new (gint32 image,
- cmsHPROFILE profile)
+lcms_icc_profile_src_label_new (gint32 image,
+ GimpColorProfile *profile)
{
GtkWidget *vbox;
GtkWidget *label;
@@ -553,7 +551,7 @@ lcms_icc_profile_src_label_new (gint32 image,
}
static GtkWidget *
-lcms_icc_profile_dest_label_new (cmsHPROFILE profile)
+lcms_icc_profile_dest_label_new (GimpColorProfile *profile)
{
GtkWidget *label;
gchar *name;
@@ -577,10 +575,10 @@ lcms_icc_profile_dest_label_new (cmsHPROFILE profile)
}
static gboolean
-lcms_icc_apply_dialog (gint32 image,
- cmsHPROFILE src_profile,
- cmsHPROFILE dest_profile,
- gboolean *dont_ask)
+lcms_icc_apply_dialog (gint32 image,
+ GimpColorProfile *src_profile,
+ GimpColorProfile *dest_profile,
+ gboolean *dont_ask)
{
GtkWidget *dialog;
GtkWidget *vbox;
@@ -651,14 +649,14 @@ static GtkWidget *
lcms_icc_combo_box_new (GimpColorConfig *config,
const gchar *filename)
{
- GtkWidget *combo;
- GtkWidget *dialog;
- gchar *history;
- gchar *label;
- gchar *name;
- const gchar *rgb_filename = NULL;
- cmsHPROFILE profile = NULL;
- GError *error = NULL;
+ GtkWidget *combo;
+ GtkWidget *dialog;
+ gchar *history;
+ gchar *label;
+ gchar *name;
+ const gchar *rgb_filename = NULL;
+ GimpColorProfile *profile = NULL;
+ GError *error = NULL;
dialog = gimp_color_profile_chooser_dialog_new (_("Select destination profile"));
@@ -685,7 +683,7 @@ lcms_icc_combo_box_new (GimpColorConfig *config,
label = g_strdup_printf (_("RGB workspace (%s)"), name);
g_free (name);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
rgb_filename, label);
@@ -709,7 +707,7 @@ lcms_dialog (GimpColorConfig *config,
GtkWidget *frame;
GtkWidget *label;
GtkWidget *combo;
- GimpColorProfile src_profile;
+ GimpColorProfile *src_profile;
gchar *name;
gboolean success = FALSE;
gboolean run;
@@ -813,7 +811,7 @@ lcms_dialog (GimpColorConfig *config,
{
gchar *filename = gimp_color_profile_combo_box_get_active (box);
GFile *file = NULL;
- GimpColorProfile dest_profile;
+ GimpColorProfile *dest_profile;
gtk_widget_set_sensitive (dialog, FALSE);
@@ -827,7 +825,7 @@ lcms_dialog (GimpColorConfig *config,
{
GError *error = NULL;
- dest_profile = gimp_color_profile_open_from_file (file, &error);
+ dest_profile = gimp_color_profile_new_from_file (file, &error);
if (! dest_profile)
{
@@ -857,7 +855,7 @@ lcms_dialog (GimpColorConfig *config,
g_message (_("Destination profile is not for RGB color space."));
}
- gimp_color_profile_close (dest_profile);
+ g_object_unref (dest_profile);
}
if (file)
@@ -871,7 +869,7 @@ lcms_dialog (GimpColorConfig *config,
gtk_widget_destroy (dialog);
- gimp_color_profile_close (src_profile);
+ g_object_unref (src_profile);
return (run ?
(success ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR) :
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 40a681d..02ac04e 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -70,7 +70,7 @@
'guillotine' => {},
'hot' => { ui => 1 },
'jigsaw' => { ui => 1 },
- 'lcms' => { ui => 1, gegl => 1, libs => 'LCMS_LIBS', cflags => 'LCMS_CFLAGS' },
+ 'lcms' => { ui => 1, gegl => 1 },
'mail' => { ui => 1, optional => 1 },
'max-rgb' => { ui => 1 },
'metadata' => { ui => 1, libs => 'GEXIV2_LIBS', cflags => 'GEXIV2_CFLAGS' },
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index a24d571..57990c4 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -596,21 +596,23 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
gsize profile_len)
{
GimpColorConfig *config = gimp_get_color_configuration ();
- GimpColorProfile cmyk_profile = NULL;
- GimpColorProfile rgb_profile = NULL;
+ GimpColorProfile *cmyk_profile = NULL;
+ GimpColorProfile *rgb_profile = NULL;
+ cmsHPROFILE cmyk_lcms;
+ cmsHPROFILE rgb_lcms;
cmsUInt32Number flags = 0;
cmsHTRANSFORM transform;
/* try to load the embedded CMYK profile */
if (profile_data)
{
- cmyk_profile = gimp_color_profile_open_from_data (profile_data,
- profile_len,
- NULL);
+ cmyk_profile = gimp_color_profile_new_from_icc_profile (profile_data,
+ profile_len,
+ NULL);
if (cmyk_profile && ! gimp_color_profile_is_cmyk (cmyk_profile))
{
- gimp_color_profile_close (cmyk_profile);
+ g_object_unref (cmyk_profile);
cmyk_profile = NULL;
}
}
@@ -633,19 +635,22 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
if (! rgb_profile)
rgb_profile = gimp_color_profile_new_srgb ();
+ cmyk_lcms = gimp_color_profile_get_lcms_profile (cmyk_profile);
+ rgb_lcms = gimp_color_profile_get_lcms_profile (rgb_profile);
+
if (config->display_intent ==
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC)
{
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
}
- transform = cmsCreateTransform (cmyk_profile, TYPE_CMYK_8_REV,
- rgb_profile, TYPE_RGB_8,
+ transform = cmsCreateTransform (cmyk_lcms, TYPE_CMYK_8_REV,
+ rgb_lcms, TYPE_RGB_8,
config->display_intent,
flags);
- gimp_color_profile_close (cmyk_profile);
- gimp_color_profile_close (rgb_profile);
+ g_object_unref (cmyk_profile);
+ g_object_unref (rgb_profile);
g_object_unref (config);
diff --git a/tools/pdbgen/pdb/image_color_profile.pdb b/tools/pdbgen/pdb/image_color_profile.pdb
index e72097f..976ae46 100644
--- a/tools/pdbgen/pdb/image_color_profile.pdb
+++ b/tools/pdbgen/pdb/image_color_profile.pdb
@@ -41,18 +41,21 @@ HELP
%invoke = (
code => <<'CODE'
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
profile = gimp_image_get_color_profile (image);
if (profile)
{
- gsize length;
+ const guint8 *data;
+ gsize length;
- profile_data = gimp_color_profile_save_to_data (profile, &length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ profile_data = g_memdup (data, length);
num_bytes = length;
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
}
CODE
@@ -83,15 +86,16 @@ HELP
{
if (color_profile)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (color_profile, num_bytes,
- error);
+ profile = gimp_color_profile_new_from_icc_profile (color_profile,
+ num_bytes,
+ error);
if (profile)
{
success = gimp_image_set_color_profile (image, profile, error);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
else
success = FALSE;
@@ -134,15 +138,18 @@ HELP
%invoke = (
code => <<'CODE'
{
- GimpColorProfile profile;
- gsize length;
+ GimpColorProfile *profile;
+ const guint8 *data;
+ gsize length;
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
- profile_data = gimp_color_profile_save_to_data (profile, &length, NULL);
+ data = gimp_color_profile_get_icc_profile (profile, &length);
+
+ profile_data = g_memdup (data, length);
num_bytes = length;
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
CODE
);
@@ -177,16 +184,18 @@ HELP
{
if (color_profile)
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
- profile = gimp_color_profile_open_from_data (color_profile, num_bytes,
- error);
+ profile = gimp_color_profile_new_from_icc_profile (color_profile,
+ num_bytes,
+ error);
if (profile)
{
success = gimp_image_convert_color_profile (image, profile,
intent, bpc,
progress, error);
+ g_object_unref (profile);
}
else
success = FALSE;
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 2034bb8..a646322 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -1780,7 +1780,7 @@ HELP
%invoke = (
code => <<'CODE'
{
- GimpColorProfile profile;
+ GimpColorProfile *profile;
profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
@@ -1788,7 +1788,7 @@ HELP
profile_desc = gimp_color_profile_get_description (profile);
profile_info = gimp_color_profile_get_summary (profile);
- gimp_color_profile_close (profile);
+ g_object_unref (profile);
}
CODE
@@ -1826,9 +1826,9 @@ HELP
if (file)
{
- GimpColorProfile p;
+ GimpColorProfile *p;
- p = gimp_color_profile_open_from_file (file, error);
+ p = gimp_color_profile_new_from_file (file, error);
g_object_unref (file);
if (p)
@@ -1837,7 +1837,7 @@ HELP
profile_desc = gimp_color_profile_get_description (p);
profile_info = gimp_color_profile_get_summary (p);
- gimp_color_profile_close (p);
+ g_object_unref (p);
}
else
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]