Example #1
0
/* GeglOperationPointFilter gives us a linear buffer to operate on
 * in our requested pixel format
 */
static gboolean
process (GeglOperation       *op,
         void                *in_buf,
         void                *out_buf,
         glong                n_pixels,
         const GeglRectangle *roi,
         gint                 level)
{
    GeglProperties   *o         = GEGL_PROPERTIES (op);
    gfloat       *in_pixel  = in_buf;
    gfloat       *out_pixel = out_buf;
    const gfloat *coeffs    = o->user_data;

    in_pixel = in_buf;
    out_pixel = out_buf;

    if (! coeffs)
    {
        coeffs = o->user_data = preprocess (o);
    }

    while (n_pixels--)
    {
        out_pixel[0] = in_pixel[0] * coeffs[0];
        out_pixel[1] = in_pixel[1] * coeffs[1];
        out_pixel[2] = in_pixel[2] * coeffs[2];
        out_pixel[3] = in_pixel[3];

        in_pixel += 4;
        out_pixel += 4;
    }

    return TRUE;
}
Example #2
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  gint        problem;
  gint        width, height;
  Babl        *format = NULL;
  GError *err = NULL;
  GFile *infile = NULL;
  GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &infile, &err);
  WARN_IF_ERROR(err);
  problem = gegl_buffer_import_png (output, stream, 0, 0,
                                    &width, &height, format, &err);
  WARN_IF_ERROR(err);
  g_input_stream_close(stream, NULL, NULL);

  if (problem)
    {
      g_object_unref(infile);
      g_object_unref(stream);
      g_warning ("%s failed to open file %s for reading.",
                 G_OBJECT_TYPE_NAME (operation), o->path);
      return FALSE;
    }
  if (infile) g_object_unref(infile);
  g_object_unref(stream);
  return TRUE;
}
Example #3
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties   *o = GEGL_PROPERTIES (operation);
  GeglBuffer   *temp_in;
  GeglRectangle compute  = gegl_operation_get_required_for_output (operation, "input", result);

  if (result->width == 0 ||
      result->height== 0 ||
      o->radius < 1.0)
    {
      output = g_object_ref (input);
    }
  else
    {
      temp_in = gegl_buffer_create_sub_buffer (input, &compute);
      snn_percentile (temp_in, output, o->radius, o->percentile, o->pairs);
      g_object_unref (temp_in);
    }

  return  TRUE;
}
Example #4
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  Priv *p = (Priv*) o->user_data;

  if (p->config != NULL)
    {
      if (p->decoder != NULL)
        {
          if (decode_from_stream (p->stream, p->decoder) < 0)
            {
              g_warning ("failed decoding WebP image file");
              cleanup (operation);
              return FALSE;
            }

          g_input_stream_close (G_INPUT_STREAM (p->stream), NULL, NULL);
          g_clear_object (&p->stream);

          WebPIDelete (p->decoder);
          p->decoder = NULL;
        }

      gegl_buffer_set (output, result, 0, p->format,
                       p->config->output.u.RGBA.rgba,
                       p->config->output.u.RGBA.stride);
    }

  return FALSE;
}
Example #5
0
static void
prepare (GeglOperation *operation)
{
  GeglProperties          *o       = GEGL_PROPERTIES (operation);
  GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
  const Babl              *format;

  if (o->direction == GEGL_ORIENTATION_HORIZONTAL)
    {
      op_area->left   = o->shift;
      op_area->right  = o->shift;
      op_area->top    = 0;
      op_area->bottom = 0;
    }
  else if (o->direction == GEGL_ORIENTATION_VERTICAL)
    {
      op_area->top    = o->shift;
      op_area->bottom = o->shift;
      op_area->left   = 0;
      op_area->right  = 0;
    }

  format = gegl_operation_get_source_format (operation, "input");

  gegl_operation_set_format (operation, "input",  format);
  gegl_operation_set_format (operation, "output", format);
}
Example #6
0
/* For GeglOperationPointFilter subclasses, we operate on linear
 * buffers with a pixel count.
 */
static gboolean
process (GeglOperation       *op,
         void                *in_buf,
         void                *out_buf,
         glong                n_pixels,
         const GeglRectangle *roi,
         gint                 level)
{
  /* Retrieve a pointer to GeglProperties structure which contains all the
   * chanted properties
   */
  GeglProperties *o = GEGL_PROPERTIES (op);
  gfloat     * GEGL_ALIGNED in_pixel;
  gfloat     * GEGL_ALIGNED out_pixel;
  gfloat      brightness, contrast;
  glong       i;

  in_pixel   = in_buf;
  out_pixel  = out_buf;

  brightness = o->brightness;
  contrast   = o->contrast;

  for (i=0; i<n_pixels; i++)
    {
      out_pixel[0] = (in_pixel[0] - 0.5f) * contrast + brightness + 0.5;
      out_pixel[1] = (in_pixel[1] - 0.5f) * contrast + brightness + 0.5;
      out_pixel[2] = (in_pixel[2] - 0.5f) * contrast + brightness + 0.5;
      out_pixel[3] = in_pixel[3]; /* copy the alpha */
      in_pixel  += 4;
      out_pixel += 4;
    }
  return TRUE;
}
Example #7
0
static GeglRectangle
get_required_for_output (GeglOperation       *operation,
                         const gchar         *input_pad,
                         const GeglRectangle *roi)
{
  GeglRectangle result = *roi;

  if (! is_nop (operation))
    {
      GeglProperties *o       = GEGL_PROPERTIES (operation);
      GeglRectangle  *in_rect = gegl_operation_source_get_bounding_box (operation, "input");

      if (in_rect)
        {
          switch (o->mode)
            {
            case GEGL_SPHERIZE_MODE_RADIAL:
              result = *in_rect;
              break;

            case GEGL_SPHERIZE_MODE_HORIZONTAL:
              result.x     = in_rect->x;
              result.width = in_rect->width;
              break;

            case GEGL_SPHERIZE_MODE_VERTICAL:
              result.y      = in_rect->y;
              result.height = in_rect->height;
              break;
            }
        }
    }

  return result;
}
Example #8
0
/* Compute the region for which this operation is defined.
 */
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
  GeglRectangle  result = {0,0,0,0};
  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
  GeglProperties *o = GEGL_PROPERTIES (operation);

  if (!in_rect){
        return result;
  }

  if (o->clip) {
    gegl_rectangle_copy(&result, in_rect);
  }
  else {
    result.x = in_rect->x;
    result.y = in_rect->y;
    result.width = result.height = sqrt (in_rect->width * in_rect->width + in_rect->height * in_rect->height) * MAX ((o->o_x + 1),  (o->o_y + 1)) * 2;
  }

  result.width = result.width * o->output_scale;
  result.height = result.height * o->output_scale;

  #ifdef TRACE
    g_warning ("< get_bounding_box result = %dx%d+%d+%d", result.width, result.height, result.x, result.y);
  #endif
  return result;
}
Example #9
0
/* Perform the specified operation.
 */
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o            = GEGL_PROPERTIES (operation);
  GeglRectangle   boundary     = gegl_operation_get_bounding_box (operation);
  GeglRectangle   eff_boundary = get_effective_area (operation);
  const Babl     *format       = babl_format ("RaGaBaA float");

#ifdef DO_NOT_USE_BUFFER_SAMPLE
 g_warning ("NOT USING BUFFER SAMPLE!");
#endif
  apply_mirror (o->m_angle,
                o->r_angle,
                o->n_segs,
                o->c_x * boundary.width,
                o->c_y * boundary.height,
                o->o_x * (eff_boundary.width  - eff_boundary.x) + eff_boundary.x,
                o->o_y * (eff_boundary.height - eff_boundary.y) + eff_boundary.y,
                o->input_scale / 100,
                o->clip,
                o->warp,
                format,
                input,
                &eff_boundary,
                output,
                &boundary,
                result,
                level);
  return TRUE;
}
Example #10
0
static GeglRectangle
gegl_rgbe_load_get_bounding_box (GeglOperation *operation)
{
  GeglProperties       *o        = GEGL_PROPERTIES (operation);
  GeglRectangle     result   = {0,0,0,0};
  rgbe_file        *file;
  guint             width, height;

  gegl_operation_set_format (operation,
                             "output",
                             babl_format (FORMAT));

  file = rgbe_load_path (o->path);
  if (!file)
      goto cleanup;

  if (!rgbe_get_size (file, &width, &height))
      goto cleanup;

  result.width  = width;
  result.height = height;

cleanup:
  rgbe_file_free (file);
  return result;
}
Example #11
0
File: v4l2.c Project: jonnor/gegl
static void
prepare (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  Priv *p= (Priv*)o->user_data;

  if (p == NULL)
    init (o);
  p = (Priv*)o->user_data;

  gegl_operation_set_format (operation, "output",
                            babl_format ("R'G'B'A u8"));


  if (!p->fd)
    {
      p->force_format = 1;
      p->dev_name = o->path;
      p->io = IO_METHOD_MMAP;
      p->w = o->width;
      p->h = o->height;

      open_device (p);
      init_device (p);

      start_capturing (p);
    }
}
Example #12
0
/* Perform the specified operation.
 */
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o        = GEGL_PROPERTIES (operation);
  GeglRectangle   boundary = gegl_operation_get_bounding_box (operation);
  const Babl     *format   = babl_format ("RaGaBaA float");

  apply_whirl_pinch (o->whirl,
                     o->pinch,
                     o->radius,
                     boundary.width / 2.0,
                     boundary.height / 2.0,
                     format,
                     input,
                     &boundary,
                     output,
                     &boundary,
                     result,
                     level);
  return TRUE;
}
Example #13
0
static void
prepare (GeglOperation *operation)
{
  GeglProperties *o             = GEGL_PROPERTIES (operation);
  const Babl     *input_format  = NULL;
  const Babl     *output_format = (o->linear ?
                                   babl_format ("Y float") :
                                   babl_format ("Y' float"));

  switch (o->component)
    {
    case GEGL_COMPONENT_EXTRACT_ALPHA:
      input_format = babl_format ("YA float");
      break;

    case GEGL_COMPONENT_EXTRACT_RGB_RED:
    case GEGL_COMPONENT_EXTRACT_RGB_GREEN:
    case GEGL_COMPONENT_EXTRACT_RGB_BLUE:
      input_format = babl_format ("R'G'B' float");
      break;

    case GEGL_COMPONENT_EXTRACT_HUE:
    case GEGL_COMPONENT_EXTRACT_HSV_SATURATION:
    case GEGL_COMPONENT_EXTRACT_HSV_VALUE:
      input_format = babl_format ("HSV float");
      break;

    case GEGL_COMPONENT_EXTRACT_HSL_LIGHTNESS:
    case GEGL_COMPONENT_EXTRACT_HSL_SATURATION:
      input_format = babl_format ("HSL float");
      break;

    case GEGL_COMPONENT_EXTRACT_CMYK_CYAN:
    case GEGL_COMPONENT_EXTRACT_CMYK_MAGENTA:
    case GEGL_COMPONENT_EXTRACT_CMYK_YELLOW:
    case GEGL_COMPONENT_EXTRACT_CMYK_KEY:
      input_format = babl_format ("CMYK float");
      break;

    case GEGL_COMPONENT_EXTRACT_YCBCR_Y:
    case GEGL_COMPONENT_EXTRACT_YCBCR_CB:
    case GEGL_COMPONENT_EXTRACT_YCBCR_CR:
      input_format = babl_format ("Y'CbCr float");
      break;

    case GEGL_COMPONENT_EXTRACT_LAB_L:
    case GEGL_COMPONENT_EXTRACT_LAB_A:
    case GEGL_COMPONENT_EXTRACT_LAB_B:
      input_format = babl_format ("CIE Lab float");
      break;

    case GEGL_COMPONENT_EXTRACT_LCH_C:
    case GEGL_COMPONENT_EXTRACT_LCH_H:
      input_format = babl_format ("CIE LCH(ab) float");
      break;
    }

  gegl_operation_set_format (operation, "input", input_format);
  gegl_operation_set_format (operation, "output", output_format);
}
Example #14
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GOutputStream *stream;
  GFile *file = NULL;
  GError *error = NULL;
  gboolean status = TRUE;

  stream = gegl_gio_open_output_stream (NULL, o->path, &file, &error);
  if (stream == NULL)
    {
      status = FALSE;
      g_warning ("%s", error->message);
      goto cleanup;
    }

  if (!export_webp (operation, input, result, stream))
    {
      status = FALSE;
      g_warning ("could not export WebP file");
      goto cleanup;
    }

cleanup:
  g_clear_object (&stream);
  g_clear_object (&file);
  return status;
}
Example #15
0
static gboolean
process (GeglOperation       *operation,
         void                *in_buf,
         void                *out_buf,
         glong                n_pixels,
         const GeglRectangle *roi,
         gint                 level)
{
  GeglProperties *o  = GEGL_PROPERTIES (operation);
  const Babl *format = gegl_operation_get_format (operation, "input");

  memcpy (out_buf, in_buf, n_pixels * babl_format_get_bytes_per_pixel (format));

  if (o->cache != (void *) operation->node->cache)
    {
      if (o->cache)
        {
          g_object_unref (o->cache);
          o->cache = NULL;
        }

      if (operation->node->cache)
        o->cache = g_object_ref (operation->node->cache);
    }

  return TRUE;
}
Example #16
0
static void
path_changed (GeglPath            *path,
              const GeglRectangle *roi,
              GeglOperation       *operation)
{
  GeglRectangle   rect;
  GeglProperties *o    = GEGL_PROPERTIES (operation);
  WarpPrivate    *priv = (WarpPrivate *) o->user_data;

  /* mark the processed stroke as invalid, so that we recheck it against the
   * new path upon the next call to process().
   */
  if (priv)
    priv->processed_stroke_valid = FALSE;

  /* invalidate the incoming rectangle */

  rect.x      = floor (roi->x - o->size/2);
  rect.y      = floor (roi->y - o->size/2);
  rect.width  = ceil (roi->x + roi->width  + o->size/2) - rect.x;
  rect.height = ceil (roi->y + roi->height + o->size/2) - rect.y;

  /* we don't want to clear the cached data right away; we potentially do this
   * in process(), if the cached path is not an initial segment of the new
   * path.  block our INVALIDATED handler so that the cache isn't cleared.
   */
  g_signal_handlers_block_by_func (operation->node,
                                   node_invalidated, operation);

  gegl_operation_invalidate (operation, &rect, FALSE);

  g_signal_handlers_unblock_by_func (operation->node,
                                     node_invalidated, operation);
}
Example #17
0
static void
prepare (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  const Babl *format = babl_format ("RGBA float");

  GeglRectangle  *whole_region;
  AlParamsType   *params;

  if (! o->user_data)
    o->user_data = g_slice_new0 (AlParamsType);

  params = (AlParamsType *) o->user_data;

  whole_region = gegl_operation_source_get_bounding_box (operation, "input");

  if (whole_region)
    {
      params->a = 0.5 * whole_region->width;
      params->b = 0.5 * whole_region->height;
      params->c = MIN (params->a, params->b);
      params->asqr = params->a * params->a;
      params->bsqr = params->b * params->b;
      params->csqr = params->c * params->c;
    }

  gegl_color_get_pixel (o->background_color, format, params->bg_color);

  gegl_operation_set_format (operation, "input", format);
  gegl_operation_set_format (operation, "output", format);
}
Example #18
0
/* Pass-through when trying to perform IIR on an infinite plane
 */
static gboolean
operation_process (GeglOperation        *operation,
                   GeglOperationContext *context,
                   const gchar          *output_prop,
                   const GeglRectangle  *result,
                   gint                  level)
{
  GeglOperationClass  *operation_class;
  GeglProperties          *o = GEGL_PROPERTIES (operation);
  GeglGblur1dFilter    filter  = filter_disambiguation (o->filter, o->std_dev);

  operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class);

  if (filter == GEGL_GBLUR_1D_IIR)
    {
      const GeglRectangle *in_rect =
        gegl_operation_source_get_bounding_box (operation, "input");

      if (in_rect && gegl_rectangle_is_infinite_plane (in_rect))
        {
          gpointer in = gegl_operation_context_get_object (context, "input");
          gegl_operation_context_take_object (context, "output",
                                              g_object_ref (G_OBJECT (in)));
          return TRUE;
        }
    }
  /* chain up, which will create the needed buffers for our actual
   * process function
   */
  return operation_class->process (operation, context, output_prop, result,
                                   gegl_operation_context_get_level (context));
}
Example #19
0
static gboolean
process (GeglOperation       *operation,
         void                *in_buf,
         void                *out_buf,
         glong                n_pixels,
         const GeglRectangle *roi,
         gint                 level)
{
  GeglProperties *o      = GEGL_PROPERTIES (operation);
  const Babl *format = babl_format ("R'G'B'A float");
  gfloat      color[4];
  gint        x;

  gfloat *in_buff = in_buf;
  gfloat *out_buff = out_buf;

  gegl_color_get_pixel (o->color, format, color);

  for (x = 0; x < n_pixels; x++)
    {
      color_to_alpha (color, in_buff, out_buff);
      in_buff  += 4;
      out_buff += 4;
    }

  return TRUE;
}
Example #20
0
static void
prepare (GeglOperation *operation)
{
  GeglOperationAreaFilter *area      = GEGL_OPERATION_AREA_FILTER (operation);
  GeglProperties          *o         = GEGL_PROPERTIES (operation);
  const Babl              *in_format = gegl_operation_get_source_format (operation, "input");
  const Babl              *format    = babl_format ("RGB float");

  area->left   =
  area->right  =
  area->top    =
  area->bottom = o->radius;

  o->user_data = g_renew (gint, o->user_data, o->radius + 1);
  init_neighborhood_outline (o->neighborhood, o->radius, o->user_data);

  if (in_format)
    {
      if (babl_format_has_alpha (in_format))
        format = babl_format ("RGBA float");
    }

  gegl_operation_set_format (operation, "input", format);
  gegl_operation_set_format (operation, "output", format);
}
Example #21
0
static gboolean
is_nop (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GeglRectangle  *in_rect;

  if (fabs (o->curvature) < EPSILON || fabs (o->amount) < EPSILON)
    return TRUE;

  in_rect = gegl_operation_source_get_bounding_box (operation, "input");

  switch (o->mode)
    {
    case GEGL_SPHERIZE_MODE_RADIAL:
      return in_rect->width < 1 || in_rect->height < 1;

    case GEGL_SPHERIZE_MODE_HORIZONTAL:
      return in_rect->width < 1;

    case GEGL_SPHERIZE_MODE_VERTICAL:
      return in_rect->height < 1;
    }

  g_return_val_if_reached (TRUE);
}
Example #22
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties    *o = GEGL_PROPERTIES (operation);
  GeglRectangle  boundary;
  const Babl    *format;
  GeglSampler   *sampler;
  gfloat        *dst_buf;
  gint           y;

  boundary = gegl_operation_get_bounding_box (operation);

  format = babl_format ("RGBA float");
  dst_buf = g_new0 (gfloat, result->width * result->height * 4);
  sampler = gegl_buffer_sampler_new_at_level (input, format, GEGL_SAMPLER_CUBIC, level);

  for (y = result->y; y < result->y + result->height; y++)
    fractaltrace (input, sampler, &boundary, dst_buf, result, o, y, o->fractal, format, level);

  gegl_buffer_set (output, result, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE);
  g_object_unref (sampler);

  g_free (dst_buf);

  gegl_buffer_sample_cleanup (input);

  return TRUE;
}
Example #23
0
static void
cleanup(GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  Priv *p = (Priv*) o->user_data;

  if (p != NULL)
    {
      if (p->decoder != NULL)
        WebPIDelete (p->decoder);
      p->decoder = NULL;
      if (p->config != NULL)
        WebPFreeDecBuffer (&p->config->output);
      if (p->config != NULL)
        g_free (p->config);
      p->config = NULL;

      if (p->stream != NULL)
        g_input_stream_close (G_INPUT_STREAM (p->stream), NULL, NULL);
      if (p->stream != NULL)
        g_clear_object (&p->stream);

      if (p->file != NULL)
        g_clear_object (&p->file);

      p->width = p->height = 0;
      p->format = NULL;
    }
}
Example #24
0
static GeglRectangle
get_bounding_box (GeglOperation * operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GeglRectangle result = { 0, 0, 0, 0 };
  gint width, height, depth;

  width = height = depth = 0;

  if (!query_jp2 (o->path, &width, &height, &depth, NULL))
    return result;

  result.width = width;
  result.height = height;

  switch (depth)
    {
    case 16:
      gegl_operation_set_format (operation, "output",
                                 babl_format ("R'G'B' u16"));
      break;

    case 8:
      gegl_operation_set_format (operation, "output",
                                 babl_format ("R'G'B' u8"));
      break;

    default:
      g_warning ("%s: Programmer stupidity error", G_STRLOC);
    }

  return result;
}
Example #25
0
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
  GeglProperties   *o = GEGL_PROPERTIES (operation);
  GeglRectangle result = {0,0,0,0};
  gint          width, height;
  gint          status;
  const Babl *  format;
  GError *err = NULL;
  GFile *infile = NULL;

  GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &infile, &err);
  WARN_IF_ERROR(err);
  if (!stream) return result;
  status = query_png(stream, &width, &height, &format, &err);
  WARN_IF_ERROR(err);
  g_input_stream_close(stream, NULL, NULL);

  if (status)
    {
      width = 0;
      height = 0;
    }

  gegl_operation_set_format (operation, "output", format);
  result.width  = width;
  result.height  = height;

  if (infile) g_object_unref(infile);
  g_object_unref(stream);
  return result;
}
Example #26
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties      *o = GEGL_PROPERTIES (operation);
  GeglBuffer          *temp_in;
  GeglRectangle        compute;

  if (gegl_operation_use_opencl (operation))
    if (cl_process (operation, input, output, result))
      return TRUE;

  compute = gegl_operation_get_required_for_output (operation, "input", result);

  if (o->radius < 1.0)
    {
      output = g_object_ref (input);
    }
  else
    {
      temp_in = gegl_buffer_create_sub_buffer (input, &compute);

      snn_mean (temp_in, output, result, o->radius, o->pairs);
      g_object_unref (temp_in);
    }

  return  TRUE;
}
Example #27
0
static void prepare (GeglOperation *operation)
{
  GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
  area->left = area->right = area->top = area->bottom =
      GEGL_PROPERTIES (operation)->radius;
  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
Example #28
0
File: gegl.c Project: jonnor/gegl
static void
prepare (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GeglNode *gegl, *input, *output;
  GError *error = NULL;

  gegl = operation->node;

  if (!o->user_data || !g_str_equal (o->user_data, o->string))
  {
    g_free (o->user_data);
    o->user_data = g_strdup (o->string);

  input  = gegl_node_get_input_proxy (gegl,  "input");
  output = gegl_node_get_output_proxy (gegl, "output");

  gegl_node_link_many (input, output, NULL);
  {
     gchar cwd[81920]; // XXX: should do better
     getcwd (cwd, sizeof(cwd));
  gegl_create_chain (o->string, input, output, 0.0,
                     gegl_node_get_bounding_box (input).height, cwd,
                     &error);
  }

  if (error)
  {
    gegl_node_set (gegl, "error", error->message, NULL);
    g_clear_error (&error);
  }
  else
    g_object_set (operation, "error", "", NULL);
  }
}
Example #29
0
static gboolean
process (GeglOperation       *operation,
         GeglBuffer          *input,
         GeglBuffer          *output,
         const GeglRectangle *result,
         gint                 level)
{
  GeglProperties *o      = GEGL_PROPERTIES (operation);
  GeglRectangle in_rect = *gegl_buffer_get_extent (input);
  GeglRectangle out_rect = *gegl_buffer_get_extent (output);
  PixelDuster    *duster = pixel_duster_new (input, output, &in_rect, &out_rect,
                                             o->seek_distance,
                                             1,
                                             o->min_neigh,
                                             o->min_iter,
                                             o->chance_try,
                                             o->chance_retry,
                                             1.0,
                                             1.0,
                                             operation);
  seed_db (duster);
  gegl_buffer_copy (input, NULL, GEGL_ABYSS_NONE, output, NULL);
  fprintf (stderr, "adding transparent probes");
  pixel_duster_add_probes_for_transparent (duster);
  fprintf (stderr, "\n");
  pixel_duster_fill (duster);
  pixel_duster_destroy (duster);

  return TRUE;
}
Example #30
0
static GeglRectangle
get_bounding_box (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GeglRectangle result = {0,0,0,0};

  if (o->width <= 0 || o->height <= 0)
  {
     GeglRectangle *in_rect;
     in_rect = gegl_operation_source_get_bounding_box (operation, "input");
     if (in_rect)
       {
          result = *in_rect;
       }
     else
     {
       result.width = 320;
       result.height = 200;
     }
  }
  else
  {
    result.width = o->width;
    result.height = o->height;
  }
  return result;
}