Re: Proposition : GeglInterpolator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've added the implementation to bug report : Bug 360888 – Interpolation for operations

GeglInterpolator
 + GeglInterpolatorNearest
 |
 + GeglInterpolatorLinear
| + GeglInterpolatorCubic | + GeglInterpolatorLanczos


usage :

void displacementmap(GeglBuffer *src,
GeglBuffer *aux,
GeglBuffer *dst,
gdouble scale,
gint cx,
gint cy)
{
gint i, j, k;
gint dst_pos;
gdouble dx, dy, xc, yc;
gfloat *buf = g_malloc0 (4 * 4 * 4);
gfloat *aux_buf = g_malloc0 (aux->width * aux->height * 4 * 4);
gfloat *dst_buf = g_malloc0 (dst->width * dst->height * 4 * 4);
gegl_buffer_get_fmt (aux, aux_buf, babl_format ("RGBA float"));
gegl_buffer_get_fmt (dst, dst_buf, babl_format ("RaGaBaA float"));

* GeglInterpolatorCubic *interpolator = g_object_new (GEGL_TYPE_INTERPOLATOR_CUBIC,
"input", src,
"format", babl_format ("RaGaBaA float"),
NULL);
gegl_interpolator_prepare(GEGL_INTERPOLATOR(interpolator)) ; *

for (i = 0; i < src->height; i++)
for (j = 0; j < src->width; j++)
{
/* Calculate x/y - offset relative to origin */
dx = (gdouble) j / (src->width-1.0);
dy = (gdouble) i / (src->height-1.0);
xc = j + (gint) (displacement (aux, aux_buf, dx, dy, cx) * scale);
yc = i + (gint) (displacement (aux, aux_buf, dx, dy, cy) * scale);
* gegl_interpolator_get(GEGL_INTERPOLATOR(interpolator), xc, yc, buf); /* returns a interpolated pixel in dst */ *

dst_pos = (i * dst->width + j )* 4;
for (k = 0 ; k < 4 ; k++)
dst_buf[dst_pos+k]= buf[k];
}

gegl_buffer_set_fmt (dst, dst_buf, babl_format ("RaGaBaA float"));
g_object_unref (interpolator);
g_free (aux_buf);
g_free (dst_buf);
}


_______________________________________________
Gegl-developer mailing list
Gegl-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer

[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux