summaryrefslogtreecommitdiffstats
path: root/pdb/groups/image_sample_points.pdb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:23:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:23:22 +0000
commite42129241681dde7adae7d20697e7b421682fbb4 (patch)
treeaf1fe815a5e639e68e59fabd8395ec69458b3e5e /pdb/groups/image_sample_points.pdb
parentInitial commit. (diff)
downloadgimp-upstream.tar.xz
gimp-upstream.zip
Adding upstream version 2.10.22.upstream/2.10.22upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pdb/groups/image_sample_points.pdb')
-rw-r--r--pdb/groups/image_sample_points.pdb202
1 files changed, 202 insertions, 0 deletions
diff --git a/pdb/groups/image_sample_points.pdb b/pdb/groups/image_sample_points.pdb
new file mode 100644
index 0000000..e116f7a
--- /dev/null
+++ b/pdb/groups/image_sample_points.pdb
@@ -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 <https://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_aux_item_get_ID (GIMP_AUX_ITEM (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_aux_item_get_ID (GIMP_AUX_ITEM (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;