[gimp/goat-invasion] pdb: export gimp-image-get-precision



commit 94cd0157db3039dbf7d151a97bf9dd3300b718dc
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 25 20:51:29 2012 +0200

    pdb: export gimp-image-get-precision

 app/pdb/image-cmds.c       |   62 ++++++++++++++++++++++++++++++++++++++++++++
 app/pdb/internal-procs.c   |    2 +-
 libgimp/gimp.def           |    1 +
 libgimp/gimpimage_pdb.c    |   32 ++++++++++++++++++++++
 libgimp/gimpimage_pdb.h    |    1 +
 tools/pdbgen/pdb/image.pdb |   34 +++++++++++++++++++++++-
 6 files changed, 130 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index ce3bb25..a0b451f 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -303,6 +303,38 @@ image_base_type_invoker (GimpProcedure      *procedure,
 }
 
 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,
                      GimpContext        *context,
@@ -3063,6 +3095,36 @@ register_image_procs (GimpPDB *pdb)
   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
    */
   procedure = gimp_procedure_new (image_width_invoker);
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index f829424..cd4492b 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 672 procedures registered total */
+/* 673 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 30e2933..3bf5288 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -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
diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c
index ea7191e..ca0d930 100644
--- a/libgimp/gimpimage_pdb.c
+++ b/libgimp/gimpimage_pdb.c
@@ -293,6 +293,38 @@ gimp_image_base_type (gint32 image_ID)
 }
 
 /**
+ * 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.
  *
diff --git a/libgimp/gimpimage_pdb.h b/libgimp/gimpimage_pdb.h
index 771e363..8c6da10 100644
--- a/libgimp/gimpimage_pdb.h
+++ b/libgimp/gimpimage_pdb.h
@@ -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
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 0f7ab4f..f5fc5e5 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -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';



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]