mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
Bug 759104 - Allow coordinates of sample points to be accessed from scripts
Add PDB sample point API similar to how the guide API works. Add core API similar to the core guide API to make guide and sample point APIs as similar as possible.
This commit is contained in:
parent
96339dd674
commit
d7bf9de526
23 changed files with 972 additions and 21 deletions
|
@ -75,8 +75,7 @@ gimp_image_add_sample_point (GimpImage *image,
|
|||
|
||||
private->sample_points = g_list_append (private->sample_points, sample_point);
|
||||
|
||||
sample_point->x = x;
|
||||
sample_point->y = y;
|
||||
gimp_sample_point_set_position (sample_point, x, y);
|
||||
gimp_sample_point_ref (sample_point);
|
||||
|
||||
gimp_image_sample_point_added (image, sample_point);
|
||||
|
@ -103,8 +102,7 @@ gimp_image_remove_sample_point (GimpImage *image,
|
|||
|
||||
gimp_image_sample_point_removed (image, sample_point);
|
||||
|
||||
sample_point->x = -1;
|
||||
sample_point->y = -1;
|
||||
gimp_sample_point_set_position (sample_point, -1, -1);
|
||||
gimp_sample_point_unref (sample_point);
|
||||
}
|
||||
|
||||
|
@ -127,8 +125,7 @@ gimp_image_move_sample_point (GimpImage *image,
|
|||
C_("undo-type", "Move Sample Point"),
|
||||
sample_point);
|
||||
|
||||
sample_point->x = x;
|
||||
sample_point->y = y;
|
||||
gimp_sample_point_set_position (sample_point, x, y);
|
||||
|
||||
gimp_image_sample_point_moved (image, sample_point);
|
||||
}
|
||||
|
@ -141,6 +138,58 @@ gimp_image_get_sample_points (GimpImage *image)
|
|||
return GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_get_sample_point (GimpImage *image,
|
||||
guint32 id)
|
||||
{
|
||||
GList *sample_points;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
for (sample_points = GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
|
||||
sample_points;
|
||||
sample_points = g_list_next (sample_points))
|
||||
{
|
||||
GimpSamplePoint *sample_point = sample_points->data;
|
||||
|
||||
if (gimp_sample_point_get_ID (sample_point) == id)
|
||||
return sample_point;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_get_next_sample_point (GimpImage *image,
|
||||
guint32 id,
|
||||
gboolean *sample_point_found)
|
||||
{
|
||||
GList *sample_points;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (sample_point_found != NULL, NULL);
|
||||
|
||||
if (id == 0)
|
||||
*sample_point_found = TRUE;
|
||||
else
|
||||
*sample_point_found = FALSE;
|
||||
|
||||
for (sample_points = GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
|
||||
sample_points;
|
||||
sample_points = g_list_next (sample_points))
|
||||
{
|
||||
GimpSamplePoint *sample_point = sample_points->data;
|
||||
|
||||
if (*sample_point_found) /* this is the first guide after the found one */
|
||||
return sample_point;
|
||||
|
||||
if (gimp_sample_point_get_ID (sample_point) == id) /* found it, next one will be returned */
|
||||
*sample_point_found = TRUE;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_find_sample_point (GimpImage *image,
|
||||
gdouble x,
|
||||
|
@ -166,13 +215,17 @@ gimp_image_find_sample_point (GimpImage *image,
|
|||
list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
gint sp_x;
|
||||
gint sp_y;
|
||||
gdouble dist;
|
||||
|
||||
if (sample_point->x < 0 || sample_point->y < 0)
|
||||
gimp_sample_point_get_position (sample_point, &sp_x, &sp_y);
|
||||
|
||||
if (sp_x < 0 || sp_y < 0)
|
||||
continue;
|
||||
|
||||
dist = hypot ((sample_point->x + 0.5) - x,
|
||||
(sample_point->y + 0.5) - y);
|
||||
dist = hypot ((sp_x + 0.5) - x,
|
||||
(sp_y + 0.5) - y);
|
||||
if (dist < MIN (epsilon_y, mindist))
|
||||
{
|
||||
mindist = dist;
|
||||
|
|
|
@ -45,6 +45,12 @@ void gimp_image_move_sample_point (GimpImage *image,
|
|||
gboolean push_undo);
|
||||
|
||||
GList * gimp_image_get_sample_points (GimpImage *image);
|
||||
GimpSamplePoint * gimp_image_get_sample_point (GimpImage *image,
|
||||
guint32 id);
|
||||
GimpSamplePoint * gimp_image_get_next_sample_point (GimpImage *image,
|
||||
guint32 id,
|
||||
gboolean *sample_point_found);
|
||||
|
||||
GimpSamplePoint * gimp_image_find_sample_point (GimpImage *image,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
|
|
|
@ -72,3 +72,35 @@ gimp_sample_point_unref (GimpSamplePoint *sample_point)
|
|||
if (sample_point->ref_count < 1)
|
||||
g_slice_free (GimpSamplePoint, sample_point);
|
||||
}
|
||||
|
||||
guint32
|
||||
gimp_sample_point_get_ID (GimpSamplePoint *sample_point)
|
||||
{
|
||||
g_return_val_if_fail (sample_point != NULL, 0);
|
||||
|
||||
return sample_point->sample_point_ID;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_sample_point_get_position (GimpSamplePoint *sample_point,
|
||||
gint *position_x,
|
||||
gint *position_y)
|
||||
{
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
g_return_if_fail (position_x != NULL);
|
||||
g_return_if_fail (position_y != NULL);
|
||||
|
||||
*position_x = sample_point->x;
|
||||
*position_y = sample_point->y;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_sample_point_set_position (GimpSamplePoint *sample_point,
|
||||
gint position_x,
|
||||
gint position_y)
|
||||
{
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
sample_point->x = position_x;
|
||||
sample_point->y = position_y;
|
||||
}
|
||||
|
|
|
@ -38,5 +38,13 @@ GimpSamplePoint * gimp_sample_point_new (guint32 sample_point_ID);
|
|||
GimpSamplePoint * gimp_sample_point_ref (GimpSamplePoint *sample_point);
|
||||
void gimp_sample_point_unref (GimpSamplePoint *sample_point);
|
||||
|
||||
guint32 gimp_sample_point_get_ID (GimpSamplePoint *sample_point);
|
||||
|
||||
void gimp_sample_point_get_position (GimpSamplePoint *sample_point,
|
||||
gint *position_x,
|
||||
gint *position_y);
|
||||
void gimp_sample_point_set_position (GimpSamplePoint *sample_point,
|
||||
gint position_x,
|
||||
gint position_y);
|
||||
|
||||
#endif /* __GIMP_SAMPLE_POINT_H__ */
|
||||
|
|
|
@ -91,8 +91,9 @@ gimp_sample_point_undo_constructed (GObject *object)
|
|||
|
||||
g_assert (sample_point_undo->sample_point != NULL);
|
||||
|
||||
sample_point_undo->x = sample_point_undo->sample_point->x;
|
||||
sample_point_undo->y = sample_point_undo->sample_point->y;
|
||||
gimp_sample_point_get_position (sample_point_undo->sample_point,
|
||||
&sample_point_undo->x,
|
||||
&sample_point_undo->y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -146,8 +147,7 @@ gimp_sample_point_undo_pop (GimpUndo *undo,
|
|||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
x = sample_point_undo->sample_point->x;
|
||||
y = sample_point_undo->sample_point->y;
|
||||
gimp_sample_point_get_position (sample_point_undo->sample_point, &x, &y);
|
||||
|
||||
if (x == -1)
|
||||
{
|
||||
|
@ -163,8 +163,9 @@ gimp_sample_point_undo_pop (GimpUndo *undo,
|
|||
}
|
||||
else
|
||||
{
|
||||
sample_point_undo->sample_point->x = sample_point_undo->x;
|
||||
sample_point_undo->sample_point->y = sample_point_undo->y;
|
||||
gimp_sample_point_set_position (sample_point_undo->sample_point,
|
||||
sample_point_undo->x,
|
||||
sample_point_undo->y);
|
||||
|
||||
gimp_image_sample_point_moved (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
|
|
|
@ -62,8 +62,9 @@ libappinternal_procs_a_SOURCES = \
|
|||
image-convert-cmds.c \
|
||||
image-grid-cmds.c \
|
||||
image-guides-cmds.c \
|
||||
image-transform-cmds.c \
|
||||
image-sample-points-cmds.c \
|
||||
image-select-cmds.c \
|
||||
image-transform-cmds.c \
|
||||
image-undo-cmds.c \
|
||||
item-cmds.c \
|
||||
item-transform-cmds.c \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpitem.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
@ -737,6 +738,29 @@ gimp_pdb_image_get_guide (GimpImage *image,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_pdb_image_get_sample_point (GimpImage *image,
|
||||
gint sample_point_ID,
|
||||
GError **error)
|
||||
{
|
||||
GimpSamplePoint *sample_point;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
sample_point = gimp_image_get_sample_point (image, sample_point_ID);
|
||||
|
||||
if (sample_point)
|
||||
return sample_point;
|
||||
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Image '%s' (%d) does not contain sample point with ID %d"),
|
||||
gimp_image_get_display_name (image),
|
||||
gimp_image_get_ID (image),
|
||||
sample_point_ID);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpStroke *
|
||||
gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
|
||||
gint stroke_ID,
|
||||
|
|
|
@ -103,6 +103,10 @@ gboolean gimp_pdb_image_is_not_precision (GimpImage *image,
|
|||
GimpGuide * gimp_pdb_image_get_guide (GimpImage *image,
|
||||
gint guide_ID,
|
||||
GError **error);
|
||||
GimpSamplePoint *
|
||||
gimp_pdb_image_get_sample_point (GimpImage *image,
|
||||
gint sample_point_ID,
|
||||
GError **error);
|
||||
|
||||
GimpStroke * gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
|
||||
gint stroke_ID,
|
||||
|
|
350
app/pdb/image-sample-points-cmds.c
Normal file
350
app/pdb/image-sample-points-cmds.c
Normal file
|
@ -0,0 +1,350 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995-2003 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/>.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is auto-generated by pdbgen.pl. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpparamspecs.h"
|
||||
#include "core/gimpsamplepoint.h"
|
||||
|
||||
#include "gimppdb.h"
|
||||
#include "gimppdberror.h"
|
||||
#include "gimppdb-utils.h"
|
||||
#include "gimpprocedure.h"
|
||||
#include "internal-procs.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static GimpValueArray *
|
||||
image_add_sample_point_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpImage *image;
|
||||
gint32 position_x;
|
||||
gint32 position_y;
|
||||
gint32 sample_point = 0;
|
||||
|
||||
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
|
||||
position_x = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
position_y = g_value_get_int (gimp_value_array_index (args, 2));
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (position_x <= gimp_image_get_width (image) &&
|
||||
position_y <= gimp_image_get_height (image))
|
||||
{
|
||||
GimpSamplePoint *sp;
|
||||
|
||||
sp = gimp_image_add_sample_point_at_pos (image, position_x, position_y,
|
||||
TRUE);
|
||||
sample_point = gimp_sample_point_get_ID (sp);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_uint (gimp_value_array_index (return_vals, 1), sample_point);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
image_delete_sample_point_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *image;
|
||||
gint32 sample_point;
|
||||
|
||||
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
|
||||
sample_point = g_value_get_uint (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_pdb_image_get_sample_point (image, sample_point,
|
||||
error);
|
||||
|
||||
if (sp)
|
||||
gimp_image_remove_sample_point (image, sp, TRUE);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
image_find_next_sample_point_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpImage *image;
|
||||
gint32 sample_point;
|
||||
gint32 next_sample_point = 0;
|
||||
|
||||
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
|
||||
sample_point = g_value_get_uint (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_image_get_next_sample_point (image, sample_point,
|
||||
&success);
|
||||
|
||||
if (sp)
|
||||
next_sample_point = gimp_sample_point_get_ID (sp);
|
||||
|
||||
if (! success)
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Image '%s' (%d) does not contain sample point with ID %d"),
|
||||
gimp_image_get_display_name (image),
|
||||
gimp_image_get_ID (image),
|
||||
sample_point);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_uint (gimp_value_array_index (return_vals, 1), next_sample_point);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
image_get_sample_point_position_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpImage *image;
|
||||
gint32 sample_point;
|
||||
gint32 position_x = 0;
|
||||
gint32 position_y = 0;
|
||||
|
||||
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
|
||||
sample_point = g_value_get_uint (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_pdb_image_get_sample_point (image, sample_point,
|
||||
error);
|
||||
|
||||
if (sp)
|
||||
gimp_sample_point_get_position (sp, &position_x, &position_y);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), position_x);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 2), position_y);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
void
|
||||
register_image_sample_points_procs (GimpPDB *pdb)
|
||||
{
|
||||
GimpProcedure *procedure;
|
||||
|
||||
/*
|
||||
* gimp-image-add-sample-point
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_add_sample_point_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-add-sample-point");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-image-add-sample-point",
|
||||
"Add a sample point to an image.",
|
||||
"This procedure adds a sample point to an image. It takes the input image and the position of the new sample points as parameters. It returns the sample point ID of the new sample point.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2016",
|
||||
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_int32 ("position-x",
|
||||
"position x",
|
||||
"The guide'sample points x-offset from left of image",
|
||||
0, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_int32 ("position-y",
|
||||
"position y",
|
||||
"The guide'sample points y-offset from top of image",
|
||||
0, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_uint ("sample-point",
|
||||
"sample point",
|
||||
"The new sample point",
|
||||
1, G_MAXUINT32, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-delete-sample-point
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_delete_sample_point_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-delete-sample-point");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-image-delete-sample-point",
|
||||
"Deletes a sample point from an image.",
|
||||
"This procedure takes an image and a sample point ID as input and removes the specified sample point from the specified image.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2016",
|
||||
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,
|
||||
g_param_spec_uint ("sample-point",
|
||||
"sample point",
|
||||
"The ID of the sample point to be removed",
|
||||
1, G_MAXUINT32, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-find-next-sample-point
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_find_next_sample_point_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-find-next-sample-point");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-image-find-next-sample-point",
|
||||
"Find next sample point on an image.",
|
||||
"This procedure takes an image and a sample point ID as input and finds the sample point ID of the successor of the given sample point ID in the image's sample point list. If the supplied sample point ID is 0, the procedure will return the first sample point. The procedure will return 0 if given the final sample point ID as an argument or the image has no sample points.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2016",
|
||||
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,
|
||||
g_param_spec_uint ("sample-point",
|
||||
"sample point",
|
||||
"The ID of the current sample point (0 if first invocation)",
|
||||
1, G_MAXUINT32, 1,
|
||||
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_uint ("next-sample-point",
|
||||
"next sample point",
|
||||
"The next sample point's ID",
|
||||
1, G_MAXUINT32, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-image-get-sample-point-position
|
||||
*/
|
||||
procedure = gimp_procedure_new (image_get_sample_point_position_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-image-get-sample-point-position");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-image-get-sample-point-position",
|
||||
"Get position of a sample point on an image.",
|
||||
"This procedure takes an image and a sample point ID as input and returns the position of the sample point relative to the top and left of the image.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2016",
|
||||
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,
|
||||
g_param_spec_uint ("sample-point",
|
||||
"sample point",
|
||||
"The guide",
|
||||
1, G_MAXUINT32, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_int32 ("position-x",
|
||||
"position x",
|
||||
"The sample points's position relative to top of image",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_int32 ("position-y",
|
||||
"position y",
|
||||
"The sample points's position relative to top of image",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 793 procedures registered total */
|
||||
/* 797 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
@ -63,6 +63,7 @@ internal_procs_init (GimpPDB *pdb)
|
|||
register_image_convert_procs (pdb);
|
||||
register_image_grid_procs (pdb);
|
||||
register_image_guides_procs (pdb);
|
||||
register_image_sample_points_procs (pdb);
|
||||
register_image_select_procs (pdb);
|
||||
register_image_transform_procs (pdb);
|
||||
register_image_undo_procs (pdb);
|
||||
|
|
|
@ -52,6 +52,7 @@ void register_image_color_profile_procs (GimpPDB *pdb);
|
|||
void register_image_convert_procs (GimpPDB *pdb);
|
||||
void register_image_grid_procs (GimpPDB *pdb);
|
||||
void register_image_guides_procs (GimpPDB *pdb);
|
||||
void register_image_sample_points_procs (GimpPDB *pdb);
|
||||
void register_image_select_procs (GimpPDB *pdb);
|
||||
void register_image_transform_procs (GimpPDB *pdb);
|
||||
void register_image_undo_procs (GimpPDB *pdb);
|
||||
|
|
|
@ -107,6 +107,7 @@ PDB_WRAPPERS_C = \
|
|||
gimpimageconvert_pdb.c \
|
||||
gimpimagegrid_pdb.c \
|
||||
gimpimageguides_pdb.c \
|
||||
gimpimagesamplepoints_pdb.c \
|
||||
gimpimageselect_pdb.c \
|
||||
gimpimagetransform_pdb.c \
|
||||
gimpimageundo_pdb.c \
|
||||
|
@ -163,6 +164,7 @@ PDB_WRAPPERS_H = \
|
|||
gimpimageconvert_pdb.h \
|
||||
gimpimagegrid_pdb.h \
|
||||
gimpimageguides_pdb.h \
|
||||
gimpimagesamplepoints_pdb.h \
|
||||
gimpimageselect_pdb.h \
|
||||
gimpimagetransform_pdb.h \
|
||||
gimpimageundo_pdb.h \
|
||||
|
|
|
@ -391,6 +391,7 @@ EXPORTS
|
|||
gimp_image_add_channel
|
||||
gimp_image_add_hguide
|
||||
gimp_image_add_layer
|
||||
gimp_image_add_sample_point
|
||||
gimp_image_add_vectors
|
||||
gimp_image_add_vguide
|
||||
gimp_image_attach_new_parasite
|
||||
|
@ -407,9 +408,11 @@ EXPORTS
|
|||
gimp_image_crop
|
||||
gimp_image_delete
|
||||
gimp_image_delete_guide
|
||||
gimp_image_delete_sample_point
|
||||
gimp_image_detach_parasite
|
||||
gimp_image_duplicate
|
||||
gimp_image_find_next_guide
|
||||
gimp_image_find_next_sample_point
|
||||
gimp_image_flatten
|
||||
gimp_image_flip
|
||||
gimp_image_floating_sel_attached_to
|
||||
|
@ -445,6 +448,7 @@ EXPORTS
|
|||
gimp_image_get_parasite_list
|
||||
gimp_image_get_precision
|
||||
gimp_image_get_resolution
|
||||
gimp_image_get_sample_point_position
|
||||
gimp_image_get_selection
|
||||
gimp_image_get_tattoo_state
|
||||
gimp_image_get_thumbnail
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include <libgimp/gimpimageconvert_pdb.h>
|
||||
#include <libgimp/gimpimagegrid_pdb.h>
|
||||
#include <libgimp/gimpimageguides_pdb.h>
|
||||
#include <libgimp/gimpimagesamplepoints_pdb.h>
|
||||
#include <libgimp/gimpimageselect_pdb.h>
|
||||
#include <libgimp/gimpimagetransform_pdb.h>
|
||||
#include <libgimp/gimpimageundo_pdb.h>
|
||||
|
|
192
libgimp/gimpimagesamplepoints_pdb.c
Normal file
192
libgimp/gimpimagesamplepoints_pdb.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpimagesamplepoints_pdb.c
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is auto-generated by pdbgen.pl */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: gimpimagesamplepoints
|
||||
* @title: gimpimagesamplepoints
|
||||
* @short_description: Functions for manipulating an image's sample points.
|
||||
*
|
||||
* Functions for manipulating an image's sample points.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* gimp_image_add_sample_point:
|
||||
* @image_ID: The image.
|
||||
* @position_x: The guide'sample points x-offset from left of image.
|
||||
* @position_y: The guide'sample points y-offset from top of image.
|
||||
*
|
||||
* Add a sample point to an image.
|
||||
*
|
||||
* This procedure adds a sample point to an image. It takes the input
|
||||
* image and the position of the new sample points as parameters. It
|
||||
* returns the sample point ID of the new sample point.
|
||||
*
|
||||
* Returns: The new sample point.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
gint32
|
||||
gimp_image_add_sample_point (gint32 image_ID,
|
||||
gint position_x,
|
||||
gint position_y)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 sample_point_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-image-add-sample-point",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_INT32, position_x,
|
||||
GIMP_PDB_INT32, position_y,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
sample_point_ID = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return sample_point_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_delete_sample_point:
|
||||
* @image_ID: The image.
|
||||
* @sample_point_ID: The ID of the sample point to be removed.
|
||||
*
|
||||
* Deletes a sample point from an image.
|
||||
*
|
||||
* This procedure takes an image and a sample point ID as input and
|
||||
* removes the specified sample point from the specified image.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
gboolean
|
||||
gimp_image_delete_sample_point (gint32 image_ID,
|
||||
gint32 sample_point_ID)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-image-delete-sample-point",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_INT32, sample_point_ID,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_find_next_sample_point:
|
||||
* @image_ID: The image.
|
||||
* @sample_point_ID: The ID of the current sample point (0 if first invocation).
|
||||
*
|
||||
* Find next sample point on an image.
|
||||
*
|
||||
* This procedure takes an image and a sample point ID as input and
|
||||
* finds the sample point ID of the successor of the given sample point
|
||||
* ID in the image's sample point list. If the supplied sample point ID
|
||||
* is 0, the procedure will return the first sample point. The
|
||||
* procedure will return 0 if given the final sample point ID as an
|
||||
* argument or the image has no sample points.
|
||||
*
|
||||
* Returns: The next sample point's ID.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
gint32
|
||||
gimp_image_find_next_sample_point (gint32 image_ID,
|
||||
gint32 sample_point_ID)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 next_sample_point_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-image-find-next-sample-point",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_INT32, sample_point_ID,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
next_sample_point_ID = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return next_sample_point_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_image_get_sample_point_position:
|
||||
* @image_ID: The image.
|
||||
* @sample_point_ID: The guide.
|
||||
* @position_y: The sample points's position relative to top of image.
|
||||
*
|
||||
* Get position of a sample point on an image.
|
||||
*
|
||||
* This procedure takes an image and a sample point ID as input and
|
||||
* returns the position of the sample point relative to the top and
|
||||
* left of the image.
|
||||
*
|
||||
* Returns: The sample points's position relative to top of image.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
gint
|
||||
gimp_image_get_sample_point_position (gint32 image_ID,
|
||||
gint32 sample_point_ID,
|
||||
gint *position_y)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint position_x = G_MININT;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-image-get-sample-point-position",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_INT32, sample_point_ID,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
position_x = return_vals[1].data.d_int32;
|
||||
*position_y = return_vals[2].data.d_int32;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return position_x;
|
||||
}
|
49
libgimp/gimpimagesamplepoints_pdb.h
Normal file
49
libgimp/gimpimagesamplepoints_pdb.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpimagesamplepoints_pdb.h
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is auto-generated by pdbgen.pl */
|
||||
|
||||
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
|
||||
#error "Only <libgimp/gimp.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __GIMP_IMAGE_SAMPLE_POINTS_PDB_H__
|
||||
#define __GIMP_IMAGE_SAMPLE_POINTS_PDB_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
gint32 gimp_image_add_sample_point (gint32 image_ID,
|
||||
gint position_x,
|
||||
gint position_y);
|
||||
gboolean gimp_image_delete_sample_point (gint32 image_ID,
|
||||
gint32 sample_point_ID);
|
||||
gint32 gimp_image_find_next_sample_point (gint32 image_ID,
|
||||
gint32 sample_point_ID);
|
||||
gint gimp_image_get_sample_point_position (gint32 image_ID,
|
||||
gint32 sample_point_ID,
|
||||
gint *position_y);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_IMAGE_SAMPLE_POINTS_PDB_H__ */
|
|
@ -302,6 +302,7 @@ app/pdb/gimpprocedure.c
|
|||
app/pdb/image-cmds.c
|
||||
app/pdb/image-convert-cmds.c
|
||||
app/pdb/image-guides-cmds.c
|
||||
app/pdb/image-sample-points-cmds.c
|
||||
app/pdb/image-select-cmds.c
|
||||
app/pdb/image-transform-cmds.c
|
||||
app/pdb/image-undo-cmds.c
|
||||
|
|
|
@ -30,6 +30,7 @@ pdb_sources = \
|
|||
pdb/image_convert.pdb \
|
||||
pdb/image_grid.pdb \
|
||||
pdb/image_guides.pdb \
|
||||
pdb/image_sample_points.pdb \
|
||||
pdb/image_select.pdb \
|
||||
pdb/image_transform.pdb \
|
||||
pdb/image_undo.pdb \
|
||||
|
|
|
@ -325,6 +325,15 @@ g_param_spec_uint ("$name",
|
|||
"$blurb",
|
||||
1, G_MAXUINT32, 1,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'sample_point') {
|
||||
$pspec = <<CODE;
|
||||
g_param_spec_uint ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
1, G_MAXUINT32, 1,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'float') {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
image_convert
|
||||
image_grid
|
||||
image_guides
|
||||
image_sample_points
|
||||
image_select
|
||||
image_transform
|
||||
image_undo
|
||||
|
|
|
@ -284,7 +284,7 @@ CODE
|
|||
$ch = 'gimp_parasite_copy (&';
|
||||
$cf = ')';
|
||||
}
|
||||
elsif ($type =~ /boolean|enum|guide/) {
|
||||
elsif ($type =~ /boolean|enum|guide|sample_point/) {
|
||||
$type = 'int32';
|
||||
}
|
||||
|
||||
|
|
|
@ -227,6 +227,14 @@ package Gimp::CodeGen::pdb;
|
|||
get_value_func => '$var = g_value_get_uint ($value)',
|
||||
set_value_func => 'g_value_set_uint ($value, $var)' },
|
||||
|
||||
sample_point => { name => 'INT32',
|
||||
type => 'gint32 ',
|
||||
const_type => 'gint32 ',
|
||||
id => 1,
|
||||
init_value => '0',
|
||||
get_value_func => '$var = g_value_get_uint ($value)',
|
||||
set_value_func => 'g_value_set_uint ($value, $var)' },
|
||||
|
||||
unit => { name => 'INT32',
|
||||
type => 'GimpUnit ',
|
||||
const_type => 'GimpUnit ',
|
||||
|
|
202
tools/pdbgen/pdb/image_sample_points.pdb
Normal file
202
tools/pdbgen/pdb/image_sample_points.pdb
Normal file
|
@ -0,0 +1,202 @@
|
|||
# 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/>.
|
||||
|
||||
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
||||
|
||||
sub image_add_sample_point {
|
||||
$blurb = 'Add a sample point to an image.';
|
||||
|
||||
$help = <<HELP;
|
||||
This procedure adds a sample point to an image. It takes the input
|
||||
image and the position of the new sample points as parameters. It
|
||||
returns the sample point ID of the new sample point.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2016', '2.10');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' },
|
||||
{ name => 'position_x', type => '0 <= int32',
|
||||
desc => "The guide'sample points x-offset from left of image" },
|
||||
{ name => 'position_y', type => '0 <= int32',
|
||||
desc => "The guide'sample points y-offset from top of image" }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'sample_point', type => 'sample_point',
|
||||
desc => 'The new sample point' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (position_x <= gimp_image_get_width (image) &&
|
||||
position_y <= gimp_image_get_height (image))
|
||||
{
|
||||
GimpSamplePoint *sp;
|
||||
|
||||
sp = gimp_image_add_sample_point_at_pos (image, position_x, position_y,
|
||||
TRUE);
|
||||
sample_point = gimp_sample_point_get_ID (sp);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_delete_sample_point {
|
||||
$blurb = 'Deletes a sample point from an image.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure takes an image and a sample point ID as input and
|
||||
removes the specified sample point from the specified image.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2016', '2.10');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' },
|
||||
{ name => 'sample_point', type => 'sample_point',
|
||||
desc => 'The ID of the sample point to be removed' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_pdb_image_get_sample_point (image, sample_point,
|
||||
error);
|
||||
|
||||
if (sp)
|
||||
gimp_image_remove_sample_point (image, sp, TRUE);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_find_next_sample_point {
|
||||
$blurb = 'Find next sample point on an image.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure takes an image and a sample point ID as input and finds
|
||||
the sample point ID of the successor of the given sample point ID in
|
||||
the image's sample point list. If the supplied sample point ID is 0,
|
||||
the procedure will return the first sample point. The procedure will
|
||||
return 0 if given the final sample point ID as an argument or the
|
||||
image has no sample points.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2016', '2.10');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' },
|
||||
{ name => 'sample_point', type => 'sample_point', no_validate => 1,
|
||||
desc => 'The ID of the current sample point (0 if first invocation)' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'next_sample_point', type => 'sample_point',
|
||||
desc => "The next sample point's ID" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_image_get_next_sample_point (image, sample_point,
|
||||
&success);
|
||||
|
||||
if (sp)
|
||||
next_sample_point = gimp_sample_point_get_ID (sp);
|
||||
|
||||
if (! success)
|
||||
g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
|
||||
_("Image '%s' (%d) does not contain sample point with ID %d"),
|
||||
gimp_image_get_display_name (image),
|
||||
gimp_image_get_ID (image),
|
||||
sample_point);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub image_get_sample_point_position {
|
||||
$blurb = 'Get position of a sample point on an image.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure takes an image and a sample point ID as input and
|
||||
returns the position of the sample point relative to the top and left
|
||||
of the image.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2016', '2.10');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'The image' },
|
||||
{ name => 'sample_point', type => 'sample_point',
|
||||
desc => 'The guide' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'position_x', type => 'int32',
|
||||
libdef => 'G_MININT',
|
||||
desc => "The sample points's position relative to top of image" },
|
||||
{ name => 'position_y', type => 'int32',
|
||||
libdef => 'G_MININT',
|
||||
desc => "The sample points's position relative to top of image" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpSamplePoint *sp = gimp_pdb_image_get_sample_point (image, sample_point,
|
||||
error);
|
||||
|
||||
if (sp)
|
||||
gimp_sample_point_get_position (sp, &position_x, &position_y);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@headers = qw("core/gimpsamplepoint.h"
|
||||
"core/gimpimage-sample-points.h"
|
||||
"gimppdb-utils.h"
|
||||
"gimppdberror.h"
|
||||
"gimp-intl.h");
|
||||
|
||||
@procs = qw(image_add_sample_point
|
||||
image_delete_sample_point
|
||||
image_find_next_sample_point
|
||||
image_get_sample_point_position);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Image Sample Point procedures';
|
||||
$doc_title = 'gimpimagesamplepoints';
|
||||
$doc_short_desc = 'Functions for manipulating an image\'s sample points.';
|
||||
$doc_long_desc = 'Functions for manipulating an image\'s sample points.';
|
||||
|
||||
1;
|
Loading…
Add table
Add a link
Reference in a new issue