Commit f8561793 authored by Caleb Michael Moore's avatar Caleb Michael Moore

cairo filter improvements

parent c1ea9819
2005-10-19 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-cairo-draw.c: series of hacks to make filters work
* rsvg-filter.c: use the new bbox system used in rsvg-cairo for filters
* rsvg-base.c: moved RsvgCairoBbox to RsvgBbox
2005-10-16 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-cairo-draw.c: No need to new0() image data, it just wastes CPU
......
......@@ -1381,3 +1381,108 @@ rsvg_render_free (RsvgRender * render)
{
render->free (render);
}
void rsvg_bbox_init(RsvgBbox * self, double * affine)
{
int i;
self->virgin = 1;
for (i = 0; i < 6; i++)
self->affine[i] = affine[i];
}
void rsvg_bbox_insert(RsvgBbox * dst, RsvgBbox * src)
{
double affine[6];
double xmin = dst->x, ymin = dst->y;
double xmax = dst->x + dst->w, ymax = dst->y + dst->h;
int i;
if (src->virgin)
return;
_rsvg_affine_invert(affine, dst->affine);
_rsvg_affine_multiply(affine, src->affine, affine);
for (i = 0; i < 4; i++)
{
double rx, ry, x, y;
rx = src->x + src->w * (double)(i % 2);
ry = src->y + src->h * (double)(i / 2);
x = affine[0] * rx + affine[2] * ry + affine[4];
y = affine[1] * rx + affine[3] * ry + affine[5];
if (dst->virgin)
{
xmin = xmax = x;
ymin = ymax = y;
dst->virgin = 0;
}
else
{
if (x < xmin)
xmin = x;
if (x > xmax)
xmax = x;
if (y < ymin)
ymin = y;
if (y > ymax)
ymax = y;
}
}
dst->x = xmin;
dst->y = ymin;
dst->w = xmax - xmin;
dst->h = ymax - ymin;
}
void rsvg_bbox_clip(RsvgBbox * dst, RsvgBbox * src)
{
double affine[6];
double xmin = dst->x + dst->w, ymin = dst->y + dst->h;
double xmax = dst->x, ymax = dst->y;
int i;
if (src->virgin)
return;
_rsvg_affine_invert(affine, dst->affine);
_rsvg_affine_multiply(affine, src->affine, affine);
for (i = 0; i < 4; i++)
{
double rx, ry, x, y;
rx = src->x + src->w * (double)(i % 2);
ry = src->y + src->h * (double)(i / 2);
x = affine[0] * rx + affine[2] * ry + affine[4];
y = affine[1] * rx + affine[3] * ry + affine[5];
if (dst->virgin)
{
xmin = xmax = x;
ymin = ymax = y;
dst->virgin = 0;
}
else
{
if (x < xmin)
xmin = x;
if (x > xmax)
xmax = x;
if (y < ymin)
ymin = y;
if (y > ymax)
ymax = y;
}
}
if (xmin < dst->x)
xmin = dst->x;
if (ymin < dst->y)
ymin = dst->y;
if (xmax > dst->x + dst->w)
xmax = dst->x + dst->w;
if (ymax > dst->y + dst->h)
ymax = dst->y + dst->h;
dst->x = xmin;
dst->w = xmax - xmin;
dst->y = ymin;
dst->h = ymax - ymin;
}
......@@ -149,7 +149,7 @@ rsvg_cairo_clip_render_new(cairo_t * cr)
}
void
rsvg_cairo_clip (RsvgDrawingCtx *ctx, RsvgClipPath *clip, RsvgCairoBbox *bbox)
rsvg_cairo_clip (RsvgDrawingCtx *ctx, RsvgClipPath *clip, RsvgBbox *bbox)
{
RsvgCairoRender * save = (RsvgCairoRender *)ctx->render;
double affinesave[6];
......
......@@ -35,7 +35,7 @@ G_BEGIN_DECLS
void
rsvg_cairo_clip (RsvgDrawingCtx *ctx, RsvgClipPath *clip,
RsvgCairoBbox *bbox);
RsvgBbox *bbox);
G_END_DECLS
......
......@@ -39,6 +39,8 @@
#include <math.h>
#include <string.h>
void rsvg_cairo_to_pixbuf_noaa(guint8 *pixels, int rowstride, int height);
void rsvg_pixbuf_to_cairo_noaa(guint8 *pixels, int rowstride, int height);
static void
rsvg_pixmap_destroy (gchar *pixels, gpointer data)
......@@ -76,7 +78,7 @@ _set_source_rsvg_linear_gradient (cairo_t *cr,
RsvgLinearGradient *linear,
guint32 current_color_rgb,
guint8 opacity,
RsvgCairoBbox bbox)
RsvgBbox bbox)
{
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
......@@ -121,7 +123,7 @@ _set_source_rsvg_radial_gradient (cairo_t *cr,
RsvgRadialGradient *radial,
guint32 current_color_rgb,
guint8 opacity,
RsvgCairoBbox bbox)
RsvgBbox bbox)
{
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
......@@ -186,7 +188,7 @@ static void
_set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
RsvgPattern *rsvg_pattern,
guint8 opacity,
RsvgCairoBbox bbox)
RsvgBbox bbox)
{
RsvgCairoRender *render = (RsvgCairoRender *)ctx->render;
RsvgPattern local_pattern = *rsvg_pattern;
......@@ -341,7 +343,7 @@ _set_source_rsvg_paint_server (RsvgDrawingCtx *ctx,
guint32 current_color_rgb,
RsvgPaintServer *ps,
guint8 opacity,
RsvgCairoBbox bbox,
RsvgBbox bbox,
guint32 current_colour)
{
RsvgCairoRender *render = (RsvgCairoRender *)ctx->render;
......@@ -391,7 +393,7 @@ rsvg_cairo_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef *bpath_def)
int i;
gdouble xmin = 0, ymin = 0, xmax = 0, ymax = 0;
int virgin = 1, need_tmpbuf = 0;
RsvgCairoBbox bbox;
RsvgBbox bbox;
if (state->fill == NULL && state->stroke == NULL)
return;
......@@ -450,14 +452,14 @@ rsvg_cairo_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef *bpath_def)
}
}
rsvg_cairo_bbox_init(&bbox, state->affine);
rsvg_bbox_init(&bbox, state->affine);
bbox.x = xmin;
bbox.y = ymin;
bbox.w = xmax - xmin;
bbox.h = ymax - ymin;
bbox.virgin = 0;
rsvg_cairo_bbox_insert(&render->bbox, &bbox);
rsvg_bbox_insert(&render->bbox, &bbox);
if (state->fill != NULL) {
int opacity;
......@@ -522,7 +524,7 @@ void rsvg_cairo_render_image (RsvgDrawingCtx *ctx, const GdkPixbuf * pixbuf,
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
int j;
RsvgCairoBbox bbox;
RsvgBbox bbox;
if (pixbuf == NULL)
return;
......@@ -611,19 +613,19 @@ void rsvg_cairo_render_image (RsvgDrawingCtx *ctx, const GdkPixbuf * pixbuf,
cairo_restore (render->cr);
rsvg_cairo_bbox_init(&bbox, state->affine);
rsvg_bbox_init(&bbox, state->affine);
bbox.x = pixbuf_x;
bbox.y = pixbuf_y;
bbox.w = w;
bbox.h = h;
bbox.virgin = 0;
rsvg_cairo_bbox_insert(&render->bbox, &bbox);
rsvg_bbox_insert(&render->bbox, &bbox);
}
static cairo_surface_t *
rsvg_cairo_generate_mask(RsvgMask * self, RsvgDrawingCtx *ctx,
RsvgCairoBbox * bbox)
RsvgBbox * bbox)
{
cairo_surface_t *surface;
cairo_t *mask_cr, *save_cr;
......@@ -716,7 +718,7 @@ rsvg_cairo_push_render_stack (RsvgDrawingCtx *ctx)
RsvgCairoRender *render = (RsvgCairoRender *)ctx->render;
cairo_surface_t *surface;
cairo_t *child_cr;
RsvgCairoBbox *bbox;
RsvgBbox *bbox;
RsvgState *state = rsvg_state_current(ctx);
gboolean lateclip = FALSE;
......@@ -761,10 +763,10 @@ rsvg_cairo_push_render_stack (RsvgDrawingCtx *ctx)
render->cr_stack = g_list_prepend(render->cr_stack, render->cr);
render->cr = child_cr;
bbox = g_new(RsvgCairoBbox, 1);
bbox = g_new(RsvgBbox, 1);
*bbox = render->bbox;
render->bb_stack = g_list_prepend(render->bb_stack, bbox);
rsvg_cairo_bbox_init(&render->bbox,state->affine);
rsvg_bbox_init(&render->bbox,state->affine);
}
void
......@@ -799,29 +801,20 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx *ctx)
if (state->filter)
{
GdkPixbuf * pixbuf = render->pixbuf_stack->data;
RsvgIRect bounds;
RsvgCairoBbox bbox;
double affine[6];
_rsvg_affine_identity(affine);
rsvg_cairo_bbox_init(&bbox, affine);
rsvg_cairo_bbox_insert(&bbox, &render->bbox);
bounds.x0 = bbox.x;
bounds.y0 = bbox.y;
bounds.x1 = bbox.w + bbox.x;
bounds.y1 = bbox.h + bbox.y;
render->pixbuf_stack = g_list_remove_link (render->pixbuf_stack,
render->pixbuf_stack);
rsvg_cairo_to_pixbuf(gdk_pixbuf_get_pixels(pixbuf),
gdk_pixbuf_get_rowstride(pixbuf),
gdk_pixbuf_get_height(pixbuf));
rsvg_cairo_to_pixbuf_noaa(gdk_pixbuf_get_pixels(pixbuf),
gdk_pixbuf_get_rowstride(pixbuf),
gdk_pixbuf_get_height(pixbuf));
output = rsvg_filter_render (state->filter, pixbuf, pixbuf,
ctx, &bounds);
ctx, &render->bbox);
gdk_pixbuf_unref(pixbuf);
rsvg_pixbuf_to_cairo(gdk_pixbuf_get_pixels(output),
gdk_pixbuf_get_rowstride(output),
gdk_pixbuf_get_height(output));
rsvg_pixbuf_to_cairo_noaa(gdk_pixbuf_get_pixels(output),
gdk_pixbuf_get_rowstride(output),
gdk_pixbuf_get_height(output));
surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels(output),
CAIRO_FORMAT_ARGB32,
......@@ -856,10 +849,10 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx *ctx)
cairo_destroy (child_cr);
rsvg_cairo_bbox_insert((RsvgCairoBbox *)render->bb_stack->data,
rsvg_bbox_insert((RsvgBbox *)render->bb_stack->data,
&render->bbox);
render->bbox = *((RsvgCairoBbox *)render->bb_stack->data);
render->bbox = *((RsvgBbox *)render->bb_stack->data);
g_free(render->bb_stack->data);
render->bb_stack = g_list_remove_link (render->bb_stack, render->bb_stack);
......@@ -924,7 +917,7 @@ rsvg_cairo_get_image_of_node (RsvgDrawingCtx *ctx,
cr = cairo_create (surface);
cairo_surface_destroy (surface);
rsvg_cairo_to_pixbuf(pixels, rowstride, height);
rsvg_cairo_to_pixbuf_noaa(pixels, rowstride, height);
render = rsvg_cairo_render_new(cr, width, height);
ctx->render = (RsvgRender *)render;
......@@ -1001,3 +994,57 @@ void rsvg_pixbuf_to_cairo(guint8 *pixels, int rowstride, int height)
}
}
}
void rsvg_cairo_to_pixbuf_noaa(guint8 *pixels, int rowstride, int height)
{
int row;
/* un-premultiply data */
for(row = 0; row < height; row++) {
guint8 *row_data = (pixels + (row * rowstride));
int i;
for(i = 0; i < rowstride; i += 4) {
guint8 *b = &row_data[i];
guint32 pixel;
guint8 alpha;
memcpy(&pixel, b, sizeof(guint32));
alpha = (pixel & 0xff000000) >> 24;
if(alpha == 0) {
b[0] = b[1] = b[2] = b[3] = 0;
} else {
b[0] = (pixel & 0xff0000) >> 16;
b[1] = (pixel & 0x00ff00) >> 8;
b[2] = (pixel & 0x0000ff) >> 0;
b[3] = alpha;
}
}
}
}
void rsvg_pixbuf_to_cairo_noaa(guint8 *pixels, int rowstride, int height)
{
int row;
/* un-premultiply data */
for(row = 0; row < height; row++) {
guint8 *row_data = (pixels + (row * rowstride));
int i;
for(i = 0; i < rowstride; i += 4) {
guint32 *b = (guint32 *)&row_data[i];
guint8 pixel[4];
int alpha;
memcpy(&pixel, b, sizeof(guint32));
alpha = pixel[3];
if(alpha == 0)
*b = 0;
else
*b = alpha << 24 |
(int)pixel[0] << 16 |
(int)pixel[1] << 8 |
(int)pixel[2];
}
}
}
......@@ -109,7 +109,7 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle)
_rsvg_affine_multiply(state->affine, affine,
state->affine);
rsvg_cairo_bbox_init(&((RsvgCairoRender *)draw->render)->bbox,
rsvg_bbox_init(&((RsvgCairoRender *)draw->render)->bbox,
state->affine);
return draw;
......@@ -133,54 +133,3 @@ rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle)
rsvg_state_pop(draw);
rsvg_drawing_ctx_free(draw);
}
void rsvg_cairo_bbox_init(RsvgCairoBbox * self, double * affine)
{
int i;
self->virgin = 1;
for (i = 0; i < 6; i++)
self->affine[i] = affine[i];
}
void rsvg_cairo_bbox_insert(RsvgCairoBbox * dst, RsvgCairoBbox * src)
{
double affine[6];
double xmin = dst->x, ymin = dst->y;
double xmax = dst->x + dst->w, ymax = dst->y + dst->h;
int i;
if (src->virgin)
return;
_rsvg_affine_invert(affine, dst->affine);
_rsvg_affine_multiply(affine, src->affine, affine);
for (i = 0; i < 4; i++)
{
double rx, ry, x, y;
rx = src->x + src->w * (double)(i % 2);
ry = src->y + src->h * (double)(i / 2);
x = affine[0] * rx + affine[2] * ry + affine[4];
y = affine[1] * rx + affine[3] * ry + affine[5];
if (dst->virgin)
{
xmin = xmax = x;
ymin = ymax = y;
dst->virgin = 0;
}
else
{
if (x < xmin)
xmin = x;
if (x > xmax)
xmax = x;
if (y < ymin)
ymin = y;
if (y > ymax)
ymax = y;
}
}
dst->x = xmin;
dst->y = ymin;
dst->w = xmax - xmin;
dst->h = ymax - ymin;
}
......@@ -32,12 +32,6 @@
G_BEGIN_DECLS
typedef struct {
gdouble x, y, w, h;
gboolean virgin;
double affine[6];
} RsvgCairoBbox;
typedef struct _RsvgCairoRender RsvgCairoRender;
struct _RsvgCairoRender {
......@@ -48,7 +42,7 @@ struct _RsvgCairoRender {
GList *cr_stack;
RsvgCairoBbox bbox;
RsvgBbox bbox;
GList *bb_stack;
GList *pixbuf_stack;
};
......@@ -56,10 +50,6 @@ struct _RsvgCairoRender {
RsvgCairoRender * rsvg_cairo_render_new(cairo_t * cr, double width, double height);
void rsvg_cairo_render_rsvg_handle (cairo_t *cr, RsvgHandle *handle);
void rsvg_cairo_bbox_init(RsvgCairoBbox * self, double * affine);
void rsvg_cairo_bbox_insert(RsvgCairoBbox * dst, RsvgCairoBbox * src);
G_END_DECLS
#endif
......@@ -33,7 +33,6 @@
#include <math.h>
#define PERFECTBLUR 0
/*************************************************************/
/*************************************************************/
......@@ -90,68 +89,46 @@ rsvg_filter_primitive_render (RsvgFilterPrimitive * self,
static RsvgIRect
rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self,
RsvgFilterContext * ctx)
RsvgFilterContext * ctx)
{
RsvgIRect output;
int skip;
skip = 0;
RsvgBbox box, otherbox;
double affine[6];
if (self == NULL)
skip = 1;
else if (self->sizedefaults)
skip = 1;
_rsvg_affine_identity(affine);
rsvg_bbox_init(&box, affine);
rsvg_bbox_init(&otherbox, ctx->affine);
otherbox.virgin = 0;
otherbox.x = ctx->filter->x;
otherbox.y = ctx->filter->y;
otherbox.w = ctx->filter->width;
otherbox.h = ctx->filter->height;
if (skip)
{
output.x0 = ctx->affine[0] * ctx->filter->x + ctx->affine[4];
output.y0 = ctx->affine[3] * ctx->filter->y + ctx->affine[5];
output.x1 =
ctx->affine[0] * (ctx->filter->x + ctx->filter->width) +
ctx->affine[4];
output.y1 =
ctx->affine[3] * (ctx->filter->y + ctx->filter->height) +
ctx->affine[5];
if (output.x0 < 0)
output.x0 = 0;
if (output.x1 > ctx->width)
output.x1 = ctx->width;
if (output.y0 < 0)
output.y0 = 0;
if (output.y1 > ctx->height)
output.y1 = ctx->height;
rsvg_bbox_insert(&box, &otherbox);
return output;
if (!(self == NULL || self->sizedefaults))
{
rsvg_bbox_init(&otherbox, ctx->paffine);
otherbox.virgin = 0;
otherbox.x = self->x;
otherbox.y = self->y;
otherbox.w = self->width;
otherbox.h = self->height;
rsvg_bbox_clip(&box, &otherbox);
}
output.x0 = ctx->paffine[0] * self->x + ctx->paffine[4];
output.y0 = ctx->paffine[3] * self->y + ctx->paffine[5];
output.x1 = ctx->paffine[0] * (self->x + self->width) + ctx->paffine[4];
output.y1 = ctx->paffine[3] * (self->y + self->height) + ctx->paffine[5];
if (output.x0 < ctx->affine[0] * ctx->filter->x + ctx->affine[4])
output.x0 = ctx->affine[0] * ctx->filter->x + ctx->affine[4];
if (output.x1 >
ctx->affine[0] * (ctx->filter->x + ctx->filter->width) + ctx->affine[4])
output.x1 =
ctx->affine[0] * (ctx->filter->x + ctx->filter->width) + ctx->affine[4];
if (output.y0 < ctx->affine[3] * ctx->filter->y + ctx->affine[5])
output.y0 = ctx->affine[3] * ctx->filter->y + ctx->affine[5];
if (output.y1 > ctx->affine[3] * (ctx->filter->y + ctx->filter->height) +
ctx->affine[5])
output.y1 = ctx->affine[3] * (ctx->filter->y + ctx->filter->height) +
ctx->affine[5];
if (output.x0 < 0)
output.x0 = 0;
if (output.x1 > ctx->width)
output.x1 = ctx->width;
if (output.y0 < 0)
output.y0 = 0;
if (output.y1 > ctx->height)
output.y1 = ctx->height;
return output;
rsvg_bbox_init(&otherbox, affine);
otherbox.virgin = 0;
otherbox.x = 0;
otherbox.y = 0;
otherbox.w = ctx->width;
otherbox.h = ctx->height;
rsvg_bbox_clip(&box, &otherbox);
{
RsvgIRect output = {box.x, box.y,
box.x + box.w,
box.y + box.h};
return output;
}
}
GdkPixbuf *
......@@ -214,47 +191,40 @@ gdk_pixbuf_get_interp_pixel(guchar * src, gdouble ox, gdouble oy, guchar ch, Rsv
static void
rsvg_filter_fix_coordinate_system (RsvgFilterContext * ctx, RsvgState * state,
RsvgIRect bbox)
RsvgBbox bbox)
{
int x, y, height, width;
int i;
x = bbox.x0;
y = bbox.y0;
width = bbox.x1 - bbox.x0;
height = bbox.y1 -bbox.y0;
x = bbox.x;
y = bbox.y;
width = bbox.w;
height = bbox.h;
ctx->width = gdk_pixbuf_get_width (ctx->source);
ctx->height = gdk_pixbuf_get_height (ctx->source);
if (ctx->filter->filterunits == userSpaceOnUse)
{
for (i = 0; i < 6; i++)
ctx->affine[i] = state->affine[i];
}
else
{
ctx->affine[0] = width;
ctx->affine[1] = 0.;
ctx->affine[2] = 0.;
ctx->affine[3] = height;
ctx->affine[4] = x;
ctx->affine[5] = y;
}
if (ctx->filter->primitiveunits == userSpaceOnUse)
printf("%f %f %f %f %f %f\n", bbox.affine[0], bbox.affine[1], bbox.affine[2],
bbox.affine[3], bbox.affine[4], bbox.affine[5]);
printf("%f %f %f %f %f %f\n",
state->affine[0], state->affine[1], state->affine[2],
state->affine[3], state->affine[4], state->affine[5]);
ctx->width = gdk_pixbuf_get_width(ctx->source);
ctx->height = gdk_pixbuf_get_height(ctx->source);
for (i = 0; i < 6; i++)
ctx->affine[i] = state->affine[i];
if (ctx->filter->filterunits == objectBoundingBox)
{
for (i = 0; i < 6; i++)
ctx->paffine[i] = state->affine[i];
double affine[6] = {width, 0, 0, height, x, y};
_rsvg_affine_multiply(ctx->affine, affine, ctx->affine);
}
else
for (i = 0; i < 6; i++)
ctx->paffine[i] = state->affine[i];
if (ctx->filter->primitiveunits == objectBoundingBox)
{
ctx->paffine[0] = width;
ctx->paffine[1] = 0.;
ctx->paffine[2] = 0.;
ctx->paffine[3] = height;
ctx->paffine[4] = x;
ctx->paffine[5] = y;
double affine[6] = {width, 0, 0, height, x, y};
_rsvg_affine_multiply(ctx->paffine, affine, ctx->paffine);
}
}
......@@ -487,13 +457,14 @@ rsvg_filter_free_pair (gpointer value)
GdkPixbuf *
rsvg_filter_render (RsvgFilter * self, GdkPixbuf * source,
GdkPixbuf * bg, RsvgDrawingCtx * context,
RsvgIRect * bounds)
RsvgBbox * bounds)
{
RsvgFilterContext *ctx;
RsvgFilterPrimitive *current;
guint i;
GdkPixbuf * out;
ctx = g_new (RsvgFilterContext, 1);
ctx->filter = self;
ctx->source = source;
......@@ -521,8 +492,7 @@ rsvg_filter_render (RsvgFilter * self, GdkPixbuf * source,
}
out = ctx->lastresult.result;
g_object_ref (G_OBJECT (out));
*bounds = rsvg_filter_primitive_get_bounds (NULL, ctx);
g_object_ref (G_OBJECT (out));
g_hash_table_destroy (ctx->results);
......@@ -850,8 +820,8 @@ static void rsvg_filter_blend(RsvgFilterPrimitiveBlendMode mode, GdkPixbuf *in,
cr = 0;
for (i = 0; i < 3; i++)
{
ca = (double) in_pixels[4 * x + y * rowstride + i] * qa / 255.0;
cb = (double) in2_pixels[4 * x + y * rowstride2 + i] * qb / 255.0;
ca = (double) in_pixels[4 * x + y * rowstride + i] / 255.0;
cb = (double) in2_pixels[4 * x + y * rowstride2 + i] / 255.0;
/*these are the ca and cb that are used in the non-standard blend functions*/
bcb = (1 - qa) * cb + ca;
bca = (1 - qb) * ca + cb;
......@@ -909,7 +879,7 @@ static void rsvg_filter_blend(RsvgFilterPrimitiveBlendMode mode, GdkPixbuf *in,
cr = abs(bca - bcb);
break;
}
cr *= 255.0 / qr;
cr *= 255.0;
if (cr > 255)
cr = 255;
if (cr < 0)
......@@ -1464,16 +1434,8 @@ box_blur (GdkPixbuf *in, GdkPixbuf *output, GdkPixbuf *intermediate, gint kw,
divisor = 0;
for (x = boundarys.x0; x < boundarys.x0 + kw; x++)
{
if (ch != 3)
{
divisor += in_pixels[4 * x + y * rowstride + 3];
sum += in_pixels[4 * x + y * rowstride + ch] * in_pixels[4 * x + y * rowstride + 3];
}
else
{
divisor++;
sum += in_pixels[4 * x + y * rowstride + ch];
}
divisor++;
sum += in_pixels[4 * x + y * rowstride + ch];
if (x - kw / 2 >= 0 && x - kw / 2 < boundarys.x1)
{
......@@ -1483,36 +1445,16 @@ box_blur (GdkPixbuf *in, GdkPixbuf *output, GdkPixbuf *intermediate, gint kw,
}
for (x = boundarys.x0 + kw; x < boundarys.x1; x++)
{