void gimp_drawable_foreground_extract (GimpDrawable *drawable, GimpForegroundExtractMode mode, GimpDrawable *mask, GimpProgress *progress) { SioxState *state; const gdouble sensitivity[3] = { SIOX_DEFAULT_SENSITIVITY_L, SIOX_DEFAULT_SENSITIVITY_A, SIOX_DEFAULT_SENSITIVITY_B }; g_return_if_fail (GIMP_IS_DRAWABLE (mask)); g_return_if_fail (mode == GIMP_FOREGROUND_EXTRACT_SIOX); state = gimp_drawable_foreground_extract_siox_init (drawable, 0, 0, gimp_item_get_width (GIMP_ITEM (mask)), gimp_item_get_height (GIMP_ITEM (mask))); if (state) { gimp_drawable_foreground_extract_siox (mask, state, SIOX_REFINEMENT_RECALCULATE, SIOX_DEFAULT_SMOOTHNESS, sensitivity, FALSE, progress); gimp_drawable_foreground_extract_siox_done (state); } }
static void gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel, GimpDisplay *display) { GimpForegroundSelectTool *fg_select; GimpForegroundSelectOptions *options; GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable; GimpScanConvert *scan_convert; GimpChannel *mask; const GimpVector2 *points; gint n_points; drawable = gimp_image_get_active_drawable (image); fg_select = GIMP_FOREGROUND_SELECT_TOOL (free_sel); options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (free_sel); if (fg_select->idle_id) { g_source_remove (fg_select->idle_id); fg_select->idle_id = 0; } if (! drawable) return; scan_convert = gimp_scan_convert_new (); gimp_free_select_tool_get_points (free_sel, &points, &n_points); gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE); mask = gimp_channel_new (image, gimp_image_get_width (image), gimp_image_get_height (image), "foreground-extraction", NULL); gimp_scan_convert_render_value (scan_convert, gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)), 0, 0, 128); gimp_scan_convert_free (scan_convert); if (fg_select->strokes) { GList *list; gimp_set_busy (image->gimp); /* apply foreground and background markers */ for (list = fg_select->strokes; list; list = list->next) gimp_foreground_select_tool_stroke (mask, list->data); if (fg_select->state) gimp_drawable_foreground_extract_siox (GIMP_DRAWABLE (mask), fg_select->state, fg_select->refinement, options->smoothness, options->sensitivity, ! options->contiguous, GIMP_PROGRESS (fg_select)); fg_select->refinement = SIOX_REFINEMENT_NO_CHANGE; gimp_unset_busy (image->gimp); } else { gint x1, y1; gint x2, y2; g_object_set (options, "background", FALSE, NULL); gimp_foreground_select_tool_get_area (mask, &x1, &y1, &x2, &y2); if (fg_select->state) g_warning ("state should be NULL here"); fg_select->state = gimp_drawable_foreground_extract_siox_init (drawable, x1, y1, x2 - x1, y2 - y1); } gimp_foreground_select_tool_set_mask (fg_select, display, mask); g_object_unref (mask); }