From 4b25c755a7106490cd3a5c0bc84f5be328e8a21b Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 13 Jan 2015 11:43:20 -0600 Subject: [PATCH 01/10] Added is_solid to image_utils. It is currently built to support the eventual use of image_view_any and image_data_any, but for a limited time supports the passing of image_view_rgba8 and image_data_rgba8. Ref #2633 --- bindings/python/mapnik_image.cpp | 19 +-------- bindings/python/mapnik_image_view.cpp | 18 +------- include/mapnik/image_util.hpp | 4 +- src/image_util.cpp | 61 +++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index b81b7ae39..6048de0ef 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -121,24 +121,7 @@ bool painted(mapnik::image_32 const& im) bool is_solid(mapnik::image_32 const& im) { - if (im.width() > 0 && im.height() > 0) - { - mapnik::image_data_rgba8 const & data = im.data(); - mapnik::image_data_rgba8::pixel_type const* first_row = data.getRow(0); - mapnik::image_data_rgba8::pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < im.height(); ++y) - { - mapnik::image_data_rgba8::pixel_type const * row = data.getRow(y); - for (unsigned x = 0; x < im.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; + return mapnik::is_solid(im.data()); } unsigned get_pixel(mapnik::image_32 const& im, int x, int y) diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 8894a96eb..82ca74c8e 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -89,23 +89,7 @@ PyObject* view_tostring3(image_view_rgba8 const & view, std::string const& forma bool is_solid(image_view_rgba8 const& view) { - if (view.width() > 0 && view.height() > 0) - { - mapnik::image_view_rgba8::pixel_type const* first_row = view.getRow(0); - mapnik::image_view_rgba8::pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < view.height(); ++y) - { - mapnik::image_view_rgba8::pixel_type const * row = view.getRow(y); - for (unsigned x = 0; x < view.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; + mapnik::is_solid(view); } void save_view1(image_view_rgba8 const& view, diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 2bee70bdb..58d3a0359 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -110,9 +110,7 @@ MAPNIK_DECL void save_to_stream ); template -void save_as_png(T const& image, - std::string const& filename, - rgba_palette const& palette); +MAPNIK_DECL bool is_solid (T const& image); inline bool is_png(std::string const& filename) { diff --git a/src/image_util.cpp b/src/image_util.cpp index 8f6c00e13..ce1eaf7ed 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -182,6 +182,67 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons else throw ImageWriterException("Could not write file to " + filename ); } +namespace detail { + +struct is_solid_visitor +{ + template + bool operator() (T const & data) + { + using pixel_type = typename T::pixel_type; + if (data.width() > 0 && data.height() > 0) + { + pixel_type const* first_row = data.getRow(0); + pixel_type const first_pixel = first_row[0]; + for (unsigned y = 0; y < data.height(); ++y) + { + pixel_type const * row = data.getRow(y); + for (unsigned x = 0; x < data.width(); ++x) + { + if (first_pixel != row[x]) + { + return false; + } + } + } + } + return true; + } +}; + +template bool is_solid_visitor::operator() (image_data_rgba8 const& data); +template bool is_solid_visitor::operator() (image_data_gray8 const& data); +template bool is_solid_visitor::operator() (image_data_gray16 const& data); +template bool is_solid_visitor::operator() (image_data_gray32f const& data); +template bool is_solid_visitor::operator() (image_view_rgba8 const& data); +template bool is_solid_visitor::operator() (image_view_gray8 const& data); +template bool is_solid_visitor::operator() (image_view_gray16 const& data); +template bool is_solid_visitor::operator() (image_view_gray32f const& data); + +} // end detail ns + +template +bool is_solid(T const& image) +{ + return util::apply_visitor(detail::is_solid_visitor(), image); +} + +// Temporary until image_data_rgba8 is removed from passing +template <> +bool is_solid(image_data_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + +// Temporary until image_view_rgba8 is removed from passing +template <> +bool is_solid(image_view_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + template void save_to_file(image_data_rgba8 const&, std::string const&, std::string const&); From e03739e316b3ad357eff56616178caac61b8be51 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:10:39 -0800 Subject: [PATCH 02/10] fix is_solid return --- bindings/python/mapnik_image_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 82ca74c8e..4d448e40a 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -89,7 +89,7 @@ PyObject* view_tostring3(image_view_rgba8 const & view, std::string const& forma bool is_solid(image_view_rgba8 const& view) { - mapnik::is_solid(view); + return mapnik::is_solid(view); } void save_view1(image_view_rgba8 const& view, From d0d899a9dd8e502485d6d3e17ee1cd4b11b819b4 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:19:45 -0800 Subject: [PATCH 03/10] fix linking error with saving image --- include/mapnik/image.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp index d9e6d5243..d9ee28334 100644 --- a/include/mapnik/image.hpp +++ b/include/mapnik/image.hpp @@ -24,10 +24,11 @@ #define MAPNIK_IMAGE_HPP #include +#include namespace mapnik { -class image +class MAPNIK_DECL image { public: image() = default; From 508521d5e56c447ea207447f384a8037b5f2fd9e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:20:15 -0800 Subject: [PATCH 04/10] move is_solid to hpp for now to avoid linking errors --- include/mapnik/image_util.hpp | 52 ++++++++++++++++++++++++++++- src/image_util.cpp | 61 ----------------------------------- 2 files changed, 51 insertions(+), 62 deletions(-) diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 58d3a0359..dd664415e 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -27,6 +27,7 @@ #include #include #include +#include // boost #pragma GCC diagnostic push @@ -109,8 +110,57 @@ MAPNIK_DECL void save_to_stream std::string const& type ); +namespace detail { + +struct is_solid_visitor +{ + template + inline bool operator() (T const & data) + { + using pixel_type = typename T::pixel_type; + if (data.width() > 0 && data.height() > 0) + { + pixel_type const* first_row = data.getRow(0); + pixel_type const first_pixel = first_row[0]; + for (unsigned y = 0; y < data.height(); ++y) + { + pixel_type const * row = data.getRow(y); + for (unsigned x = 0; x < data.width(); ++x) + { + if (first_pixel != row[x]) + { + return false; + } + } + } + } + return true; + } +}; + +} template -MAPNIK_DECL bool is_solid (T const& image); +inline bool is_solid (T const& image) +{ + return util::apply_visitor(detail::is_solid_visitor(), image); +} + +// Temporary until image_data_rgba8 is removed from passing +template <> +inline bool is_solid(image_data_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + +// Temporary until image_view_rgba8 is removed from passing +template <> +inline bool is_solid(image_view_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + inline bool is_png(std::string const& filename) { diff --git a/src/image_util.cpp b/src/image_util.cpp index ce1eaf7ed..8f6c00e13 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -182,67 +182,6 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons else throw ImageWriterException("Could not write file to " + filename ); } -namespace detail { - -struct is_solid_visitor -{ - template - bool operator() (T const & data) - { - using pixel_type = typename T::pixel_type; - if (data.width() > 0 && data.height() > 0) - { - pixel_type const* first_row = data.getRow(0); - pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < data.height(); ++y) - { - pixel_type const * row = data.getRow(y); - for (unsigned x = 0; x < data.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; - } -}; - -template bool is_solid_visitor::operator() (image_data_rgba8 const& data); -template bool is_solid_visitor::operator() (image_data_gray8 const& data); -template bool is_solid_visitor::operator() (image_data_gray16 const& data); -template bool is_solid_visitor::operator() (image_data_gray32f const& data); -template bool is_solid_visitor::operator() (image_view_rgba8 const& data); -template bool is_solid_visitor::operator() (image_view_gray8 const& data); -template bool is_solid_visitor::operator() (image_view_gray16 const& data); -template bool is_solid_visitor::operator() (image_view_gray32f const& data); - -} // end detail ns - -template -bool is_solid(T const& image) -{ - return util::apply_visitor(detail::is_solid_visitor(), image); -} - -// Temporary until image_data_rgba8 is removed from passing -template <> -bool is_solid(image_data_rgba8 const& image) -{ - detail::is_solid_visitor visitor; - return visitor(image); -} - -// Temporary until image_view_rgba8 is removed from passing -template <> -bool is_solid(image_view_rgba8 const& image) -{ - detail::is_solid_visitor visitor; - return visitor(image); -} - template void save_to_file(image_data_rgba8 const&, std::string const&, std::string const&); From 7ce7416999618b06d039e33361a077034c2bc0c0 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 13 Jan 2015 11:43:20 -0600 Subject: [PATCH 05/10] Added is_solid to image_utils. It is currently built to support the eventual use of image_view_any and image_data_any, but for a limited time supports the passing of image_view_rgba8 and image_data_rgba8. Ref #2633 --- bindings/python/mapnik_image.cpp | 19 +-------- bindings/python/mapnik_image_view.cpp | 18 +------- include/mapnik/image_util.hpp | 4 +- src/image_util.cpp | 61 +++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 4459edd21..7577878c3 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -121,24 +121,7 @@ bool painted(mapnik::image_32 const& im) bool is_solid(mapnik::image_32 const& im) { - if (im.width() > 0 && im.height() > 0) - { - mapnik::image_data_rgba8 const & data = im.data(); - mapnik::image_data_rgba8::pixel_type const* first_row = data.getRow(0); - mapnik::image_data_rgba8::pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < im.height(); ++y) - { - mapnik::image_data_rgba8::pixel_type const * row = data.getRow(y); - for (unsigned x = 0; x < im.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; + return mapnik::is_solid(im.data()); } unsigned get_pixel(mapnik::image_32 const& im, int x, int y) diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 8894a96eb..82ca74c8e 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -89,23 +89,7 @@ PyObject* view_tostring3(image_view_rgba8 const & view, std::string const& forma bool is_solid(image_view_rgba8 const& view) { - if (view.width() > 0 && view.height() > 0) - { - mapnik::image_view_rgba8::pixel_type const* first_row = view.getRow(0); - mapnik::image_view_rgba8::pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < view.height(); ++y) - { - mapnik::image_view_rgba8::pixel_type const * row = view.getRow(y); - for (unsigned x = 0; x < view.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; + mapnik::is_solid(view); } void save_view1(image_view_rgba8 const& view, diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 0cec4782c..31e2cf551 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -119,9 +119,7 @@ template MAPNIK_DECL void set_premultiplied_alpha(T & image, bool status); template -void save_as_png(T const& image, - std::string const& filename, - rgba_palette const& palette); +MAPNIK_DECL bool is_solid (T const& image); inline bool is_png(std::string const& filename) { diff --git a/src/image_util.cpp b/src/image_util.cpp index f71fe334f..85242add4 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -325,6 +325,67 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons else throw ImageWriterException("Could not write file to " + filename ); } +namespace detail { + +struct is_solid_visitor +{ + template + bool operator() (T const & data) + { + using pixel_type = typename T::pixel_type; + if (data.width() > 0 && data.height() > 0) + { + pixel_type const* first_row = data.getRow(0); + pixel_type const first_pixel = first_row[0]; + for (unsigned y = 0; y < data.height(); ++y) + { + pixel_type const * row = data.getRow(y); + for (unsigned x = 0; x < data.width(); ++x) + { + if (first_pixel != row[x]) + { + return false; + } + } + } + } + return true; + } +}; + +template bool is_solid_visitor::operator() (image_data_rgba8 const& data); +template bool is_solid_visitor::operator() (image_data_gray8 const& data); +template bool is_solid_visitor::operator() (image_data_gray16 const& data); +template bool is_solid_visitor::operator() (image_data_gray32f const& data); +template bool is_solid_visitor::operator() (image_view_rgba8 const& data); +template bool is_solid_visitor::operator() (image_view_gray8 const& data); +template bool is_solid_visitor::operator() (image_view_gray16 const& data); +template bool is_solid_visitor::operator() (image_view_gray32f const& data); + +} // end detail ns + +template +bool is_solid(T const& image) +{ + return util::apply_visitor(detail::is_solid_visitor(), image); +} + +// Temporary until image_data_rgba8 is removed from passing +template <> +bool is_solid(image_data_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + +// Temporary until image_view_rgba8 is removed from passing +template <> +bool is_solid(image_view_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + // image_data_rgba8 template void save_to_file(image_data_rgba8 const&, std::string const&, From 40c1649b0e211608c3b10b78dd1fa41d5d130aad Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:10:39 -0800 Subject: [PATCH 06/10] fix is_solid return --- bindings/python/mapnik_image_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/mapnik_image_view.cpp b/bindings/python/mapnik_image_view.cpp index 82ca74c8e..4d448e40a 100644 --- a/bindings/python/mapnik_image_view.cpp +++ b/bindings/python/mapnik_image_view.cpp @@ -89,7 +89,7 @@ PyObject* view_tostring3(image_view_rgba8 const & view, std::string const& forma bool is_solid(image_view_rgba8 const& view) { - mapnik::is_solid(view); + return mapnik::is_solid(view); } void save_view1(image_view_rgba8 const& view, From 61bc70511747843b3a64e7fadc31db2d6ae5a065 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:19:45 -0800 Subject: [PATCH 07/10] fix linking error with saving image --- include/mapnik/image.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp index ed2a1d1bc..d9ee28334 100644 --- a/include/mapnik/image.hpp +++ b/include/mapnik/image.hpp @@ -24,6 +24,7 @@ #define MAPNIK_IMAGE_HPP #include +#include namespace mapnik { From cf646030f33c1c49b6caf8bf7297a0e87439081b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Jan 2015 21:20:15 -0800 Subject: [PATCH 08/10] move is_solid to hpp for now to avoid linking errors --- include/mapnik/image_util.hpp | 1 + src/image_util.cpp | 121 +++++++++++++++++----------------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 31e2cf551..2c018a0bc 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -27,6 +27,7 @@ #include #include #include +#include // boost #pragma GCC diagnostic push diff --git a/src/image_util.cpp b/src/image_util.cpp index 85242add4..c01161497 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -325,67 +325,6 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons else throw ImageWriterException("Could not write file to " + filename ); } -namespace detail { - -struct is_solid_visitor -{ - template - bool operator() (T const & data) - { - using pixel_type = typename T::pixel_type; - if (data.width() > 0 && data.height() > 0) - { - pixel_type const* first_row = data.getRow(0); - pixel_type const first_pixel = first_row[0]; - for (unsigned y = 0; y < data.height(); ++y) - { - pixel_type const * row = data.getRow(y); - for (unsigned x = 0; x < data.width(); ++x) - { - if (first_pixel != row[x]) - { - return false; - } - } - } - } - return true; - } -}; - -template bool is_solid_visitor::operator() (image_data_rgba8 const& data); -template bool is_solid_visitor::operator() (image_data_gray8 const& data); -template bool is_solid_visitor::operator() (image_data_gray16 const& data); -template bool is_solid_visitor::operator() (image_data_gray32f const& data); -template bool is_solid_visitor::operator() (image_view_rgba8 const& data); -template bool is_solid_visitor::operator() (image_view_gray8 const& data); -template bool is_solid_visitor::operator() (image_view_gray16 const& data); -template bool is_solid_visitor::operator() (image_view_gray32f const& data); - -} // end detail ns - -template -bool is_solid(T const& image) -{ - return util::apply_visitor(detail::is_solid_visitor(), image); -} - -// Temporary until image_data_rgba8 is removed from passing -template <> -bool is_solid(image_data_rgba8 const& image) -{ - detail::is_solid_visitor visitor; - return visitor(image); -} - -// Temporary until image_view_rgba8 is removed from passing -template <> -bool is_solid(image_view_rgba8 const& image) -{ - detail::is_solid_visitor visitor; - return visitor(image); -} - // image_data_rgba8 template void save_to_file(image_data_rgba8 const&, std::string const&, @@ -458,6 +397,66 @@ template std::string save_to_string(image_data_any const&, std::string const&, rgba_palette const& palette); +namespace detail { + +struct is_solid_visitor +{ + template + bool operator() (T const & data) + { + using pixel_type = typename T::pixel_type; + if (data.width() > 0 && data.height() > 0) + { + pixel_type const* first_row = data.getRow(0); + pixel_type const first_pixel = first_row[0]; + for (unsigned y = 0; y < data.height(); ++y) + { + pixel_type const * row = data.getRow(y); + for (unsigned x = 0; x < data.width(); ++x) + { + if (first_pixel != row[x]) + { + return false; + } + } + } + } + return true; + } +}; + +template bool is_solid_visitor::operator() (image_data_rgba8 const& data); +template bool is_solid_visitor::operator() (image_data_gray8 const& data); +template bool is_solid_visitor::operator() (image_data_gray16 const& data); +template bool is_solid_visitor::operator() (image_data_gray32f const& data); +template bool is_solid_visitor::operator() (image_view_rgba8 const& data); +template bool is_solid_visitor::operator() (image_view_gray8 const& data); +template bool is_solid_visitor::operator() (image_view_gray16 const& data); +template bool is_solid_visitor::operator() (image_view_gray32f const& data); + +} // end detail ns + +template +MAPNIK_DECL bool is_solid(T const& image) +{ + return util::apply_visitor(detail::is_solid_visitor(), image); +} + +// Temporary until image_data_rgba8 is removed from passing +template <> +MAPNIK_DECL bool is_solid(image_data_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} + +// Temporary until image_view_rgba8 is removed from passing +template <> +MAPNIK_DECL bool is_solid(image_view_rgba8 const& image) +{ + detail::is_solid_visitor visitor; + return visitor(image); +} namespace detail { From 73d9c60168832a579fd993db2c0c3c04f7d07284 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 15 Jan 2015 10:53:21 -0600 Subject: [PATCH 09/10] Small fix for is solid to work with image_view_any and image_data_any properly. --- src/image_util.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/image_util.cpp b/src/image_util.cpp index c01161497..359ba06a6 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -434,6 +435,12 @@ template bool is_solid_visitor::operator() (image_view_gray8 c template bool is_solid_visitor::operator() (image_view_gray16 const& data); template bool is_solid_visitor::operator() (image_view_gray32f const& data); +template<> +bool is_solid_visitor::operator() (image_data_null const&) +{ + return true; +} + } // end detail ns template @@ -442,6 +449,9 @@ MAPNIK_DECL bool is_solid(T const& image) return util::apply_visitor(detail::is_solid_visitor(), image); } +template bool is_solid (image_data_any const&); +template bool is_solid (image_view_any const&); + // Temporary until image_data_rgba8 is removed from passing template <> MAPNIK_DECL bool is_solid(image_data_rgba8 const& image) From 4d3145991d8066031a9cbad41712ab02cba5cda1 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 15 Jan 2015 11:00:58 -0600 Subject: [PATCH 10/10] Removed some commented out code in src/image.cpp --- src/image.cpp | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index f30d025f2..6e71b80c9 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -52,54 +52,10 @@ image image::read_from_file(std::string const& filename) return image(); } } -/* -namespace detail { - -struct save_to_file_visitor -{ - save_to_file_visitor(std::string const& filename, std::string const& format) - : filename_(filename), - format_(format) {} - - void operator() (image_data_rgba8 const& data) const - { - 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 - { - throw std::runtime_error("Error: saving " + std::string(typeid(data).name()) + " as " + format_ + " is not supported"); - } - - std::string const& filename_; - std::string const& format_; -}; - -}*/ void image::save_to_file(std::string const& filename, std::string const& format) { mapnik::save_to_file(data_, filename, format); - //util::apply_visitor(detail::save_to_file_visitor(filename, format), data_); } }