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
2023-05-31 07:12:04 -07:00
static GimpValueArray *
pattern_get_by_name_invoker ( GimpProcedure * procedure ,
Gimp * gimp ,
GimpContext * context ,
GimpProgress * progress ,
const GimpValueArray * args ,
GError * * error )
{
gboolean success = TRUE ;
GimpValueArray * return_vals ;
const gchar * name ;
GimpPattern * pattern = NULL ;
name = g_value_get_string ( gimp_value_array_index ( args , 0 ) ) ;
if ( success )
{
2023-07-19 06:26:26 -07:00
pattern = GIMP_PATTERN ( gimp_pdb_get_resource ( gimp , GIMP_TYPE_PATTERN , name , GIMP_PDB_DATA_ACCESS_READ , error ) ) ;
2023-05-31 07:12:04 -07:00
if ( ! pattern )
success = FALSE ;
}
return_vals = gimp_procedure_get_return_values ( procedure , success ,
error ? * error : NULL ) ;
if ( success )
g_value_set_object ( gimp_value_array_index ( return_vals , 1 ) , pattern ) ;
return return_vals ;
}
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 ;
2022-09-05 16:28:35 -07:00
GimpPattern * pattern ;
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
2022-09-05 16:28:35 -07:00
pattern = g_value_get_object ( gimp_value_array_index ( args , 0 ) ) ;
2004-09-28 15:01:21 -07:00
if ( success )
{
2022-09-05 16:28:35 -07:00
const Babl * format ;
2004-09-28 15:01:21 -07:00
2022-09-05 16:28:35 -07:00
format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format ( pattern - > mask ) ) ;
2019-02-07 06:12:53 -08:00
2022-09-05 16:28:35 -07:00
width = gimp_temp_buf_get_width ( pattern - > mask ) ;
height = gimp_temp_buf_get_height ( pattern - > mask ) ;
bpp = babl_format_get_bytes_per_pixel ( format ) ;
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 ;
2022-09-05 16:28:35 -07:00
GimpPattern * pattern ;
2019-08-15 05:04:56 -07:00
gint width = 0 ;
gint height = 0 ;
gint bpp = 0 ;
2023-05-23 14:37:46 -07:00
GBytes * color_bytes = NULL ;
2004-10-05 16:28:17 -07:00
2022-09-05 16:28:35 -07:00
pattern = g_value_get_object ( gimp_value_array_index ( args , 0 ) ) ;
2004-10-05 16:28:17 -07:00
if ( success )
{
2022-09-05 16:28:35 -07: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 ) ;
width = gimp_temp_buf_get_width ( pattern - > mask ) ;
height = gimp_temp_buf_get_height ( pattern - > mask ) ;
bpp = babl_format_get_bytes_per_pixel ( format ) ;
2023-05-23 14:37:46 -07:00
color_bytes = g_bytes_new ( data , gimp_temp_buf_get_data_size ( pattern - > mask ) ) ;
2022-09-05 16:28:35 -07:00
gimp_temp_buf_unlock ( pattern - > mask , data ) ;
2004-10-05 16:28:17 -07:00
}
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 ) ;
2023-05-23 14:37:46 -07:00
g_value_take_boxed ( gimp_value_array_index ( return_vals , 4 ) , 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 ;
2023-05-31 07:12:04 -07:00
/*
* gimp - pattern - get - by - name
*/
procedure = gimp_procedure_new ( pattern_get_by_name_invoker ) ;
gimp_object_set_static_name ( GIMP_OBJECT ( procedure ) ,
" gimp-pattern-get-by-name " ) ;
gimp_procedure_set_static_help ( procedure ,
" Returns the pattern with the given name. " ,
" Returns the pattern with the given name. " ,
NULL ) ;
gimp_procedure_set_static_attribution ( procedure ,
" Michael Natterer <mitch@gimp.org> " ,
" Michael Natterer " ,
" 2023 " ) ;
gimp_procedure_add_argument ( procedure ,
gimp_param_spec_string ( " name " ,
" name " ,
" The name of the pattern " ,
FALSE , FALSE , TRUE ,
NULL ,
GIMP_PARAM_READWRITE ) ) ;
gimp_procedure_add_return_value ( procedure ,
gimp_param_spec_pattern ( " pattern " ,
" pattern " ,
" The pattern " ,
FALSE ,
GIMP_PARAM_READWRITE ) ) ;
gimp_pdb_register_procedure ( pdb , procedure ) ;
g_object_unref ( procedure ) ;
2006-04-04 14:11:45 -07:00
/*
* 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 ,
2022-09-05 16:28:35 -07:00
" Gets information about the pattern. " ,
" Gets information about the pattern: the pattern extents (width and height) and bytes per pixel. " ,
2019-09-08 14:40:34 -07:00
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 ,
2022-09-05 16:28:35 -07:00
gimp_param_spec_pattern ( " pattern " ,
" pattern " ,
" The pattern " ,
FALSE ,
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 ( " 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 ,
2022-09-05 16:28:35 -07:00
" Gets information about the pattern (including pixels). " ,
" Gets information about the pattern: the pattern extents (width and height), its bpp, and its pixel data. The pixel data is an array in C or a list in some languages. " ,
2019-09-08 14:40:34 -07:00
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 ,
2022-09-05 16:28:35 -07:00
gimp_param_spec_pattern ( " pattern " ,
" pattern " ,
" The pattern " ,
FALSE ,
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 ( " 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 ,
2023-05-23 14:37:46 -07:00
g_param_spec_boxed ( " color-bytes " ,
" color bytes " ,
" The pattern data. " ,
G_TYPE_BYTES ,
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
}