Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created November 19, 2010 01:22
Show Gist options
  • Save springmeyer/705987 to your computer and use it in GitHub Desktop.
Save springmeyer/705987 to your computer and use it in GitHub Desktop.
agg blur
diff --git a/src/image_util.cpp b/src/image_util.cpp
index ae36062..f1cace0 100644
--- a/src/image_util.cpp
+++ b/src/image_util.cpp
@@ -69,6 +69,7 @@ extern "C"
#include "agg_span_image_filter_rgba.h"
#include "agg_span_interpolator_linear.h"
#include "agg_trans_affine.h"
+#include "agg_blur.h"
namespace mapnik
{
@@ -552,6 +553,7 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
// most of this is copied from http://www.antigrain.com/demo/image_filters2.cpp.html
typedef agg::pixfmt_rgba32 pixfmt;
typedef agg::renderer_base<pixfmt> renderer_base;
+ typedef agg::stack_blur <agg::rgba8, agg::stack_blur_calc_rgb<> > stack_blur;
// define some stuff we'll use soon
agg::rasterizer_scanline_aa<> ras;
@@ -562,6 +564,9 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
// initialize source AGG buffer
agg::rendering_buffer rbuf_src((unsigned char*)source.getBytes(), source.width(), source.height(), source.width() * 4);
pixfmt pixf_src(rbuf_src);
+ //m_recursive_blur.blur(pixf_src,0.5);
+
+ agg::stack_blur_rgb24(pixf_src, agg::uround(filter_radius/2.0),agg::uround(filter_radius/2.0));
typedef agg::image_accessor_clone<pixfmt> img_src_type;
img_src_type img_src(pixf_src);
@@ -588,7 +593,7 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
ras.line_to_d(target.width(), 0);
ras.line_to_d(target.width(), target.height());
ras.line_to_d(0, target.height());
-
+
switch(scaling_method)
{
case SCALING_NEAR:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment