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);
    }
}
Beispiel #2
0
static void
gimp_foreground_select_tool_control (GimpTool       *tool,
                                     GimpToolAction  action,
                                     GimpDisplay    *display)
{
  GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);

  switch (action)
    {
    case GIMP_TOOL_ACTION_PAUSE:
    case GIMP_TOOL_ACTION_RESUME:
      break;

    case GIMP_TOOL_ACTION_HALT:
      {
        GList *list;

        gimp_foreground_select_tool_set_mask (fg_select, display, NULL);

        for (list = fg_select->strokes; list; list = list->next)
          {
            FgSelectStroke *stroke = list->data;

            g_free (stroke->points);
            g_slice_free (FgSelectStroke, stroke);
          }

        g_list_free (fg_select->strokes);
        fg_select->strokes = NULL;

        if (fg_select->state)
          {
            gimp_drawable_foreground_extract_siox_done (fg_select->state);
            fg_select->state = NULL;
          }

        tool->display = NULL;
      }
      break;
    }

  GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}