+ only premultiply src
This commit is contained in:
parent
38f35d6f97
commit
c5864453a0
4 changed files with 19 additions and 23 deletions
|
@ -147,9 +147,9 @@ void blend (image_32 & im, unsigned x, unsigned y, image_32 const& im2, float op
|
|||
}
|
||||
|
||||
|
||||
void composite(image_32 & im, image_32 & im2, mapnik::composite_mode_e mode, float opacity)
|
||||
void composite(image_32 & dst, image_32 & src, mapnik::composite_mode_e mode, float opacity)
|
||||
{
|
||||
mapnik::composite(im.data(),im2.data(),mode,opacity,0,0,false,true);
|
||||
mapnik::composite(dst.data(),src.data(),mode,opacity,0,0,true);
|
||||
}
|
||||
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
|
|
|
@ -81,23 +81,21 @@ enum composite_mode_e
|
|||
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
|
||||
|
||||
template <typename T1, typename T2>
|
||||
MAPNIK_DECL void composite(T1 & im, T2 & im2,
|
||||
MAPNIK_DECL void composite(T1 & dst, T2 & src,
|
||||
composite_mode_e mode,
|
||||
float opacity=1,
|
||||
int dx=0,
|
||||
int dy=0,
|
||||
bool premultiply_src=true,
|
||||
bool premultiply_dst=true);
|
||||
bool premultiply_src=true);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
template MAPNIK_DECL void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32 & im,
|
||||
mapnik::image_data_32 & im2,
|
||||
template MAPNIK_DECL void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32 & dst,
|
||||
mapnik::image_data_32 & src,
|
||||
composite_mode_e mode,
|
||||
float opacity,
|
||||
int dx,
|
||||
int dy,
|
||||
bool premultiply_src,
|
||||
bool premultiply_dst);
|
||||
bool premultiply_src);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ void agg_renderer<T>::setup(Map const &m)
|
|||
{
|
||||
for (unsigned y=0;y<y_steps;++y)
|
||||
{
|
||||
pixmap_.set_rectangle_alpha2(*bg_image, x*w, y*h, 1.0f);
|
||||
composite(pixmap_.data(),*bg_image, src_over, 1.0f, x*w, y*h, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,11 +230,11 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
|
|||
|
||||
if (st.comp_op())
|
||||
{
|
||||
composite(pixmap_.data(),current_buffer_->data(), *st.comp_op(), 1.0f, 0, 0, false, false);
|
||||
composite(pixmap_.data(),current_buffer_->data(), *st.comp_op(), 1.0f, 0, 0, false);
|
||||
}
|
||||
else if (blend_from)
|
||||
{
|
||||
composite(pixmap_.data(),current_buffer_->data(), src_over, 1.0f, 0, 0, false,false);
|
||||
composite(pixmap_.data(),current_buffer_->data(), src_over, 1.0f, 0, 0, false);
|
||||
}
|
||||
|
||||
// apply any 'direct' image filters
|
||||
|
@ -297,7 +297,7 @@ void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& mar
|
|||
comp_op, opacity,
|
||||
boost::math::iround(pos.x - cx),
|
||||
boost::math::iround(pos.y - cy),
|
||||
false, false);
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,12 +89,11 @@ boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
|
|||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void composite(T1 & im, T2 & im2, composite_mode_e mode,
|
||||
void composite(T1 & dst, T2 & src, composite_mode_e mode,
|
||||
float opacity,
|
||||
int dx,
|
||||
int dy,
|
||||
bool premultiply_src,
|
||||
bool premultiply_dst)
|
||||
bool premultiply_src)
|
||||
{
|
||||
typedef agg::rgba8 color;
|
||||
typedef agg::order_rgba order;
|
||||
|
@ -103,20 +102,19 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode,
|
|||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
|
||||
typedef agg::renderer_base<pixfmt_type> renderer_type;
|
||||
|
||||
agg::rendering_buffer source(im.getBytes(),im.width(),im.height(),im.width() * 4);
|
||||
agg::rendering_buffer mask(im2.getBytes(),im2.width(),im2.height(),im2.width() * 4);
|
||||
agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.width() * 4);
|
||||
agg::rendering_buffer src_buffer(src.getBytes(),src.width(),src.height(),src.width() * 4);
|
||||
|
||||
pixfmt_type pixf(source);
|
||||
pixfmt_type pixf(dst_buffer);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(mode));
|
||||
|
||||
agg::pixfmt_rgba32 pixf_mask(mask);
|
||||
|
||||
agg::pixfmt_rgba32 pixf_mask(src_buffer);
|
||||
if (premultiply_src) pixf_mask.premultiply();
|
||||
if (premultiply_dst) pixf.premultiply();
|
||||
renderer_type ren(pixf);
|
||||
// TODO - is this really opacity, or agg::cover?
|
||||
ren.blend_from(pixf_mask,0, dx,dy,unsigned(255*opacity));
|
||||
}
|
||||
|
||||
template void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32&, mapnik::image_data_32& ,composite_mode_e, float, int, int, bool, bool);
|
||||
template void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32&, mapnik::image_data_32& ,composite_mode_e, float, int, int, bool);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue