From c95cf160538776475ca245454bb9340e18de200c Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 3 Nov 2010 14:35:20 -0700 Subject: [PATCH] Removed blur.cc since it is currently not used --- src/blur.cc | 72 ----------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/blur.cc diff --git a/src/blur.cc b/src/blur.cc deleted file mode 100644 index ac8e4cf..0000000 --- a/src/blur.cc +++ /dev/null @@ -1,72 +0,0 @@ - -#include -#include -#include -#include -#include -#include "canvas.h" - -void -Canvas::blur(cairo_surface_t *surface, int radius) { - // Steve Hanov, 2009 - // Released into the public domain. - - // get width, height - int width = cairo_image_surface_get_width( surface ); - int height = cairo_image_surface_get_height( surface ); - unsigned char* dst = (unsigned char*)malloc(width*height*4); - unsigned* precalc = - (unsigned*)malloc(width*height*sizeof(unsigned)); - unsigned char* src = cairo_image_surface_get_data( surface ); - double mul=1.f/((radius*2)*(radius*2)); - int channel; - - // The number of times to perform the averaging. According to wikipedia, - // three iterations is good enough to pass for a gaussian. - const int MAX_ITERATIONS = 3; - int iteration; - - memcpy( dst, src, width*height*4 ); - - for ( iteration = 0; iteration < MAX_ITERATIONS; iteration++ ) { - for( channel = 0; channel < 4; channel++ ) { - int x,y; - - // precomputation step. - unsigned char* pix = src; - unsigned* pre = precalc; - - pix += channel; - for (y=0;y0) tot+=pre[-1]; - if (y>0) tot+=pre[-width]; - if (x>0 && y>0) tot-=pre[-width-1]; - *pre++=tot; - pix += 4; - } - } - - // blur step. - pix = dst + (int)radius * width * 4 + (int)radius * 4 + channel; - for (y=radius;y= width ? width - 1 : x + radius; - int b = y + radius >= height ? height - 1 : y + radius; - int tot = precalc[r+b*width] + precalc[l+t*width] - - precalc[l+b*width] - precalc[r+t*width]; - *pix=(unsigned char)(tot*mul); - pix += 4; - } - pix += (int)radius * 2 * 4; - } - } - memcpy( src, dst, width*height*4 ); - } - - free( dst ); - free( precalc ); -} \ No newline at end of file