Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created November 19, 2010 01:19
Show Gist options
  • Save springmeyer/705986 to your computer and use it in GitHub Desktop.
Save springmeyer/705986 to your computer and use it in GitHub Desktop.
diff --git a/src/image_util.cpp b/src/image_util.cpp
index ae36062..5e6aac3 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
{
@@ -551,7 +552,10 @@ 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;
+ agg::recursive_blur<agg::rgba8, agg::recursive_blur_calc_rgb<> > m_recursive_blur;
typedef agg::renderer_base<pixfmt> renderer_base;
+
+ agg::stack_blur <agg::rgba8, agg::stack_blur_calc_rgb<> > m_stack_blur;
// define some stuff we'll use soon
agg::rasterizer_scanline_aa<> ras;
@@ -562,6 +566,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);
@@ -579,7 +586,9 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
img_mtx *= agg::trans_affine_translation(-x_off_f, -y_off_f);
// create a linear interpolator for our scaling matrix
- typedef agg::span_interpolator_linear<> interpolator_type;
+ //typedef agg::span_interpolator_linear<> interpolator_type;
+ //typedef span_interpolator_linear_subdiv<> interpolator_type;
+ typedef agg::span_interpolator_linear_subdiv<agg::trans_affine> interpolator_type;
interpolator_type interpolator(img_mtx);
// draw an anticlockwise polygon to render our image into
@@ -589,6 +598,10 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
ras.line_to_d(target.width(), target.height());
ras.line_to_d(0, target.height());
+ std::clog << "filter radius: "<< filter_radius << "\n";
+ std::clog << "scale_x: "<< scale_factor_x << "\n";
+ std::clog << "scale_y: "<< scale_factor_y << "\n";
+
switch(scaling_method)
{
case SCALING_NEAR:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment