예제 #1
0
static void
gegl_sampler_cubic_init (GeglSamplerCubic *self)
{
 GEGL_SAMPLER (self)->context_rect.x = -1;
 GEGL_SAMPLER (self)->context_rect.y = -1;
 GEGL_SAMPLER (self)->context_rect.width = 4;
 GEGL_SAMPLER (self)->context_rect.height = 4;
 GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
 self->b=1.0;
 self->c=0.0;
 self->type = g_strdup("cubic");
 if (strcmp (self->type, "cubic"))
    {
      /* cubic B-spline */
      self->b = 0.0;
      self->c = 0.5;
    }
  else if (strcmp (self->type, "catmullrom"))
    {
      /* Catmull-Rom spline */
      self->b = 1.0;
      self->c = 0.0;
    }
  else if (strcmp (self->type, "formula"))
    {
      self->c = (1.0 - self->b) / 2.0;
    }
}
예제 #2
0
static void
set_property (GObject      *object,
              guint         prop_id,
              const GValue *value,
              GParamSpec   *pspec)
{
  GeglSamplerLanczos *self         = GEGL_SAMPLER_LANCZOS (object);

  switch (prop_id)
    {
      case PROP_LANCZOS_WIDTH:
        {
        self->lanczos_width = g_value_get_int (value);
        GEGL_SAMPLER (self)->context_rect[0].x = - self->lanczos_width;
        GEGL_SAMPLER (self)->context_rect[0].y = - self->lanczos_width;
        GEGL_SAMPLER (self)->context_rect[0].width = self->lanczos_width*2+1;
        GEGL_SAMPLER (self)->context_rect[0].height = self->lanczos_width*2+1;
        }
        break;

      case PROP_LANCZOS_SAMPLES:
        self->lanczos_spp = g_value_get_int (value);
        break;

      default:
        break;
    }
}
예제 #3
0
static void
gegl_sampler_linear_init (GeglSamplerLinear *self)
{
  GEGL_SAMPLER (self)->level[0].context_rect.x      = -1 -   LINEAR_EXTRA_ELBOW_ROOM;
  GEGL_SAMPLER (self)->level[0].context_rect.y      = -1 -   LINEAR_EXTRA_ELBOW_ROOM;
  GEGL_SAMPLER (self)->level[0].context_rect.width  =  3 + 2*LINEAR_EXTRA_ELBOW_ROOM;
  GEGL_SAMPLER (self)->level[0].context_rect.height =  3 + 2*LINEAR_EXTRA_ELBOW_ROOM;
  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
}
예제 #4
0
/*
 * It would seem that x=y=0 and width=height=1 should be enough, but
 * apparently safety w.r.t. round off or something else makes things
 * work better with width=height=3 and centering.
 */
static void
gegl_sampler_nearest_init (GeglSamplerNearest *self)
{
  GEGL_SAMPLER (self)->context_rect[0].x = 0;
  GEGL_SAMPLER (self)->context_rect[0].y = 0;
  GEGL_SAMPLER (self)->context_rect[0].width = 1;
  GEGL_SAMPLER (self)->context_rect[0].height = 1;
  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
}
예제 #5
0
/*
 * It would seem that x=y=0 and width=height=1 should be enough, but
 * apparently safety w.r.t. round off or something else makes things
 * work better with width=height=3 and centering.
 */
static void
gegl_sampler_nearest_init (GeglSamplerNearest *self)
{
  GEGL_SAMPLER (self)->level[0].context_rect.x = 0;
  GEGL_SAMPLER (self)->level[0].context_rect.y = 0;
  GEGL_SAMPLER (self)->level[0].context_rect.width = 1;
  GEGL_SAMPLER (self)->level[0].context_rect.height = 1;
  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
}
예제 #6
0
파일: gegl-sampler.c 프로젝트: jonnor/gegl
static void
set_property (GObject      *object,
              guint         property_id,
              const GValue *value,
              GParamSpec   *pspec)
{
  GeglSampler *self = GEGL_SAMPLER (object);

  switch (property_id)
    {
      case PROP_BUFFER:
        gegl_sampler_set_buffer (self, GEGL_BUFFER (g_value_get_object (value)));
        break;

      case PROP_FORMAT:
        self->format = g_value_get_pointer (value);
        break;

      case PROP_LEVEL:
        self->lvel = g_value_get_int  (value);
        break;

      default:
        break;
    }
}
예제 #7
0
파일: gegl-sampler.c 프로젝트: jonnor/gegl
static void
get_property (GObject    *object,
              guint       property_id,
              GValue     *value,
              GParamSpec *pspec)
{
  GeglSampler *self = GEGL_SAMPLER (object);

  switch (property_id)
    {
      case PROP_BUFFER:
        g_value_set_object (value, self->buffer);
        break;

      case PROP_FORMAT:
        g_value_set_pointer (value, (void*)self->format);
        break;

      case PROP_LEVEL:
        g_value_set_int (value, self->lvel);
        break;

      default:
        break;
    }
}
예제 #8
0
파일: gegl-sampler.c 프로젝트: bantu/gegl
static void
dispose (GObject *gobject)
{
  GeglSampler *sampler = GEGL_SAMPLER (gobject);

  /* This call handles unreffing the buffer and disconnecting signals */
  set_buffer (sampler, NULL);

  G_OBJECT_CLASS (gegl_sampler_parent_class)->dispose (gobject);
}
예제 #9
0
파일: gegl-sampler.c 프로젝트: bantu/gegl
static void
finalize (GObject *gobject)
{
  GeglSampler *sampler = GEGL_SAMPLER (gobject);
  int i = 0;
  do {
    if (sampler->sampler_buffer[i])
      {
        g_free (sampler->sampler_buffer[i]);
        sampler->sampler_buffer[i] = NULL;
      }
  } while ( ++i<GEGL_SAMPLER_MIPMAP_LEVELS );
  G_OBJECT_CLASS (gegl_sampler_parent_class)->finalize (gobject);
}
예제 #10
0
파일: gegl-sampler.c 프로젝트: bantu/gegl
static void
buffer_contents_changed (GeglBuffer          *buffer,
                         const GeglRectangle *changed_rect,
                         gpointer             userdata)
{
  GeglSampler *self = GEGL_SAMPLER (userdata);

  /*
   * Invalidate all mipmap levels by setting the width and height of the
   * rectangles to zero. The x and y coordinates do not matter any more, so we
   * can just call memset to do this.
   * XXX: it might be faster to only invalidate rects that intersect
   *      changed_rect
   */
  memset (self->sampler_rectangle, 0, sizeof (self->sampler_rectangle));

  return;
}