+ apply scale_factor to raster markers (bilinear)

This commit is contained in:
artemp 2012-06-29 12:31:41 +01:00
parent 34c3128b0c
commit caa50402dc

View file

@ -36,6 +36,7 @@
#include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/image_compositing.hpp>
#include <mapnik/image_filter.hpp>
#include <mapnik/image_util.hpp>
// agg
#define AGG_RENDERING_BUFFER row_ptr_cache<int8u>
#include "agg_rendering_buffer.h"
@ -303,13 +304,31 @@ void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& mar
}
else
{
double cx = 0.5 * (*marker.get_bitmap_data())->width();
double cy = 0.5 * (*marker.get_bitmap_data())->height();
composite(current_buffer_->data(), **marker.get_bitmap_data(),
comp_op, opacity,
boost::math::iround(pos.x - cx),
boost::math::iround(pos.y - cy),
false);
double w = (*marker.get_bitmap_data())->width();
double h = (*marker.get_bitmap_data())->height();
double cx = 0.5 * w;
double cy = 0.5 * h;
if (std::fabs(1.0 - scale_factor_) < 0.001)
{
composite(current_buffer_->data(), **marker.get_bitmap_data(),
comp_op, opacity,
boost::math::iround(pos.x - cx),
boost::math::iround(pos.y - cy),
false);
}
else
{
double scaled_width = w * scale_factor_;
double scaled_height = h * scale_factor_;
image_data_32 buf(std::ceil(scaled_width),std::ceil(scaled_height));
scale_image_agg(buf, **marker.get_bitmap_data(), SCALING_BILINEAR, scale_factor_);
composite(current_buffer_->data(), buf,
comp_op, opacity,
boost::math::iround(pos.x - 0.5*scaled_width),
boost::math::iround(pos.y - 0.5*scaled_height),
false);
}
}
}