Пример #1
0
void
drawable_erode_cmd_callback (GtkAction *action,
                             gpointer   data)
{
  GimpImage    *image;
  GimpDrawable *drawable;
  GimpDisplay  *display;
  GeglNode     *node;
  return_if_no_drawable (image, drawable, data);
  return_if_no_display (display, data);

  node = gegl_node_new_child (NULL,
                              "operation",       "gegl:value-propagate",
                              "mode",            1, /* GEGL_VALUE_PROPAGATE_MODE_BLACK */
                              "lower-threshold", 0.0,
                              "upper-threshold", 1.0,
                              "rate",            1.0,
                              "top",             TRUE,
                              "left",            TRUE,
                              "right",           TRUE,
                              "bottom",          TRUE,
                              "value",           TRUE,
                              "alpha",           FALSE,
                              NULL);

  gimp_drawable_apply_operation (drawable, GIMP_PROGRESS (display),
                                 _("Erode"), node);
  g_object_unref (node);

  gimp_image_flush (image);
}
Пример #2
0
void
gimp_drawable_brightness_contrast (GimpDrawable *drawable,
                                   GimpProgress *progress,
                                   gint          brightness,
                                   gint          contrast)
{
  GimpBrightnessContrastConfig *config;

  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
  g_return_if_fail (! gimp_drawable_is_indexed (drawable));
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));

  config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
                         "brightness", brightness / 127.0,
                         "contrast",   contrast   / 127.0,
                         NULL);

  if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
    {
      GeglNode *node;

      node = g_object_new (GEGL_TYPE_NODE,
                           "operation", "gimp:brightness-contrast",
                           "config",    config,
                           NULL);

      gimp_drawable_apply_operation (drawable, progress,
                                     C_("undo-type", "Brightness-Contrast")
                                     , node, TRUE);
      g_object_unref (node);
    }
  else
    {
      GimpLut *lut;

      lut = brightness_contrast_lut_new (config->brightness / 2.0,
                                         config->contrast,
                                         gimp_drawable_bytes (drawable));

      gimp_drawable_process_lut (drawable, progress,
                                 C_("undo-type", "Brightness-Contrast"),
                                 lut);
      gimp_lut_free (lut);
    }

  g_object_unref (config);
}
Пример #3
0
void
gimp_drawable_posterize (GimpDrawable *drawable,
                         GimpProgress *progress,
                         gint          levels)
{
  GimpPosterizeConfig *config;

  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
  g_return_if_fail (! gimp_drawable_is_indexed (drawable));
  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));

  config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG,
                         "levels", levels,
                         NULL);

  if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
    {
      GeglNode *node;

      node = g_object_new (GEGL_TYPE_NODE,
                           "operation", "gimp:posterize",
                           NULL);
      gegl_node_set (node,
                     "config", config,
                     NULL);

      gimp_drawable_apply_operation (drawable, progress, _("Posterize"),
                                     node, TRUE);
      g_object_unref (node);
    }
  else
    {
      GimpLut *lut;

      lut = posterize_lut_new (config->levels, gimp_drawable_bytes (drawable));

      gimp_drawable_process_lut (drawable, progress, _("Posterize"), lut);
      gimp_lut_free (lut);
    }

  g_object_unref (config);
}
Пример #4
0
static void
gimp_drawable_curves (GimpDrawable     *drawable,
                      GimpProgress     *progress,
                      GimpCurvesConfig *config)
{
  if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (drawable))->gimp))
    {
      GeglNode *node;

      node = g_object_new (GEGL_TYPE_NODE,
                           "operation", "gimp:curves",
                           NULL);
      gegl_node_set (node,
                     "config", config,
                     NULL);

      gimp_drawable_apply_operation (drawable, progress, C_("undo-type", "Curves"),
                                     node, TRUE);
      g_object_unref (node);
    }
  else
    {
      GimpLut *lut = gimp_lut_new ();
      Curves   cruft;

      gimp_curves_config_to_cruft (config, &cruft,
                                   gimp_drawable_is_rgb (drawable));

      gimp_lut_setup (lut,
                      (GimpLutFunc) curves_lut_func,
                      &cruft,
                      gimp_drawable_bytes (drawable));

      gimp_drawable_process_lut (drawable, progress, C_("undo-type", "Curves"), lut);
      gimp_lut_free (lut);
    }
}