Exemplo n.º 1
0
Arquivo: spread.c Projeto: Minoos/gimp
static void
spread (GimpDrawable *drawable)
{
  GimpRgnIterator *iter;
  SpreadParam_t    param;

  param.pft      = gimp_pixel_fetcher_new (drawable, FALSE);
  param.gr       = g_rand_new ();
  param.x_amount = (spvals.spread_amount_x + 1) / 2;
  param.y_amount = (spvals.spread_amount_y + 1) / 2;
  param.width    = drawable->width;
  param.height   = drawable->height;

  iter = gimp_rgn_iterator_new (drawable, 0);
  gimp_rgn_iterator_dest (iter, spread_func, &param);
  gimp_rgn_iterator_free (iter);

  g_rand_free (param.gr);
}
Exemplo n.º 2
0
static void
polarize (GimpDrawable *drawable)
{
  GimpRgnIterator  *iter;
  GimpPixelFetcher *pft;
  GimpRGB           background;

  pft = gimp_pixel_fetcher_new (drawable, FALSE);

  gimp_context_get_background (&background);
  gimp_rgb_set_alpha (&background, 0.0);
  gimp_pixel_fetcher_set_bg_color (pft, &background);
  gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);

  gimp_progress_init (_("Polar coordinates"));

  iter = gimp_rgn_iterator_new (drawable, 0);
  gimp_rgn_iterator_dest (iter, polarize_func, pft);
  gimp_rgn_iterator_free (iter);

  gimp_pixel_fetcher_destroy (pft);
}
Exemplo n.º 3
0
static void
lens_distort (GimpDrawable *drawable)
{
  GimpRgnIterator  *iter;
  GimpPixelFetcher *pft;
  GimpRGB           background;

  lens_setup_calc (drawable->width, drawable->height);

  pft = gimp_pixel_fetcher_new (drawable, FALSE);

  gimp_context_get_background (&background);
  gimp_rgb_set_alpha (&background, 0.0);
  gimp_pixel_fetcher_set_bg_color (pft, &background);
  gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_BACKGROUND);

  gimp_progress_init (_("Lens distortion"));

  iter = gimp_rgn_iterator_new (drawable, 0);
  gimp_rgn_iterator_dest (iter, (GimpRgnFuncDest) lens_distort_func, pft);
  gimp_rgn_iterator_free (iter);

  gimp_pixel_fetcher_destroy (pft);
}
Exemplo n.º 4
0
static void
ripple (GimpDrawable *drawable,
        GimpPreview  *preview)
{
  RippleParam_t param;
  gint          edges;
  gint          period;

  param.pft       = gimp_pixel_fetcher_new (drawable, FALSE);
  param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
  param.width     = drawable->width;
  param.height    = drawable->height;

  edges  = rvals.edges;
  period = rvals.period;

  if (rvals.tile)
    {
      rvals.edges = WRAP;
      rvals.period = (param.width / (param.width / rvals.period) *
                      (rvals.orientation == GIMP_ORIENTATION_HORIZONTAL) +
                      param.height / (param.height / rvals.period) *
                      (rvals.orientation == GIMP_ORIENTATION_VERTICAL));
    }

  if (preview)
    {
      guchar *buffer, *d;
      gint    bpp = gimp_drawable_bpp (drawable->drawable_id);
      gint    width, height;
      gint    x, y;
      gint    x1, y1;

      gimp_preview_get_position (preview, &x1, &y1);
      gimp_preview_get_size (preview, &width, &height);

      d = buffer = g_new (guchar, width * height * bpp);

      for (y = 0; y < height ; y++)
        for (x = 0; x < width ; x++)
          {
            if (rvals.orientation == GIMP_ORIENTATION_VERTICAL)
              ripple_vertical (x1 + x, y1 + y, d, bpp, &param);
            else
              ripple_horizontal (x1 + x, y1 + y, d, bpp, &param);

            d += bpp;
          }

      gimp_preview_draw_buffer (preview, buffer, width * bpp);
      g_free (buffer);
    }
  else
    {
      GimpRgnIterator *iter;

      iter = gimp_rgn_iterator_new (drawable, 0);

      gimp_rgn_iterator_dest (iter,
                              rvals.orientation == GIMP_ORIENTATION_VERTICAL ?
                              ripple_vertical :
                              ripple_horizontal,
                              &param);

      gimp_rgn_iterator_free (iter);
    }

  rvals.edges  = edges;
  rvals.period = period;

  gimp_pixel_fetcher_destroy (param.pft);
}