account for scaling and alpha of bitmap images in grid_renderer

This commit is contained in:
Dane Springmeyer 2011-05-02 22:33:11 +00:00
parent e69f17eb35
commit adb44a6ec2
3 changed files with 24 additions and 4 deletions

View file

@ -252,7 +252,15 @@ public:
for (int x = box.minx(); x < box.maxx(); ++x) for (int x = box.minx(); x < box.maxx(); ++x)
{ {
if (row_from[x-x0] & 0xff000000) unsigned rgba = row_from[x-x0];
#ifdef MAPNIK_BIG_ENDIAN
unsigned a = rgba & 0xff;
#else
unsigned a = (rgba >> 24) & 0xff;
#endif
// if the pixel is more than a tenth
// opaque then burn in the feature id
if (a >= 25)
{ {
row_to[x] = id; row_to[x] = id;
} }

View file

@ -153,7 +153,19 @@ void grid_renderer<T>::render_marker(Feature const& feature, unsigned int step,
} }
else else
{ {
pixmap_.set_rectangle(feature.id(), **marker.get_bitmap_data(), x, y); image_data_32 const& data = **marker.get_bitmap_data();
if (step == 1 && scale_factor_ == 1.0)
{
pixmap_.set_rectangle(feature.id(), data, x, y);
}
else
{
double ratio = (1.0/step);
image_data_32 target(ratio * data.width(), ratio * data.height());
mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR,
scale_factor_, 0.0, 0.0, 1.0, ratio);
pixmap_.set_rectangle(feature.id(), target, x, y);
}
} }
pixmap_.add_feature(feature); pixmap_.add_feature(feature);
} }

View file

@ -68,8 +68,8 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
prj_trans.backward(x,y,z); prj_trans.backward(x,y,z);
t_.forward(&x,&y); t_.forward(&x,&y);
int w = (*marker)->width(); int w = (*marker)->width() * (1.0/pixmap_.get_step());
int h = (*marker)->height(); int h = (*marker)->height() * (1.0/pixmap_.get_step());
int px = int(floor(x - 0.5 * w)); int px = int(floor(x - 0.5 * w));
int py = int(floor(y - 0.5 * h)); int py = int(floor(y - 0.5 * h));