added save_to_file method that works with Image object.

This commit is contained in:
Artem Pavlenko 2007-06-12 19:30:58 +00:00
parent 8010d5433f
commit ab149257ad
3 changed files with 20 additions and 12 deletions

View file

@ -25,9 +25,11 @@
#include <boost/python/module.hpp> #include <boost/python/module.hpp>
#include <boost/python/def.hpp> #include <boost/python/def.hpp>
#include <mapnik/graphics.hpp> #include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
using mapnik::Image32; using mapnik::Image32;
using namespace boost::python; using namespace boost::python;
using mapnik::save_to_file;
PyObject* rawdata( Image32 const& im) PyObject* rawdata( Image32 const& im)
{ {
@ -35,6 +37,7 @@ PyObject* rawdata( Image32 const& im)
return ::PyString_FromStringAndSize((const char*)im.raw_data(),size); 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() void export_image()
{ {
using namespace boost::python; using namespace boost::python;
@ -46,5 +49,6 @@ void export_image()
(&Image32::getBackground,return_value_policy<copy_const_reference>()), (&Image32::getBackground,return_value_policy<copy_const_reference>()),
&Image32::setBackground, "The background color of the image.") &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);
} }

View file

@ -22,10 +22,6 @@
//$Id$ //$Id$
#include <boost/python.hpp> #include <boost/python.hpp>
//#include <boost/python/module.hpp>
//#include <boost/python/def.hpp>
//#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp> #include <mapnik/image_util.hpp>
#include <mapnik/image_view.hpp> #include <mapnik/image_view.hpp>

View file

@ -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<ImageData32>(file,type,image.data());
}
#ifdef _MSC_VER #ifdef _MSC_VER
template MAPNIK_DECL void save_to_file<ImageData32>(std::string const&, template MAPNIK_DECL void save_to_file<ImageData32>(std::string const&,
std::string const& , std::string const& ,
ImageData32 const&); ImageData32 const&);
template MAPNIK_DECL void save_to_file<image_view<ImageData32> > (std::string const&,
std::string const& , template MAPNIK_DECL void save_to_file<image_view<ImageData32> > (std::string const&,
image_view<ImageData32> const&); std::string const& ,
image_view<ImageData32> const&);
#endif #endif
} }