+ mapnik-image-from-cairo-in-python.patch from jonb
adds a method to the python bindings to create an Image from a Cairo.ImageSurface().
This commit is contained in:
parent
387ff213ef
commit
391ae4c4be
1 changed files with 18 additions and 0 deletions
|
@ -37,6 +37,11 @@ extern "C"
|
||||||
#include <mapnik/png_io.hpp>
|
#include <mapnik/png_io.hpp>
|
||||||
#include <mapnik/image_reader.hpp>
|
#include <mapnik/image_reader.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
// cairo
|
||||||
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||||
|
#include <cairomm/surface.h>
|
||||||
|
#include <pycairo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using mapnik::Image32;
|
using mapnik::Image32;
|
||||||
using mapnik::ImageReader;
|
using mapnik::ImageReader;
|
||||||
|
@ -83,6 +88,15 @@ void blend (Image32 & im, unsigned x, unsigned y, Image32 const& im2, float opac
|
||||||
im.set_rectangle_alpha2(im2.data(),x,y,opacity);
|
im.set_rectangle_alpha2(im2.data(),x,y,opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) && defined(CAIRO_HAS_IMAGE_SURFACE)
|
||||||
|
boost::shared_ptr<Image32> from_cairo(PycairoSurface* surface)
|
||||||
|
{
|
||||||
|
Cairo::RefPtr<Cairo::ImageSurface> s(new Cairo::ImageSurface(surface->surface));
|
||||||
|
boost::shared_ptr<Image32> image_ptr(new Image32(s));
|
||||||
|
return image_ptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void export_image()
|
void export_image()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -100,6 +114,10 @@ void export_image()
|
||||||
.def("save", save_to_file2)
|
.def("save", save_to_file2)
|
||||||
.def("open",open_from_file)
|
.def("open",open_from_file)
|
||||||
.staticmethod("open")
|
.staticmethod("open")
|
||||||
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) && defined(CAIRO_HAS_IMAGE_SURFACE)
|
||||||
|
.def("from_cairo",&from_cairo)
|
||||||
|
.staticmethod("from_cairo")
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue