Changeset 652
- Timestamp:
- 02/19/08 06:28:20 (9 months ago)
- Files:
-
- 1 modified
-
trunk/bindings/python/mapnik_image.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/mapnik_image.cpp
r642 r652 36 36 #include <mapnik/jpeg_io.hpp> 37 37 #include <mapnik/png_io.hpp> 38 #include <mapnik/image_reader.hpp> 38 39 #include <sstream> 39 40 40 41 using mapnik::Image32; 42 using mapnik::ImageReader; 43 using mapnik::get_image_reader; 44 using mapnik::type_from_filename; 41 45 using namespace boost::python; 42 46 using mapnik::save_to_file; … … 63 67 void (*save_to_file2)( mapnik::Image32 const&, std::string const&) = mapnik::save_to_file; 64 68 69 boost::shared_ptr<Image32> open_from_file(std::string const& filename) 70 { 71 std::auto_ptr<ImageReader> reader(get_image_reader(filename,type_from_filename(filename))); 72 if (reader.get()) 73 { 74 boost::shared_ptr<Image32> image_ptr(new Image32(reader->width(),reader->height())); 75 reader->read(0,0,image_ptr->data()); 76 return image_ptr; 77 } 78 throw mapnik::ImageReaderException("FIXME: " + filename); 79 } 80 65 81 void blend (Image32 & im, unsigned x, unsigned y, Image32 const& im2, float opacity) 66 82 { … … 71 87 { 72 88 using namespace boost::python; 73 class_<Image32 >("Image","This class represents a 32 bit RGBA image.",init<int,int>())89 class_<Image32,boost::shared_ptr<Image32> >("Image","This class represents a 32 bit RGBA image.",init<int,int>()) 74 90 .def("width",&Image32::width) 75 91 .def("height",&Image32::height) … … 83 99 .def("save", save_to_file1) 84 100 .def("save", save_to_file2) 101 .def("open",open_from_file) 102 .staticmethod("open") 85 103 ; 104 86 105 }
