diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp index c940cf8e6..9e7fd897e 100644 --- a/include/mapnik/grid/grid.hpp +++ b/include/mapnik/grid/grid.hpp @@ -262,6 +262,30 @@ public: return height_; } + inline void blendPixel(value_type feature_id,int x,int y,unsigned int rgba1,int t) + { + blendPixel2(x,y,rgba1,t,1.0); // do not change opacity + } + + inline void blendPixel2(value_type feature_id,int x,int y,unsigned int rgba1,int t,double opacity) + { + if (checkBounds(x,y)) + { + +#ifdef MAPNIK_BIG_ENDIAN + unsigned a1 = (int)((rgba1 & 0xff) * opacity) & 0xff; // adjust for desired opacity +#else + unsigned a = (int)(((rgba1 >> 24) & 0xff) * opacity) & 0xff; // adjust for desired opacity +#endif + // if the pixel is more than a tenth + // opaque then burn in the feature id + if (a >= 25) + { + data_(x,y) = feature_id; + } + } + } + inline void set_rectangle(value_type id,image_data_32 const& data,int x0,int y0) { box2d ext0(0,0,width_,height_);