account for scaling and alpha of bitmap images in grid_renderer
This commit is contained in:
parent
e69f17eb35
commit
adb44a6ec2
3 changed files with 24 additions and 4 deletions
|
@ -252,7 +252,15 @@ public:
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,19 @@ void grid_renderer<T>::render_marker(Feature const& feature, unsigned int step,
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
|
|||
prj_trans.backward(x,y,z);
|
||||
t_.forward(&x,&y);
|
||||
|
||||
int w = (*marker)->width();
|
||||
int h = (*marker)->height();
|
||||
int w = (*marker)->width() * (1.0/pixmap_.get_step());
|
||||
int h = (*marker)->height() * (1.0/pixmap_.get_step());
|
||||
|
||||
int px = int(floor(x - 0.5 * w));
|
||||
int py = int(floor(y - 0.5 * h));
|
||||
|
|
Loading…
Reference in a new issue