Exemplo n.º 1
0
static void
select_shrink_callback (GtkWidget *widget,
                        gdouble    size,
                        GimpUnit   unit,
                        gpointer   data)
{
  GimpImage *image  = GIMP_IMAGE (data);
  GtkWidget *button = g_object_get_data (G_OBJECT (widget), "edge-lock-toggle");
  gint       radius_x;
  gint       radius_y;

  radius_x = radius_y = select_shrink_pixels = ROUND (size);

  select_shrink_edge_lock =
    ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));

  if (unit != GIMP_UNIT_PIXEL)
    {
      gdouble factor;

      factor = (MAX (image->xresolution, image->yresolution) /
                MIN (image->xresolution, image->yresolution));

      if (image->xresolution == MIN (image->xresolution, image->yresolution))
        radius_y *= factor;
      else
        radius_x *= factor;
    }

  gimp_channel_shrink (gimp_image_get_mask (image), radius_x, radius_y,
                       select_shrink_edge_lock, TRUE);
  gimp_image_flush (image);
}
Exemplo n.º 2
0
static GimpValueArray *
selection_shrink_invoker (GimpProcedure         *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
                          GimpProgress          *progress,
                          const GimpValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 steps;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  steps = g_value_get_int (gimp_value_array_index (args, 1));

  if (success)
    {
      gimp_channel_shrink (gimp_image_get_mask (image),
                           steps, steps, FALSE, TRUE);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}