[gimp] app: add gimp_image_get_profile() which returns a cmsHPROFILE
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_image_get_profile() which returns a cmsHPROFILE
- Date: Mon, 17 Mar 2014 01:31:12 +0000 (UTC)
commit 89e0c04d1319d69b8baa43d113cb4cc67b74d204
Author: Michael Natterer <mitch gimp org>
Date: Mon Mar 17 02:28:36 2014 +0100
app: add gimp_image_get_profile() which returns a cmsHPROFILE
app/core/gimpimage-profile.c | 129 ++++++++++++++++++++++++++++++++++++
app/core/gimpimage-profile.h | 34 ++++++++++
app/widgets/gimpimageprofileview.c | 43 ++----------
po/POTFILES.in | 3 +-
4 files changed, 172 insertions(+), 37 deletions(-)
---
diff --git a/app/core/gimpimage-profile.c b/app/core/gimpimage-profile.c
new file mode 100644
index 0000000..883fec8
--- /dev/null
+++ b/app/core/gimpimage-profile.c
@@ -0,0 +1,129 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <glib.h> /* lcms.h uses the "inline" keyword */
+
+#include <lcms2.h>
+
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gegl.h>
+
+#include "libgimpconfig/gimpconfig.h"
+#include "libgimpcolor/gimpcolor.h"
+#include "libgimpbase/gimpbase.h"
+
+#include "core-types.h"
+
+#include "config/gimpcoreconfig.h"
+
+#include "core/gimp.h"
+#include "gimperror.h"
+#include "gimpimage.h"
+#include "gimpimage-profile.h"
+
+#include "gimp-intl.h"
+
+
+/* public functions */
+
+const GimpParasite *
+gimp_image_get_icc_profile (GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return gimp_image_parasite_find (image, GIMP_ICC_PROFILE_PARASITE_NAME);
+}
+
+void
+gimp_image_set_icc_profile (GimpImage *image,
+ const GimpParasite *icc_profile)
+{
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+
+ if (icc_profile)
+ {
+ g_return_if_fail (strcmp (gimp_parasite_name (icc_profile),
+ GIMP_ICC_PROFILE_PARASITE_NAME) == 0);
+ g_return_if_fail (gimp_parasite_flags (icc_profile) ==
+ (GIMP_PARASITE_PERSISTENT |
+ GIMP_PARASITE_UNDOABLE));
+
+ gimp_image_parasite_attach (image, icc_profile);
+ }
+ else
+ {
+ gimp_image_parasite_detach (image, GIMP_ICC_PROFILE_PARASITE_NAME);
+ }
+}
+
+GimpColorProfile
+gimp_image_get_profile (GimpImage *image,
+ guint8 *md5_digest,
+ GError **error)
+{
+ GimpColorConfig *config;
+ const GimpParasite *parasite;
+ GimpColorProfile *profile = NULL;
+
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ config = image->gimp->config->color_management;
+
+ parasite = gimp_image_get_icc_profile (image);
+
+ if (parasite)
+ {
+ profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite),
+ gimp_parasite_data_size (parasite),
+ md5_digest, error);
+
+ if (! profile)
+ g_prefix_error (error,
+ _("Error parsing data attached as 'icc-profile': "));
+
+ if (profile && ! gimp_lcms_profile_is_rgb (profile))
+ {
+ g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
+ _("Color profile attached as 'icc-profile' is "
+ "not for RGB color space"));
+ cmsCloseProfile (profile);
+ profile = NULL;
+ }
+ }
+ else if (config->rgb_profile)
+ {
+ profile = gimp_lcms_profile_open_from_file (config->rgb_profile,
+ md5_digest, error);
+
+ if (profile && ! gimp_lcms_profile_is_rgb (profile))
+ {
+ g_set_error (error, GIMP_ERROR, GIMP_FAILED,
+ _("Color profile '%s' is not for RGB color space"),
+ gimp_filename_to_utf8 (config->rgb_profile));
+ cmsCloseProfile (profile);
+ profile = NULL;
+ }
+ }
+
+ return profile;
+}
diff --git a/app/core/gimpimage-profile.h b/app/core/gimpimage-profile.h
new file mode 100644
index 0000000..8d653e6
--- /dev/null
+++ b/app/core/gimpimage-profile.h
@@ -0,0 +1,34 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_IMAGE_PROFILE_H__
+#define __GIMP_IMAGE_PROFILE_H__
+
+
+#define GIMP_ICC_PROFILE_PARASITE_NAME "icc-profile"
+
+
+const GimpParasite * gimp_image_get_icc_profile (GimpImage *image);
+void gimp_image_set_icc_profile (GimpImage *image,
+ const GimpParasite *icc_profile);
+
+GimpColorProfile gimp_image_get_profile (GimpImage *image,
+ guint8 *md5_digest,
+ GError **error);
+
+
+#endif /* __GIMP_IMAGE_PROFILE_H__ */
diff --git a/app/widgets/gimpimageprofileview.c b/app/widgets/gimpimageprofileview.c
index 9c0e735..68a7a37 100644
--- a/app/widgets/gimpimageprofileview.c
+++ b/app/widgets/gimpimageprofileview.c
@@ -36,9 +36,6 @@
#include "widgets-types.h"
-#include "config/gimpcoreconfig.h"
-
-#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimage-profile.h"
@@ -109,43 +106,17 @@ gimp_image_profile_view_update (GimpImageParasiteView *view)
{
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
GimpImage *image;
- GimpColorConfig *config;
- const GimpParasite *parasite;
- GimpColorProfile *profile = NULL;
- GError *error = NULL;
-
- image = gimp_image_parasite_view_get_image (view);
- parasite = gimp_image_parasite_view_get_parasite (view);
+ GimpColorProfile *profile;
+ GError *error = NULL;
- config = image->gimp->config->color_management;
+ image = gimp_image_parasite_view_get_image (view);
- if (parasite)
- {
- profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
- NULL, &error);
- if (! profile)
- {
- g_message (_("Error parsing 'icc-profile': %s"), error->message);
- g_clear_error (&error);
- }
- }
- else if (config->rgb_profile)
- {
- profile = gimp_lcms_profile_open_from_file (config->rgb_profile,
- NULL, &error);
- if (! profile)
- {
- g_message ("%s", error->message);
- g_clear_error (&error);
- }
- }
+ profile = gimp_image_get_profile (image, NULL, &error);
- if (profile && ! gimp_lcms_profile_is_rgb (profile))
+ if (! profile && error)
{
- g_message (_("Color profile is not for RGB color space (skipping)"));
- cmsCloseProfile (profile);
- profile = NULL;
+ g_message ("%s", error->message);
+ g_clear_error (&error);
}
if (! profile)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6051cf9..6e15e07 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -128,8 +128,8 @@ app/core/gimp-gradients.c
app/core/gimpgrid.c
app/core/gimpgrouplayer.c
app/core/gimp-gui.c
-app/core/gimpimage-arrange.c
app/core/gimpimage.c
+app/core/gimpimage-arrange.c
app/core/gimpimage-colormap.c
app/core/gimpimage-convert-precision.c
app/core/gimpimage-convert-type.c
@@ -140,6 +140,7 @@ app/core/gimpimage-guides.c
app/core/gimpimage-item-list.c
app/core/gimpimage-merge.c
app/core/gimpimage-new.c
+app/core/gimpimage-profile.c
app/core/gimpimage-quick-mask.c
app/core/gimpimage-resize.c
app/core/gimpimage-sample-points.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]