diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp index d35b2cebc..d9e6d5243 100644 --- a/include/mapnik/image.hpp +++ b/include/mapnik/image.hpp @@ -23,7 +23,6 @@ #ifndef MAPNIK_IMAGE_HPP #define MAPNIK_IMAGE_HPP -#include #include namespace mapnik { diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index af60309d1..33dbf4a11 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -261,7 +261,7 @@ struct tag_setter tiff_config config_; }; -void set_tiff_config(TIFF* output, tiff_config & config) +inline void set_tiff_config(TIFF* output, tiff_config & config) { // Set some constant tiff information that doesn't vary based on type of data // or image size diff --git a/src/image.cpp b/src/image.cpp index 11b8ad33b..f7728fe62 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -23,6 +23,9 @@ #include #include #include +#include + +#include namespace mapnik { @@ -63,8 +66,29 @@ struct save_to_file_visitor save_to_file(data,filename_, format_); } + void operator() (image_data_gray16 const& data) const + { + if (format_ == "tiff") // only TIFF supported + { + std::ofstream file (filename_.c_str(), std::ios::out| std::ios::trunc|std::ios::binary); + if (file) + { + tiff_config config; + save_as_tiff(file, data, config); + } + else throw ImageWriterException("Could not write file to " + filename_ ); + } + else + { + throw std::runtime_error("Error: saving gray16 image as " + format_ + " is not supported"); + } + } + template - void operator() (T const& data) const {} + void operator() (T const& data) const + { + throw std::runtime_error("Error: saving " + std::string(typeid(data).name()) + " as " + format_ + " is not supported"); + } std::string const& filename_; std::string const& format_;