static GimpValueArray * patterns_get_pattern_data_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *name; gchar *actual_name = NULL; gint32 width = 0; gint32 height = 0; gint32 mask_bpp = 0; gint32 length = 0; guint8 *mask_data = NULL; name = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { GimpPattern *pattern; if (name && strlen (name)) pattern = gimp_pdb_get_pattern (gimp, name, error); else pattern = gimp_context_get_pattern (context); if (pattern) { actual_name = g_strdup (gimp_object_get_name (pattern)); width = gimp_temp_buf_get_width (pattern->mask); height = gimp_temp_buf_get_height (pattern->mask); mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask)); length = gimp_temp_buf_get_data_size (pattern->mask); mask_data = g_memdup (gimp_temp_buf_get_data (pattern->mask), length); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { g_value_take_string (gimp_value_array_index (return_vals, 1), actual_name); g_value_set_int (gimp_value_array_index (return_vals, 2), width); g_value_set_int (gimp_value_array_index (return_vals, 3), height); g_value_set_int (gimp_value_array_index (return_vals, 4), mask_bpp); g_value_set_int (gimp_value_array_index (return_vals, 5), length); gimp_value_take_int8array (gimp_value_array_index (return_vals, 6), mask_data, length); } return return_vals; }
static GimpValueArray * file_load_thumbnail_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filename; gint32 width = 0; gint32 height = 0; gint32 thumb_data_count = 0; guint8 *thumb_data = NULL; filename = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename); if (pixbuf) { width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); thumb_data_count = 3 * width * height; thumb_data = g_memdup (gdk_pixbuf_get_pixels (pixbuf), thumb_data_count); g_object_unref (pixbuf); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { 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), thumb_data_count); gimp_value_take_int8array (gimp_value_array_index (return_vals, 4), thumb_data, thumb_data_count); } return return_vals; }
static GimpValueArray * image_get_color_profile_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; GimpImage *image; gint32 num_bytes = 0; guint8 *profile_data = NULL; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); if (success) { GimpColorProfile *profile; profile = gimp_image_get_color_profile (image); if (profile) { const guint8 *data; gsize length; data = gimp_color_profile_get_icc_profile (profile, &length); profile_data = g_memdup (data, length); num_bytes = length; g_object_unref (profile); } } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes); gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes); } return return_vals; }
static GimpValueArray * procedural_db_get_data_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *identifier; gint32 bytes = 0; guint8 *data = NULL; identifier = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { gchar *canonical = gimp_canonicalize_identifier (identifier); const guint8 *orig_data; orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager, canonical, &bytes); g_free (canonical); if (orig_data) data = g_memdup (orig_data, bytes); else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { g_value_set_int (gimp_value_array_index (return_vals, 1), bytes); gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), data, bytes); } return return_vals; }
static GValueArray * brushes_get_brush_data_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gchar *actual_name = NULL; gdouble opacity = 0.0; gint32 spacing = 0; gint32 paint_mode = 0; gint32 width = 0; gint32 height = 0; gint32 length = 0; guint8 *mask_data = NULL; name = g_value_get_string (&args->values[0]); if (success) { GimpBrush *brush; if (name && strlen (name)) { brush = (GimpBrush *) gimp_container_get_child_by_name (gimp->brush_factory->container, name); } else { brush = gimp_context_get_brush (context); } if (brush) { actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush))); opacity = 1.0; spacing = gimp_brush_get_spacing (brush); paint_mode = 0; width = brush->mask->width; height = brush->mask->height; length = brush->mask->height * brush->mask->width; mask_data = g_memdup (temp_buf_data (brush->mask), length); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) { g_value_take_string (&return_vals->values[1], actual_name); g_value_set_double (&return_vals->values[2], opacity); g_value_set_int (&return_vals->values[3], spacing); g_value_set_enum (&return_vals->values[4], paint_mode); g_value_set_int (&return_vals->values[5], width); g_value_set_int (&return_vals->values[6], height); g_value_set_int (&return_vals->values[7], length); gimp_value_take_int8array (&return_vals->values[8], mask_data, length); } return return_vals; }