mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
pdb: export gimp-image-get-precision
This commit is contained in:
parent
8918fd338b
commit
92b4c66777
6 changed files with 130 additions and 2 deletions
|
@ -302,6 +302,38 @@ image_base_type_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
image_get_precision_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GValueArray *return_vals;
|
||||
GimpImage *image;
|
||||
gint32 precision = 0;
|
||||
|
||||
image = gimp_value_get_image (&args->values[0], gimp);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (gimp->plug_in_manager->current_plug_in)
|
||||
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
|
||||
|
||||
precision = gimp_image_get_precision (image);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_enum (&return_vals->values[1], precision);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
image_width_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -3062,6 +3094,36 @@ register_image_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-get-precision
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_get_precision_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-get-precision");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-image-get-precision",
|
||||
"Get the precision of the image.",
|
||||
"This procedure returns the image's precision.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2012",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_image_id ("image",
|
||||
"image",
|
||||
"The image",
|
||||
pdb->gimp, FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_enum ("precision",
|
||||
"precision",
|
||||
"The image's precision",
|
||||
GIMP_TYPE_PRECISION,
|
||||
GIMP_PRECISION_U8,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-width
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 672 procedures registered total */
|
||||
/* 673 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -405,6 +405,7 @@ EXPORTS
|
|||
gimp_image_get_name
|
||||
gimp_image_get_parasite
|
||||
gimp_image_get_parasite_list
|
||||
gimp_image_get_precision
|
||||
gimp_image_get_resolution
|
||||
gimp_image_get_selection
|
||||
gimp_image_get_tattoo_state
|
||||
|
|
|
@ -292,6 +292,38 @@ gimp_image_base_type (gint32 image_ID)
|
|||
return base_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_precision:
|
||||
* @image_ID: The image.
|
||||
*
|
||||
* Get the precision of the image.
|
||||
*
|
||||
* This procedure returns the image's precision.
|
||||
*
|
||||
* Returns: The image's precision.
|
||||
*
|
||||
* Since: GIMP 2.10
|
||||
**/
|
||||
GimpPrecision
|
||||
gimp_image_get_precision (gint32 image_ID)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
GimpPrecision precision = 0;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-image-get-precision",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
precision = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_width:
|
||||
* @image_ID: The image.
|
||||
|
|
|
@ -44,6 +44,7 @@ gint32 gimp_image_new_with_precision (gint
|
|||
gint32 gimp_image_duplicate (gint32 image_ID);
|
||||
gboolean gimp_image_delete (gint32 image_ID);
|
||||
GimpImageBaseType gimp_image_base_type (gint32 image_ID);
|
||||
GimpPrecision gimp_image_get_precision (gint32 image_ID);
|
||||
gint gimp_image_width (gint32 image_ID);
|
||||
gint gimp_image_height (gint32 image_ID);
|
||||
#ifndef GIMP_DISABLE_DEPRECATED
|
||||
|
|
|
@ -1516,6 +1516,37 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub image_get_precision {
|
||||
$blurb = 'Get the precision of the image.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the image's precision.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2012', '2.10');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'precision', type => 'enum GimpPrecision',
|
||||
desc => "The image's precision" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimp->plug_in_manager->current_plug_in)
|
||||
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
|
||||
|
||||
precision = gimp_image_get_precision (image);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_get_colormap {
|
||||
$blurb = "Returns the image's colormap";
|
||||
|
||||
|
@ -2956,6 +2987,7 @@ CODE
|
|||
image_new image_new_with_precision
|
||||
image_duplicate image_delete
|
||||
image_base_type
|
||||
image_get_precision
|
||||
image_width image_height
|
||||
image_free_shadow
|
||||
image_resize image_resize_to_layers
|
||||
|
@ -3011,7 +3043,7 @@ CODE
|
|||
# image_add_layer_mask and image_remove_layer_mask.
|
||||
# If adding or removing functions, make sure the range below is
|
||||
# updated correctly!
|
||||
%exports = (app => [@procs], lib => [@procs[0..43,46..84]]);
|
||||
%exports = (app => [@procs], lib => [@procs[0..44,47..85]]);
|
||||
|
||||
$desc = 'Image';
|
||||
$doc_title = 'gimpimage';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue