34
36
#include "core/gimplist.h"
35
37
#include "core/gimppattern.h"
37
static ProcRecord pattern_get_info_proc;
38
static ProcRecord pattern_get_pixels_proc;
41
register_pattern_procs (Gimp *gimp)
43
procedural_db_register (gimp, &pattern_get_info_proc);
44
procedural_db_register (gimp, &pattern_get_pixels_proc);
48
pattern_get_info_invoker (Gimp *gimp,
50
GimpProgress *progress,
39
#include "internal_procs.h"
43
pattern_get_info_invoker (GimpProcedure *procedure,
46
GimpProgress *progress,
47
const GValueArray *args)
53
49
gboolean success = TRUE;
54
Argument *return_args;
56
GimpPattern *pattern = NULL;
50
GValueArray *return_vals;
58
name = (gchar *) args[0].value.pdb_pointer;
59
if (name == NULL || !g_utf8_validate (name, -1, NULL))
56
name = g_value_get_string (&args->values[0]);
64
pattern = (GimpPattern *)
60
GimpPattern *pattern = (GimpPattern *)
65
61
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
67
success = (pattern != NULL);
65
width = pattern->mask->width;
66
height = pattern->mask->height;
67
bpp = pattern->mask->bytes;
70
return_args = procedural_db_return_args (&pattern_get_info_proc, success);
73
return_vals = gimp_procedure_get_return_values (procedure, success);
74
return_args[1].value.pdb_int = pattern->mask->width;
75
return_args[2].value.pdb_int = pattern->mask->height;
76
return_args[3].value.pdb_int = pattern->mask->bytes;
77
g_value_set_int (&return_vals->values[1], width);
78
g_value_set_int (&return_vals->values[2], height);
79
g_value_set_int (&return_vals->values[3], bpp);
82
static ProcArg pattern_get_info_inargs[] =
91
static ProcArg pattern_get_info_outargs[] =
110
static ProcRecord pattern_get_info_proc =
112
"gimp_pattern_get_info",
113
"Retrieve information about the specified pattern.",
114
"This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
115
"Michael Natterer <mitch@gimp.org>",
121
pattern_get_info_inargs,
123
pattern_get_info_outargs,
124
{ { pattern_get_info_invoker } }
128
pattern_get_pixels_invoker (Gimp *gimp,
129
GimpContext *context,
130
GimpProgress *progress,
86
pattern_get_pixels_invoker (GimpProcedure *procedure,
89
GimpProgress *progress,
90
const GValueArray *args)
133
92
gboolean success = TRUE;
134
Argument *return_args;
93
GValueArray *return_vals;
136
98
gint32 num_color_bytes = 0;
137
99
guint8 *color_bytes = NULL;
138
GimpPattern *pattern = NULL;
140
name = (gchar *) args[0].value.pdb_pointer;
141
if (name == NULL || !g_utf8_validate (name, -1, NULL))
101
name = g_value_get_string (&args->values[0]);
146
pattern = (GimpPattern *)
105
GimpPattern *pattern = (GimpPattern *)
147
106
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
110
width = pattern->mask->width;
111
height = pattern->mask->height;
112
bpp = pattern->mask->bytes;
151
113
num_color_bytes = pattern->mask->height * pattern->mask->width *
152
114
pattern->mask->bytes;
153
115
color_bytes = g_memdup (temp_buf_data (pattern->mask),
160
return_args = procedural_db_return_args (&pattern_get_pixels_proc, success);
122
return_vals = gimp_procedure_get_return_values (procedure, success);
164
return_args[1].value.pdb_int = pattern->mask->width;
165
return_args[2].value.pdb_int = pattern->mask->height;
166
return_args[3].value.pdb_int = pattern->mask->bytes;
167
return_args[4].value.pdb_int = num_color_bytes;
168
return_args[5].value.pdb_pointer = color_bytes;
126
g_value_set_int (&return_vals->values[1], width);
127
g_value_set_int (&return_vals->values[2], height);
128
g_value_set_int (&return_vals->values[3], bpp);
129
g_value_set_int (&return_vals->values[4], num_color_bytes);
130
gimp_value_take_int8array (&return_vals->values[5], color_bytes, num_color_bytes);
174
static ProcArg pattern_get_pixels_inargs[] =
183
static ProcArg pattern_get_pixels_outargs[] =
203
"Number of pattern bytes"
212
static ProcRecord pattern_get_pixels_proc =
214
"gimp_pattern_get_pixels",
215
"Retrieve information about the specified pattern (including pixels).",
216
"This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
217
"Michael Natterer <mitch@gimp.org>",
223
pattern_get_pixels_inargs,
225
pattern_get_pixels_outargs,
226
{ { pattern_get_pixels_invoker } }
137
register_pattern_procs (GimpPDB *pdb)
139
GimpProcedure *procedure;
142
* gimp-pattern-get-info
144
procedure = gimp_procedure_new (pattern_get_info_invoker);
145
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-pattern-get-info");
146
gimp_procedure_set_static_strings (procedure,
147
"gimp-pattern-get-info",
148
"Retrieve information about the specified pattern.",
149
"This procedure retrieves information about the specified pattern. This includes the pattern extents (width and height).",
150
"Michael Natterer <mitch@gimp.org>",
154
gimp_procedure_add_argument (procedure,
155
gimp_param_spec_string ("name",
160
GIMP_PARAM_READWRITE));
161
gimp_procedure_add_return_value (procedure,
162
gimp_param_spec_int32 ("width",
165
G_MININT32, G_MAXINT32, 0,
166
GIMP_PARAM_READWRITE));
167
gimp_procedure_add_return_value (procedure,
168
gimp_param_spec_int32 ("height",
170
"The pattern height",
171
G_MININT32, G_MAXINT32, 0,
172
GIMP_PARAM_READWRITE));
173
gimp_procedure_add_return_value (procedure,
174
gimp_param_spec_int32 ("bpp",
177
G_MININT32, G_MAXINT32, 0,
178
GIMP_PARAM_READWRITE));
179
gimp_pdb_register_procedure (pdb, procedure);
180
g_object_unref (procedure);
183
* gimp-pattern-get-pixels
185
procedure = gimp_procedure_new (pattern_get_pixels_invoker);
186
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-pattern-get-pixels");
187
gimp_procedure_set_static_strings (procedure,
188
"gimp-pattern-get-pixels",
189
"Retrieve information about the specified pattern (including pixels).",
190
"This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
191
"Michael Natterer <mitch@gimp.org>",
195
gimp_procedure_add_argument (procedure,
196
gimp_param_spec_string ("name",
201
GIMP_PARAM_READWRITE));
202
gimp_procedure_add_return_value (procedure,
203
gimp_param_spec_int32 ("width",
206
G_MININT32, G_MAXINT32, 0,
207
GIMP_PARAM_READWRITE));
208
gimp_procedure_add_return_value (procedure,
209
gimp_param_spec_int32 ("height",
211
"The pattern height",
212
G_MININT32, G_MAXINT32, 0,
213
GIMP_PARAM_READWRITE));
214
gimp_procedure_add_return_value (procedure,
215
gimp_param_spec_int32 ("bpp",
218
G_MININT32, G_MAXINT32, 0,
219
GIMP_PARAM_READWRITE));
220
gimp_procedure_add_return_value (procedure,
221
gimp_param_spec_int32 ("num-color-bytes",
223
"Number of pattern bytes",
225
GIMP_PARAM_READWRITE));
226
gimp_procedure_add_return_value (procedure,
227
gimp_param_spec_int8_array ("color-bytes",
230
GIMP_PARAM_READWRITE));
231
gimp_pdb_register_procedure (pdb, procedure);
232
g_object_unref (procedure);