2006-12-10 05:33:38 +08:00
|
|
|
# GIMP - The GNU Image Manipulation Program
|
2004-09-29 06:01:21 +08:00
|
|
|
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
2009-01-18 06:28:01 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2004-09-29 06:01:21 +08:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2004-09-29 06:01:21 +08:00
|
|
|
# (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
|
2018-07-12 05:27:07 +08:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
|
|
|
|
sub pattern_get_info {
|
|
|
|
$blurb = 'Retrieve information about the specified pattern.';
|
2006-03-15 05:35:50 +08:00
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure retrieves information about the specified pattern.
|
|
|
|
This includes the pattern extents (width and height).
|
|
|
|
HELP
|
|
|
|
|
2006-03-15 05:35:50 +08:00
|
|
|
&mitch_pdb_misc('2004', '2.2');
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
@inargs = (
|
2007-12-11 17:54:41 +08:00
|
|
|
{ name => 'name', type => 'string', non_empty => 1,
|
2006-03-15 05:35:50 +08:00
|
|
|
desc => 'The pattern name.' }
|
2004-09-29 06:01:21 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
@outargs = (
|
2007-04-27 01:43:18 +08:00
|
|
|
{ name => 'width', type => 'int32', void_ret => 1,
|
2004-09-29 06:01:21 +08:00
|
|
|
desc => "The pattern width" },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'height', type => 'int32',
|
2004-09-29 06:01:21 +08:00
|
|
|
desc => "The pattern height" },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'bpp', type => 'int32',
|
2004-09-29 06:01:21 +08:00
|
|
|
desc => "The pattern bpp" }
|
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
2004-10-06 07:28:17 +08:00
|
|
|
code => <<'CODE'
|
2004-09-29 06:01:21 +08:00
|
|
|
{
|
2007-12-11 17:54:41 +08:00
|
|
|
GimpPattern *pattern = gimp_pdb_get_pattern (gimp, name, error);
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2006-03-15 20:49:25 +08:00
|
|
|
if (pattern)
|
|
|
|
{
|
2012-04-23 15:40:56 +08:00
|
|
|
width = gimp_temp_buf_get_width (pattern->mask);
|
|
|
|
height = gimp_temp_buf_get_height (pattern->mask);
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
|
2006-03-15 20:49:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
success = FALSE;
|
2004-09-29 06:01:21 +08:00
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-10-06 07:28:17 +08:00
|
|
|
sub pattern_get_pixels {
|
|
|
|
$blurb = <<'BLURB';
|
|
|
|
Retrieve information about the specified pattern (including pixels).
|
|
|
|
BLURB
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure retrieves information about the specified. This
|
|
|
|
includes the pattern extents (width and height), its bpp and its pixel
|
|
|
|
data.
|
|
|
|
HELP
|
|
|
|
|
2006-03-15 05:35:50 +08:00
|
|
|
&mitch_pdb_misc('2004', '2.2');
|
2004-10-06 07:28:17 +08:00
|
|
|
|
|
|
|
@inargs = (
|
2007-12-11 17:54:41 +08:00
|
|
|
{ name => 'name', type => 'string', non_empty => 1,
|
2006-03-15 05:35:50 +08:00
|
|
|
desc => 'The pattern name.' }
|
2004-10-06 07:28:17 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
@outargs = (
|
2007-04-27 01:43:18 +08:00
|
|
|
{ name => 'width', type => 'int32', void_ret => 1,
|
2004-10-06 07:28:17 +08:00
|
|
|
desc => "The pattern width" },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'height', type => 'int32',
|
2004-10-06 07:28:17 +08:00
|
|
|
desc => "The pattern height" },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'bpp', type => 'int32',
|
2004-10-06 07:28:17 +08:00
|
|
|
desc => "The pattern bpp" },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'color_bytes', type => 'int8array',
|
2004-10-06 11:23:09 +08:00
|
|
|
desc => 'The pattern data.',
|
2006-03-15 23:32:39 +08:00
|
|
|
array => { desc => 'Number of pattern bytes' } }
|
2004-10-06 07:28:17 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
|
|
|
code => <<'CODE'
|
|
|
|
{
|
2007-12-11 17:54:41 +08:00
|
|
|
GimpPattern *pattern = gimp_pdb_get_pattern (gimp, name, error);
|
2004-10-06 07:28:17 +08:00
|
|
|
|
|
|
|
if (pattern)
|
|
|
|
{
|
2012-04-23 15:40:56 +08:00
|
|
|
width = gimp_temp_buf_get_width (pattern->mask);
|
|
|
|
height = gimp_temp_buf_get_height (pattern->mask);
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
|
2012-04-09 05:56:52 +08:00
|
|
|
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
|
|
|
|
color_bytes = g_memdup (gimp_temp_buf_get_data (pattern->mask),
|
2004-10-06 11:23:09 +08:00
|
|
|
num_color_bytes);
|
2004-10-06 07:28:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2007-12-11 17:54:41 +08:00
|
|
|
@headers = qw(<string.h>
|
|
|
|
"core/gimpcontext.h"
|
|
|
|
"core/gimpdatafactory.h"
|
|
|
|
"core/gimppattern.h"
|
2012-04-09 06:59:20 +08:00
|
|
|
"core/gimptempbuf.h"
|
2007-12-11 17:54:41 +08:00
|
|
|
"gimppdb-utils.h");
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2008-02-08 01:08:54 +08:00
|
|
|
@procs = qw(pattern_get_info
|
|
|
|
pattern_get_pixels);
|
2006-03-24 05:17:16 +08:00
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
|
|
|
|
$desc = 'Pattern';
|
2010-07-07 17:43:10 +08:00
|
|
|
$doc_title = 'gimppattern';
|
|
|
|
$doc_short_desc = 'Functions operating on a single pattern.';
|
|
|
|
$doc_long_desc = 'Functions operating on a single pattern.';
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
1;
|