default values for composite args to maintain api compatibility

This commit is contained in:
Dane Springmeyer 2012-05-11 15:19:05 -07:00
parent c9bedf8bd4
commit 8ae867f6de
5 changed files with 32 additions and 22 deletions

View file

@ -149,7 +149,7 @@ 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 & im, image_32 & im2, mapnik::composite_mode_e mode, float opacity)
{ {
mapnik::composite(im.data(),im2.data(),mode,opacity,true,true); mapnik::composite(im.data(),im2.data(),mode,opacity,0,0,true,true);
} }
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
@ -207,7 +207,12 @@ void export_image()
.def("set_color_to_alpha",&image_32::set_color_to_alpha, "Set a given color to the alpha channel of the Image") .def("set_color_to_alpha",&image_32::set_color_to_alpha, "Set a given color to the alpha channel of the Image")
.def("set_alpha",&image_32::set_alpha, "Set the overall alpha channel of the Image") .def("set_alpha",&image_32::set_alpha, "Set the overall alpha channel of the Image")
.def("blend",&blend) .def("blend",&blend)
.def("composite",&composite) .def("composite",&composite,
( arg("self"),
arg("image"),
arg("mode"),
arg("opacity")=1.0f
))
.def("set_pixel",&set_pixel) .def("set_pixel",&set_pixel)
//TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3 //TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3

View file

@ -74,15 +74,23 @@ enum composite_mode_e
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name); MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
template <typename T1, typename T2> template <typename T1, typename T2>
MAPNIK_DECL void composite(T1 & im, T2 & im2, int xdst, int ydst, MAPNIK_DECL void composite(T1 & im, T2 & im2,
composite_mode_e mode, float opacity, composite_mode_e mode,
bool premultiply_src, bool premultiply_dst); float opacity=1,
int xdst=0,
template <typename T1, typename T2> int ydst=0,
MAPNIK_DECL void composite(T1 & im, T2 & im2, composite_mode_e mode, float opacity, bool premultiply_src, bool premultiply_dst); bool premultiply_src=true,
bool premultiply_dst=true);
#ifdef _MSC_VER #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, composite_mode_e mode, float opacity, bool premultiply_src, bool premultiply_dst); template MAPNIK_DECL void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32 & im,
mapnik::image_data_32 & im2,
composite_mode_e mode,
float opacity,
int xdst,
int ydst,
bool premultiply_src,
bool premultiply_dst);
#endif #endif
} }

View file

@ -230,11 +230,11 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
if (st.comp_op()) if (st.comp_op())
{ {
composite(pixmap_.data(),current_buffer_->data(), *st.comp_op(), 1.0f, false,false); composite(pixmap_.data(),current_buffer_->data(), *st.comp_op(), 1.0f, 0, 0, false, false);
} }
else if (blend_from) else if (blend_from)
{ {
composite(pixmap_.data(),current_buffer_->data(), src_over, 1.0f,false,false); composite(pixmap_.data(),current_buffer_->data(), src_over, 1.0f, 0, 0, false,false);
} }
// apply any 'direct' image filters // apply any 'direct' image filters

View file

@ -77,7 +77,7 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
scale_factor, scale_factor,
sym.get_scaling()); sym.get_scaling());
composite(current_buffer_->data(), target.data_, start_x, start_y, sym.comp_op(), sym.get_opacity(), false , false); composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, false, false);
} }
} }
} }

View file

@ -81,7 +81,12 @@ boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
} }
template <typename T1, typename T2> template <typename T1, typename T2>
void composite(T1 & im, T2 & im2, int xdst, int ydst, composite_mode_e mode, float opacity, bool premultiply_src, bool premultiply_dst) void composite(T1 & im, T2 & im2, composite_mode_e mode,
float opacity,
int xdst,
int ydst,
bool premultiply_src,
bool premultiply_dst)
{ {
typedef agg::rgba8 color; typedef agg::rgba8 color;
typedef agg::order_rgba order; typedef agg::order_rgba order;
@ -103,14 +108,6 @@ void composite(T1 & im, T2 & im2, int xdst, int ydst, composite_mode_e mode, flo
ren.blend_from(pixf_mask,0, xdst,ydst,unsigned(255*opacity)); ren.blend_from(pixf_mask,0, xdst,ydst,unsigned(255*opacity));
} }
template <typename T1, typename T2> 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);
void composite(T1 & im, T2 & im2, composite_mode_e mode, float opacity, bool premultiply_src, bool premultiply_dst)
{
composite(im, im2, 0, 0, mode, opacity, premultiply_src, premultiply_dst);
}
template void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32&, mapnik::image_data_32& , int, int,composite_mode_e, float, 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, bool, bool);
} }