static GimpValueArray * image_scale_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 new_width; gint32 new_height; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); new_width = g_value_get_int (gimp_value_array_index (args, 1)); new_height = g_value_get_int (gimp_value_array_index (args, 2)); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); if (progress) gimp_progress_start (progress, FALSE, _("Scaling")); gimp_image_scale (image, new_width, new_height, pdb_context->interpolation, progress); if (progress) gimp_progress_end (progress); } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static void gimp_pdb_context_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GimpPDBContext *options = GIMP_PDB_CONTEXT (object); switch (property_id) { case PROP_ANTIALIAS: g_value_set_boolean (value, options->antialias); break; case PROP_FEATHER: g_value_set_boolean (value, options->feather); break; case PROP_FEATHER_RADIUS_X: g_value_set_double (value, options->feather_radius_x); break; case PROP_FEATHER_RADIUS_Y: g_value_set_double (value, options->feather_radius_y); break; case PROP_SAMPLE_MERGED: g_value_set_boolean (value, options->sample_merged); break; case PROP_SAMPLE_CRITERION: g_value_set_enum (value, options->sample_criterion); break; case PROP_SAMPLE_THRESHOLD: g_value_set_double (value, options->sample_threshold); break; case PROP_SAMPLE_TRANSPARENT: g_value_set_boolean (value, options->sample_transparent); break; case PROP_INTERPOLATION: g_value_set_enum (value, options->interpolation); break; case PROP_TRANSFORM_DIRECTION: g_value_set_enum (value, options->transform_direction); break; case PROP_TRANSFORM_RESIZE: g_value_set_enum (value, options->transform_resize); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_pdb_context_finalize (GObject *object) { GimpPDBContext *context = GIMP_PDB_CONTEXT (object); if (context->paint_options_list) { g_object_unref (context->paint_options_list); context->paint_options_list = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); }
GimpContext * gimp_pdb_context_new (Gimp *gimp, GimpContext *parent, gboolean set_parent) { GimpPDBContext *context; GList *list; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL); context = g_object_new (GIMP_TYPE_PDB_CONTEXT, "gimp", gimp, "name", "PDB Context", NULL); gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0); if (set_parent) { gimp_context_define_properties (GIMP_CONTEXT (context), GIMP_CONTEXT_ALL_PROPS_MASK, FALSE); gimp_context_set_parent (GIMP_CONTEXT (context), parent); for (list = gimp_get_paint_info_iter (gimp); list; list = g_list_next (list)) { GimpPaintInfo *info = list->data; gimp_container_add (context->paint_options_list, GIMP_OBJECT (info->paint_options)); } } else { for (list = GIMP_LIST (GIMP_PDB_CONTEXT (parent)->paint_options_list)->list; list; list = g_list_next (list)) { GimpPaintOptions *options = gimp_config_duplicate (list->data); gimp_container_add (context->paint_options_list, GIMP_OBJECT (options)); g_object_unref (options); } } return GIMP_CONTEXT (context); }
static GimpValueArray * image_select_contiguous_color_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; GimpDrawable *drawable; gdouble x; gdouble y; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); operation = g_value_get_enum (gimp_value_array_index (args, 1)); drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp); x = g_value_get_double (gimp_value_array_index (args, 3)); y = g_value_get_double (gimp_value_array_index (args, 4)); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); if (pdb_context->sample_merged || gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, 0, error)) { gimp_channel_select_fuzzy (gimp_image_get_mask (image), drawable, pdb_context->sample_merged, x, y, pdb_context->sample_threshold, pdb_context->sample_transparent, pdb_context->sample_criterion, pdb_context->diagonal_neighbors, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y); } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static GimpValueArray * image_select_round_rectangle_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; gdouble x; gdouble y; gdouble width; gdouble height; gdouble corner_radius_x; gdouble corner_radius_y; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); operation = g_value_get_enum (gimp_value_array_index (args, 1)); x = g_value_get_double (gimp_value_array_index (args, 2)); y = g_value_get_double (gimp_value_array_index (args, 3)); width = g_value_get_double (gimp_value_array_index (args, 4)); height = g_value_get_double (gimp_value_array_index (args, 5)); corner_radius_x = g_value_get_double (gimp_value_array_index (args, 6)); corner_radius_y = g_value_get_double (gimp_value_array_index (args, 7)); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); gimp_channel_select_round_rect (gimp_image_get_mask (image), (gint) x, (gint) y, (gint) width, (gint) height, corner_radius_x, corner_radius_y, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y, TRUE); } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static GValueArray * image_select_color_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; GimpDrawable *drawable; GimpRGB color; image = gimp_value_get_image (&args->values[0], gimp); operation = g_value_get_enum (&args->values[1]); drawable = gimp_value_get_drawable (&args->values[2], gimp); gimp_value_get_rgb (&args->values[3], &color); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); if (pdb_context->sample_merged || gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error)) { gimp_channel_select_by_color (gimp_image_get_mask (image), drawable, pdb_context->sample_merged, &color, (gint) (pdb_context->sample_threshold * 255.99), pdb_context->sample_transparent, pdb_context->sample_criterion, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y); } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static GValueArray * image_select_ellipse_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; gdouble x; gdouble y; gdouble width; gdouble height; image = gimp_value_get_image (&args->values[0], gimp); operation = g_value_get_enum (&args->values[1]); x = g_value_get_double (&args->values[2]); y = g_value_get_double (&args->values[3]); width = g_value_get_double (&args->values[4]); height = g_value_get_double (&args->values[5]); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); gimp_channel_select_ellipse (gimp_image_get_mask (image), (gint) x, (gint) y, (gint) width, (gint) height, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y, TRUE); } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static GimpValueArray * image_select_polygon_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; gint32 num_segs; const gdouble *segs; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); operation = g_value_get_enum (gimp_value_array_index (args, 1)); num_segs = g_value_get_int (gimp_value_array_index (args, 2)); segs = gimp_value_get_floatarray (gimp_value_array_index (args, 3)); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); gimp_channel_select_polygon (gimp_image_get_mask (image), _("Free Select"), num_segs / 2, (GimpVector2 *) segs, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y, TRUE); } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static GimpValueArray * image_select_item_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; GimpItem *item; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); operation = g_value_get_enum (gimp_value_array_index (args, 1)); item = gimp_value_get_item (gimp_value_array_index (args, 2), gimp); if (success) { if (gimp_pdb_item_is_attached (item, image, 0, error)) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); gimp_item_to_selection (item, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y); } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }