mirror of https://github.com/GNOME/gimp.git
pdb, libgimp: add gimp_image_convert_color_profile_from_file()
This commit is contained in:
parent
b0735c9448
commit
96749a440e
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 767 procedures registered total */
|
||||
/* 768 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue