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-2003 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
|
|
|
*/
|
|
|
|
|
2007-01-09 18:52:47 +08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl. */
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
#include "pdb-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdatafactory.h"
|
2008-02-08 01:08:54 +08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-09-29 06:01:21 +08:00
|
|
|
#include "core/gimppattern.h"
|
2012-04-09 06:59:20 +08:00
|
|
|
#include "core/gimptempbuf.h"
|
2019-02-07 22:12:53 +08:00
|
|
|
#include "gegl/gimp-babl-compat.h"
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2008-02-08 01:08:54 +08:00
|
|
|
#include "gimppdb.h"
|
|
|
|
#include "gimppdb-utils.h"
|
|
|
|
#include "gimpprocedure.h"
|
2008-04-04 19:15:55 +08:00
|
|
|
#include "internal-procs.h"
|
2006-11-01 03:02:56 +08:00
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
static GimpValueArray *
|
2012-05-29 01:55:28 +08:00
|
|
|
pattern_get_info_invoker (GimpProcedure *procedure,
|
2012-05-04 06:50:23 +08:00
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
GError **error)
|
2004-09-29 06:01:21 +08:00
|
|
|
{
|
|
|
|
gboolean success = TRUE;
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *return_vals;
|
2006-04-03 00:03:32 +08:00
|
|
|
const gchar *name;
|
2019-08-15 20:04:56 +08:00
|
|
|
gint width = 0;
|
|
|
|
gint height = 0;
|
|
|
|
gint bpp = 0;
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
name = g_value_get_string (gimp_value_array_index (args, 0));
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
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)
|
|
|
|
{
|
2019-02-07 22:12:53 +08:00
|
|
|
const Babl *format;
|
|
|
|
|
|
|
|
format = gimp_babl_compat_u8_format (
|
|
|
|
gimp_temp_buf_get_format (pattern->mask));
|
|
|
|
|
2012-04-23 15:40:56 +08:00
|
|
|
width = gimp_temp_buf_get_width (pattern->mask);
|
|
|
|
height = gimp_temp_buf_get_height (pattern->mask);
|
2019-02-07 22:12:53 +08:00
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
2006-03-15 20:49:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
success = FALSE;
|
2004-09-29 06:01:21 +08:00
|
|
|
}
|
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
|
|
error ? *error : NULL);
|
2004-09-29 06:01:21 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
2012-05-04 06:50:23 +08: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-29 06:01:21 +08:00
|
|
|
}
|
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
return return_vals;
|
2004-09-29 06:01:21 +08:00
|
|
|
}
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
static GimpValueArray *
|
2012-05-29 01:55:28 +08:00
|
|
|
pattern_get_pixels_invoker (GimpProcedure *procedure,
|
2012-05-04 06:50:23 +08:00
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
GError **error)
|
2004-10-06 07:28:17 +08:00
|
|
|
{
|
|
|
|
gboolean success = TRUE;
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpValueArray *return_vals;
|
2006-04-03 00:03:32 +08:00
|
|
|
const gchar *name;
|
2019-08-15 20:04:56 +08:00
|
|
|
gint width = 0;
|
|
|
|
gint height = 0;
|
|
|
|
gint bpp = 0;
|
|
|
|
gint num_color_bytes = 0;
|
2004-10-06 11:23:09 +08:00
|
|
|
guint8 *color_bytes = NULL;
|
2004-10-06 07:28:17 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
name = g_value_get_string (gimp_value_array_index (args, 0));
|
2004-10-06 07:28:17 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
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)
|
|
|
|
{
|
2019-02-07 22: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 15:40:56 +08:00
|
|
|
width = gimp_temp_buf_get_width (pattern->mask);
|
|
|
|
height = gimp_temp_buf_get_height (pattern->mask);
|
2019-02-07 22:12:53 +08:00
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
2012-04-09 05:56:52 +08:00
|
|
|
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
|
2021-08-26 23:18:32 +08:00
|
|
|
color_bytes = g_memdup2 (data, num_color_bytes);
|
2019-02-07 22:12:53 +08:00
|
|
|
|
|
|
|
gimp_temp_buf_unlock (pattern->mask, data);
|
2004-10-06 07:28:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
|
2008-08-16 21:57:57 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
|
|
error ? *error : NULL);
|
2004-10-06 07:28:17 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
2012-05-04 06:50:23 +08: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 21:04:34 +08:00
|
|
|
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), color_bytes, num_color_bytes);
|
2004-10-06 07:28:17 +08:00
|
|
|
}
|
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
return return_vals;
|
2004-10-06 07:28:17 +08:00
|
|
|
}
|
|
|
|
|
2006-04-05 05:11:45 +08:00
|
|
|
void
|
2006-04-26 17:13:47 +08:00
|
|
|
register_pattern_procs (GimpPDB *pdb)
|
2004-10-06 07:28:17 +08:00
|
|
|
{
|
2006-04-05 05:11:45 +08:00
|
|
|
GimpProcedure *procedure;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gimp-pattern-get-info
|
|
|
|
*/
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = gimp_procedure_new (pattern_get_info_invoker);
|
2008-04-04 18:58:56 +08:00
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
|
|
"gimp-pattern-get-info");
|
2019-09-09 05:40:34 +08: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-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("name",
|
|
|
|
"name",
|
|
|
|
"The pattern name.",
|
2007-12-11 17:54:41 +08:00
|
|
|
FALSE, FALSE, TRUE,
|
2006-04-05 05:11:45 +08:00
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("width",
|
|
|
|
"width",
|
|
|
|
"The pattern width",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("height",
|
|
|
|
"height",
|
|
|
|
"The pattern height",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("bpp",
|
|
|
|
"bpp",
|
|
|
|
"The pattern bpp",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
2006-04-07 16:16:26 +08:00
|
|
|
g_object_unref (procedure);
|
2006-04-05 05:11:45 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* gimp-pattern-get-pixels
|
|
|
|
*/
|
2006-04-06 18:01:30 +08:00
|
|
|
procedure = gimp_procedure_new (pattern_get_pixels_invoker);
|
2008-04-04 18:58:56 +08:00
|
|
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
|
|
"gimp-pattern-get-pixels");
|
2019-09-09 05:40:34 +08: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-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("name",
|
|
|
|
"name",
|
|
|
|
"The pattern name.",
|
2007-12-11 17:54:41 +08:00
|
|
|
FALSE, FALSE, TRUE,
|
2006-04-05 05:11:45 +08:00
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("width",
|
|
|
|
"width",
|
|
|
|
"The pattern width",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("height",
|
|
|
|
"height",
|
|
|
|
"The pattern height",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("bpp",
|
|
|
|
"bpp",
|
|
|
|
"The pattern bpp",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 20:04:56 +08:00
|
|
|
g_param_spec_int ("num-color-bytes",
|
|
|
|
"num color bytes",
|
|
|
|
"Number of pattern bytes",
|
|
|
|
0, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_add_return_value (procedure,
|
2019-08-15 21:04:34 +08:00
|
|
|
gimp_param_spec_uint8_array ("color-bytes",
|
|
|
|
"color bytes",
|
|
|
|
"The pattern data.",
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-26 17:13:47 +08:00
|
|
|
gimp_pdb_register_procedure (pdb, procedure);
|
2006-04-07 16:16:26 +08:00
|
|
|
g_object_unref (procedure);
|
2006-04-05 05:11:45 +08:00
|
|
|
}
|