From ab149257ad0d18ec87f22d824ef9ee3d0efc9ae5 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 12 Jun 2007 19:30:58 +0000 Subject: [PATCH] added save_to_file method that works with Image object. --- bindings/python/mapnik_image.cpp | 6 +++++- bindings/python/mapnik_image_view.cpp | 4 ---- include/mapnik/image_util.hpp | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index e16d283c7..7bdd9b90c 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -25,9 +25,11 @@ #include #include #include +#include using mapnik::Image32; using namespace boost::python; +using mapnik::save_to_file; PyObject* rawdata( Image32 const& im) { @@ -35,6 +37,7 @@ PyObject* rawdata( Image32 const& im) return ::PyString_FromStringAndSize((const char*)im.raw_data(),size); } +void (*save_to_file2)(std::string const&,std::string const&, mapnik::Image32 const&) = mapnik::save_to_file; void export_image() { using namespace boost::python; @@ -46,5 +49,6 @@ void export_image() (&Image32::getBackground,return_value_policy()), &Image32::setBackground, "The background color of the image.") ; - def("rawdata",&rawdata); + def("rawdata",&rawdata); // FIXME : I dont think we need this one + def("save_to_file", save_to_file2); } diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 53a8c8be0..9d218622c 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -22,10 +22,6 @@ //$Id$ #include - -//#include -//#include -//#include #include #include diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 3054a98e3..908b27b48 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -217,14 +217,22 @@ namespace mapnik { } } } - + + inline MAPNIK_DECL void save_to_file (std::string const& file, + std::string const& type, + Image32 const& image) + { + save_to_file(file,type,image.data()); + } + #ifdef _MSC_VER - template MAPNIK_DECL void save_to_file(std::string const&, - std::string const& , - ImageData32 const&); - template MAPNIK_DECL void save_to_file > (std::string const&, - std::string const& , - image_view const&); + template MAPNIK_DECL void save_to_file(std::string const&, + std::string const& , + ImageData32 const&); + + template MAPNIK_DECL void save_to_file > (std::string const&, + std::string const& , + image_view const&); #endif }