diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 6fac846b0..9107aa881 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -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) { - 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) @@ -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_alpha",&image_32::set_alpha, "Set the overall alpha channel of the Image") .def("blend",&blend) - .def("composite",&composite) + .def("composite",&composite, + ( arg("self"), + arg("image"), + arg("mode"), + arg("opacity")=1.0f + )) .def("set_pixel",&set_pixel) //TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3 diff --git a/include/mapnik/image_compositing.hpp b/include/mapnik/image_compositing.hpp index bce476dc3..65bb4bfb3 100644 --- a/include/mapnik/image_compositing.hpp +++ b/include/mapnik/image_compositing.hpp @@ -74,15 +74,23 @@ enum composite_mode_e MAPNIK_DECL boost::optional comp_op_from_string(std::string const& name); template -MAPNIK_DECL void composite(T1 & im, T2 & im2, int xdst, int ydst, - composite_mode_e mode, float opacity, - bool premultiply_src, bool premultiply_dst); - -template -MAPNIK_DECL void composite(T1 & im, T2 & im2, composite_mode_e mode, float opacity, bool premultiply_src, bool premultiply_dst); +MAPNIK_DECL void composite(T1 & im, T2 & im2, + composite_mode_e mode, + float opacity=1, + int xdst=0, + int ydst=0, + bool premultiply_src=true, + bool premultiply_dst=true); #ifdef _MSC_VER -template MAPNIK_DECL void composite(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 & im, + mapnik::image_data_32 & im2, + composite_mode_e mode, + float opacity, + int xdst, + int ydst, + bool premultiply_src, + bool premultiply_dst); #endif } diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 9936de2b9..67b4c4b13 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -230,11 +230,11 @@ void agg_renderer::end_style_processing(feature_type_style const& st) 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) { - 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 diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp index 6474d0837..21ef0ece1 100644 --- a/src/agg/process_raster_symbolizer.cpp +++ b/src/agg/process_raster_symbolizer.cpp @@ -77,7 +77,7 @@ void agg_renderer::process(raster_symbolizer const& sym, scale_factor, 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); } } } diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp index afab5da3a..f90f24b73 100644 --- a/src/image_compositing.cpp +++ b/src/image_compositing.cpp @@ -81,7 +81,12 @@ boost::optional comp_op_from_string(std::string const& name) } template -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::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)); } -template -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& , int, int,composite_mode_e, float, bool, bool); - -template void composite(mapnik::image_data_32&, mapnik::image_data_32&, composite_mode_e, float, bool, bool); +template void composite(mapnik::image_data_32&, mapnik::image_data_32& ,composite_mode_e, float, int, int, bool, bool); }