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-2003 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
|
|
|
*/
|
|
|
|
|
|
2007-01-09 02:52:47 -08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl. */
|
2004-09-28 15:01:21 -07:00
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2022-03-28 06:13:17 -07:00
|
|
|
#include "stamp-pdbgen.h"
|
|
|
|
|
|
2004-09-28 15:01:21 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2004-09-28 15:01:21 -07:00
|
|
|
|
2012-05-02 18:36:22 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
|
|
2012-05-03 15:50:23 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
2004-09-28 15:01:21 -07:00
|
|
|
#include "pdb-types.h"
|
|
|
|
|
|
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
#include "core/gimpdatafactory.h"
|
2008-02-07 09:08:54 -08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-09-28 15:01:21 -07:00
|
|
|
#include "core/gimppattern.h"
|
2012-04-08 15:59:20 -07:00
|
|
|
#include "core/gimptempbuf.h"
|
2019-02-07 06:12:53 -08:00
|
|
|
#include "gegl/gimp-babl-compat.h"
|
2004-09-28 15:01:21 -07:00
|
|
|
|
2008-02-07 09:08:54 -08:00
|
|
|
#include "gimppdb.h"
|
|
|
|
|
#include "gimppdb-utils.h"
|
|
|
|
|
#include "gimpprocedure.h"
|
2008-04-04 04:15:55 -07:00
|
|
|
#include "internal-procs.h"
|
2006-10-31 11:02:56 -08:00
|
|
|
|
2004-09-28 15:01:21 -07:00
|
|
|
|
2012-05-03 15:50:23 -07:00
|
|
|
static GimpValueArray *
|
2012-05-28 10:55:28 -07:00
|
|
|
pattern_get_info_invoker (GimpProcedure *procedure,
|
2012-05-03 15:50:23 -07:00
|
|
|
Gimp *gimp,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GimpProgress *progress,
|
|
|
|
|
const GimpValueArray *args,
|
|
|
|
|
GError **error)
|
2004-09-28 15:01:21 -07:00
|
|
|
{
|
|
|
|
|
gboolean success = TRUE;
|
2012-05-03 15:50:23 -07:00
|
|
|
GimpValueArray *return_vals;
|
2006-04-02 09:03:32 -07:00
|
|
|
const gchar *name;
|
2019-08-15 05:04:56 -07:00
|
|
|
gint width = 0;
|
|
|
|
|
gint height = 0;
|
|
|
|
|
gint bpp = 0;
|
2004-09-28 15:01:21 -07:00
|
|
|
|
2012-05-03 15:50:23 -07:00
|
|
|
name = g_value_get_string (gimp_value_array_index (args, 0));
|
2004-09-28 15:01:21 -07:00
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
2008-08-16 06:57:57 -07:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
|
|
|
error ? *error : NULL);
|
2004-09-28 15:01:21 -07:00
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
2012-05-03 15:50:23 -07:00
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 1), width);
|
|
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 2), height);
|
|
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
|
2004-09-28 15:01:21 -07:00
|
|
|
}
|
|
|
|
|
|
2006-03-27 13:09:32 -08:00
|
|
|
return return_vals;
|
2004-09-28 15:01:21 -07:00
|
|
|
}
|
|
|
|
|
|
2012-05-03 15:50:23 -07:00
|
|
|
static GimpValueArray *
|
2012-05-28 10:55:28 -07:00
|
|
|
pattern_get_pixels_invoker (GimpProcedure *procedure,
|
2012-05-03 15:50:23 -07:00
|
|
|
Gimp *gimp,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GimpProgress *progress,
|
|
|
|
|
const GimpValueArray *args,
|
|
|
|
|
GError **error)
|
2004-10-05 16:28:17 -07:00
|
|
|
{
|
|
|
|
|
gboolean success = TRUE;
|
2012-05-03 15:50:23 -07:00
|
|
|
GimpValueArray *return_vals;
|
2006-04-02 09:03:32 -07:00
|
|
|
const gchar *name;
|
2019-08-15 05:04:56 -07:00
|
|
|
gint width = 0;
|
|
|
|
|
gint height = 0;
|
|
|
|
|
gint bpp = 0;
|
|
|
|
|
gint num_color_bytes = 0;
|
2004-10-05 20:23:09 -07:00
|
|
|
guint8 *color_bytes = NULL;
|
2004-10-05 16:28:17 -07:00
|
|
|
|
2012-05-03 15:50:23 -07:00
|
|
|
name = g_value_get_string (gimp_value_array_index (args, 0));
|
2004-10-05 16:28:17 -07:00
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-16 06:57:57 -07:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
|
|
|
error ? *error : NULL);
|
2004-10-05 16:28:17 -07:00
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
2012-05-03 15:50:23 -07:00
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 1), width);
|
|
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 2), height);
|
|
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
|
|
|
|
|
g_value_set_int (gimp_value_array_index (return_vals, 4), num_color_bytes);
|
2019-08-15 06:04:34 -07:00
|
|
|
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), color_bytes, num_color_bytes);
|
2004-10-05 16:28:17 -07:00
|
|
|
}
|
|
|
|
|
|
2006-03-27 13:09:32 -08:00
|
|
|
return return_vals;
|
2004-10-05 16:28:17 -07:00
|
|
|
}
|
|
|
|
|
|
2006-04-04 14:11:45 -07:00
|
|
|
void
|
2006-04-26 02:13:47 -07:00
|
|
|
register_pattern_procs (GimpPDB *pdb)
|
2004-10-05 16:28:17 -07:00
|
|
|
{
|
2006-04-04 14:11:45 -07:00
|
|
|
GimpProcedure *procedure;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* gimp-pattern-get-info
|
|
|
|
|
*/
|
2006-04-06 03:01:30 -07:00
|
|
|
procedure = gimp_procedure_new (pattern_get_info_invoker);
|
2008-04-04 03:58:56 -07:00
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
|
|
|
"gimp-pattern-get-info");
|
2019-09-08 14:40:34 -07:00
|
|
|
gimp_procedure_set_static_help (procedure,
|
|
|
|
|
"Retrieve information about the specified pattern.",
|
|
|
|
|
"This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
|
|
|
|
|
NULL);
|
|
|
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
|
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
|
|
|
"Michael Natterer",
|
|
|
|
|
"2004");
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
|
gimp_param_spec_string ("name",
|
|
|
|
|
"name",
|
|
|
|
|
"The pattern name.",
|
2007-12-11 01:54:41 -08:00
|
|
|
FALSE, FALSE, TRUE,
|
2006-04-04 14:11:45 -07:00
|
|
|
NULL,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("width",
|
|
|
|
|
"width",
|
|
|
|
|
"The pattern width",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("height",
|
|
|
|
|
"height",
|
|
|
|
|
"The pattern height",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("bpp",
|
|
|
|
|
"bpp",
|
|
|
|
|
"The pattern bpp",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-26 02:13:47 -07:00
|
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
2006-04-07 01:16:26 -07:00
|
|
|
g_object_unref (procedure);
|
2006-04-04 14:11:45 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* gimp-pattern-get-pixels
|
|
|
|
|
*/
|
2006-04-06 03:01:30 -07:00
|
|
|
procedure = gimp_procedure_new (pattern_get_pixels_invoker);
|
2008-04-04 03:58:56 -07:00
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
|
|
|
"gimp-pattern-get-pixels");
|
2019-09-08 14:40:34 -07:00
|
|
|
gimp_procedure_set_static_help (procedure,
|
|
|
|
|
"Retrieve information about the specified pattern (including pixels).",
|
|
|
|
|
"This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
|
|
|
|
|
NULL);
|
|
|
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
|
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
|
|
|
"Michael Natterer",
|
|
|
|
|
"2004");
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
|
gimp_param_spec_string ("name",
|
|
|
|
|
"name",
|
|
|
|
|
"The pattern name.",
|
2007-12-11 01:54:41 -08:00
|
|
|
FALSE, FALSE, TRUE,
|
2006-04-04 14:11:45 -07:00
|
|
|
NULL,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("width",
|
|
|
|
|
"width",
|
|
|
|
|
"The pattern width",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("height",
|
|
|
|
|
"height",
|
|
|
|
|
"The pattern height",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("bpp",
|
|
|
|
|
"bpp",
|
|
|
|
|
"The pattern bpp",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 05:04:56 -07:00
|
|
|
g_param_spec_int ("num-color-bytes",
|
|
|
|
|
"num color bytes",
|
|
|
|
|
"Number of pattern bytes",
|
|
|
|
|
0, G_MAXINT32, 0,
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-04 14:11:45 -07:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 06:04:34 -07:00
|
|
|
gimp_param_spec_uint8_array ("color-bytes",
|
|
|
|
|
"color bytes",
|
|
|
|
|
"The pattern data.",
|
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-26 02:13:47 -07:00
|
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
2006-04-07 01:16:26 -07:00
|
|
|
g_object_unref (procedure);
|
2006-04-04 14:11:45 -07:00
|
|
|
}
|