[gimp] pdb, libgimp: add gimp_image_convert_color_profile_from_file()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, libgimp: add gimp_image_convert_color_profile_from_file()
- Date: Tue, 28 Jul 2015 21:12:22 +0000 (UTC)
commit 96749a440edee70f6fd2d7d535de7f309624a139
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 28 23:11:54 2015 +0200
pdb, libgimp: add gimp_image_convert_color_profile_from_file()
app/pdb/image-color-profile-cmds.c | 91 ++++++++++++++++++++++++++++++
app/pdb/internal-procs.c | 2 +-
libgimp/gimp.def | 1 +
libgimp/gimpimagecolorprofile_pdb.c | 42 ++++++++++++++
libgimp/gimpimagecolorprofile_pdb.h | 32 ++++++-----
tools/pdbgen/pdb/image_color_profile.pdb | 54 +++++++++++++++++-
6 files changed, 206 insertions(+), 16 deletions(-)
---
diff --git a/app/pdb/image-color-profile-cmds.c b/app/pdb/image-color-profile-cmds.c
index 111006a..8e31cfc 100644
--- a/app/pdb/image-color-profile-cmds.c
+++ b/app/pdb/image-color-profile-cmds.c
@@ -272,6 +272,54 @@ image_convert_color_profile_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
+static GimpValueArray *
+image_convert_color_profile_from_file_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpImage *image;
+ const gchar *uri;
+ gint32 intent;
+ gboolean bpc;
+
+ image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
+ uri = g_value_get_string (gimp_value_array_index (args, 1));
+ intent = g_value_get_enum (gimp_value_array_index (args, 2));
+ bpc = g_value_get_boolean (gimp_value_array_index (args, 3));
+
+ if (success)
+ {
+ if (uri)
+ {
+ GFile *file = g_file_new_for_uri (uri);
+ GimpColorProfile *profile;
+
+ profile = gimp_color_profile_new_from_file (file, error);
+
+ if (profile)
+ {
+ success = gimp_image_convert_color_profile (image, profile,
+ intent, bpc,
+ progress, error);
+ g_object_unref (profile);
+ }
+ else
+ success = FALSE;
+
+ g_object_unref (file);
+ }
+ else
+ success = FALSE;
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
void
register_image_color_profile_procs (GimpPDB *pdb)
{
@@ -455,4 +503,47 @@ register_image_color_profile_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
+
+ /*
+ * gimp-image-convert-color-profile-from-file
+ */
+ procedure = gimp_procedure_new (image_convert_color_profile_from_file_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-image-convert-color-profile-from-file");
+ gimp_procedure_set_static_strings (procedure,
+ "gimp-image-convert-color-profile-from-file",
+ "Convert the image's layers to a color profile",
+ "This procedure converts from the image's color profile (or the default
RGB profile if none is set) to an ICC profile precified by 'uri'. Only RGB color profiles are accepted.",
+ "Michael Natterer <mitch gimp org>",
+ "Michael Natterer",
+ "2015",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_image_id ("image",
+ "image",
+ "The image",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_string ("uri",
+ "uri",
+ "The URI of the file containing the new color
profile",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_enum ("intent",
+ "intent",
+ "Rendering intent",
+ GIMP_TYPE_COLOR_RENDERING_INTENT,
+ GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_boolean ("bpc",
+ "bpc",
+ "Black point compensation",
+ FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
}
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index a7f2dda..6f0b6e0 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 767 procedures registered total */
+/* 768 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 3649c30..6a4ffdf 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -379,6 +379,7 @@ EXPORTS
gimp_image_base_type
gimp_image_clean_all
gimp_image_convert_color_profile
+ gimp_image_convert_color_profile_from_file
gimp_image_convert_grayscale
gimp_image_convert_indexed
gimp_image_convert_precision
diff --git a/libgimp/gimpimagecolorprofile_pdb.c b/libgimp/gimpimagecolorprofile_pdb.c
index cbf7a90..6bd5dfe 100644
--- a/libgimp/gimpimagecolorprofile_pdb.c
+++ b/libgimp/gimpimagecolorprofile_pdb.c
@@ -247,3 +247,45 @@ _gimp_image_convert_color_profile (gint32 image_ID,
return success;
}
+
+/**
+ * gimp_image_convert_color_profile_from_file:
+ * @image_ID: The image.
+ * @uri: The URI of the file containing the new color profile.
+ * @intent: Rendering intent.
+ * @bpc: Black point compensation.
+ *
+ * Convert the image's layers to a color profile
+ *
+ * This procedure converts from the image's color profile (or the
+ * default RGB profile if none is set) to an ICC profile precified by
+ * 'uri'. Only RGB color profiles are accepted.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_image_convert_color_profile_from_file (gint32 image_ID,
+ const gchar *uri,
+ GimpColorRenderingIntent intent,
+ gboolean bpc)
+{
+ GimpParam *return_vals;
+ gint nreturn_vals;
+ gboolean success = TRUE;
+
+ return_vals = gimp_run_procedure ("gimp-image-convert-color-profile-from-file",
+ &nreturn_vals,
+ GIMP_PDB_IMAGE, image_ID,
+ GIMP_PDB_STRING, uri,
+ GIMP_PDB_INT32, intent,
+ GIMP_PDB_INT32, bpc,
+ GIMP_PDB_END);
+
+ success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+ gimp_destroy_params (return_vals, nreturn_vals);
+
+ return success;
+}
diff --git a/libgimp/gimpimagecolorprofile_pdb.h b/libgimp/gimpimagecolorprofile_pdb.h
index cc9831c..db55e58 100644
--- a/libgimp/gimpimagecolorprofile_pdb.h
+++ b/libgimp/gimpimagecolorprofile_pdb.h
@@ -32,20 +32,24 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
-G_GNUC_INTERNAL guint8* _gimp_image_get_color_profile (gint32 image_ID,
- gint *num_bytes);
-G_GNUC_INTERNAL guint8* _gimp_image_get_effective_color_profile (gint32 image_ID,
- gint *num_bytes);
-G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (gint32 image_ID,
- gint num_bytes,
- const guint8 *color_profile);
-gboolean gimp_image_set_color_profile_from_file (gint32 image_ID,
- const gchar *uri);
-G_GNUC_INTERNAL gboolean _gimp_image_convert_color_profile (gint32 image_ID,
- gint num_bytes,
- const guint8 *color_profile,
- GimpColorRenderingIntent intent,
- gboolean bpc);
+G_GNUC_INTERNAL guint8* _gimp_image_get_color_profile (gint32 image_ID,
+ gint *num_bytes);
+G_GNUC_INTERNAL guint8* _gimp_image_get_effective_color_profile (gint32 image_ID,
+ gint *num_bytes);
+G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (gint32 image_ID,
+ gint num_bytes,
+ const guint8
*color_profile);
+gboolean gimp_image_set_color_profile_from_file (gint32 image_ID,
+ const gchar *uri);
+G_GNUC_INTERNAL gboolean _gimp_image_convert_color_profile (gint32 image_ID,
+ gint num_bytes,
+ const guint8 *color_profile,
+ GimpColorRenderingIntent intent,
+ gboolean bpc);
+gboolean gimp_image_convert_color_profile_from_file (gint32 image_ID,
+ const gchar *uri,
+ GimpColorRenderingIntent intent,
+ gboolean bpc);
G_END_DECLS
diff --git a/tools/pdbgen/pdb/image_color_profile.pdb b/tools/pdbgen/pdb/image_color_profile.pdb
index 7089570..0ede65c 100644
--- a/tools/pdbgen/pdb/image_color_profile.pdb
+++ b/tools/pdbgen/pdb/image_color_profile.pdb
@@ -254,6 +254,57 @@ CODE
);
}
+sub image_convert_color_profile_from_file {
+ $blurb = "Convert the image's layers to a color profile";
+
+ $help = <<'HELP';
+This procedure converts from the image's color profile (or the default
+RGB profile if none is set) to an ICC profile precified by 'uri'.
+Only RGB color profiles are accepted.
+HELP
+
+ &mitch_pdb_misc('2015', '2.10');
+
+ @inargs = (
+ { name => 'image', type => 'image',
+ desc => 'The image' },
+ { name => 'uri', type => 'string',
+ desc => 'The URI of the file containing the new color profile' },
+ { name => 'intent', type => 'enum GimpColorRenderingIntent',
+ desc => 'Rendering intent' },
+ { name => 'bpc', type => 'boolean',
+ desc => 'Black point compensation' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ if (uri)
+ {
+ GFile *file = g_file_new_for_uri (uri);
+ GimpColorProfile *profile;
+
+ profile = gimp_color_profile_new_from_file (file, error);
+
+ if (profile)
+ {
+ success = gimp_image_convert_color_profile (image, profile,
+ intent, bpc,
+ progress, error);
+ g_object_unref (profile);
+ }
+ else
+ success = FALSE;
+
+ g_object_unref (file);
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
@headers = qw(<cairo.h>
"libgimpcolor/gimpcolor.h"
"core/gimpimage-profile.h"
@@ -263,7 +314,8 @@ CODE
image_get_effective_color_profile
image_set_color_profile
image_set_color_profile_from_file
- image_convert_color_profile);
+ image_convert_color_profile
+ image_convert_color_profile_from_file);
%exports = (app => [ procs], lib => [ procs]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]