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