From 08a3911b0acc18b0f96170e1b0c953d36b1b97c2 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 19 Mar 2015 21:28:16 -0500 Subject: [PATCH] Added the introduction of an image_view_null, this could possibly fix windows build issues --- include/mapnik/image_null.hpp | 2 +- include/mapnik/image_view.hpp | 3 +- include/mapnik/image_view_any.hpp | 6 ++- include/mapnik/image_view_null.hpp | 65 ++++++++++++++++++++++++++++++ src/image_util_jpeg.cpp | 6 +++ src/image_util_png.cpp | 12 ++++++ src/image_util_tiff.cpp | 7 ++++ src/image_util_webp.cpp | 6 +++ src/image_view.cpp | 2 + 9 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 include/mapnik/image_view_null.hpp diff --git a/include/mapnik/image_null.hpp b/include/mapnik/image_null.hpp index af7123ca6..422e4e108 100644 --- a/include/mapnik/image_null.hpp +++ b/include/mapnik/image_null.hpp @@ -34,7 +34,7 @@ namespace mapnik { template <> -class image +class MAPNIK_DECL image { public: using pixel_type = null_t::type; diff --git a/include/mapnik/image_view.hpp b/include/mapnik/image_view.hpp index eb4eac6e7..29e2731f7 100644 --- a/include/mapnik/image_view.hpp +++ b/include/mapnik/image_view.hpp @@ -35,7 +35,7 @@ public: using pixel_type = typename T::pixel_type; static const image_dtype dtype = T::dtype; static constexpr std::size_t pixel_size = sizeof(pixel_type); - image_view() = delete; + image_view(unsigned x, unsigned y, unsigned width, unsigned height, T const& data); ~image_view(); @@ -67,6 +67,7 @@ private: T const& data_; }; +using image_view_null = image_view; using image_view_rgba8 = image_view; using image_view_gray8 = image_view; using image_view_gray8s = image_view; diff --git a/include/mapnik/image_view_any.hpp b/include/mapnik/image_view_any.hpp index 3381f90c1..ca975d8a3 100644 --- a/include/mapnik/image_view_any.hpp +++ b/include/mapnik/image_view_any.hpp @@ -24,11 +24,13 @@ #define MAPNIK_IMAGE_VIEW_ANY_HPP #include +#include #include namespace mapnik { -using image_view_base = util::variant image_view_any(T && data) noexcept diff --git a/include/mapnik/image_view_null.hpp b/include/mapnik/image_view_null.hpp new file mode 100644 index 000000000..69276bdc1 --- /dev/null +++ b/include/mapnik/image_view_null.hpp @@ -0,0 +1,65 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_IMAGE_VIEW_NULL_HPP +#define MAPNIK_IMAGE_VIEW_NULL_HPP + +#include + +//stl +#include + +namespace mapnik { + +template <> +class MAPNIK_DECL image_view +{ +public: + using pixel_type = typename image_null::pixel_type; + static const image_dtype dtype = image_null::dtype; + + image_view() {} + ~image_view() {}; + + image_view(image_view const& rhs) {} + image_view & operator=(image_view const& rhs) { return *this; } + bool operator==(image_view const& rhs) const { return true; } + bool operator<(image_view const& rhs) const { return false; } + + unsigned x() const { return 0; } + unsigned y() const { return 0; } + unsigned width() const { return 0; } + unsigned height() const { return 0; } + const pixel_type& operator() (std::size_t i, std::size_t j) const { std::runtime_error("Can not get from a null image view"); } + unsigned getSize() const { return 0; } + unsigned getRowSize() const { return 0; } + const pixel_type* getRow(unsigned row) const { return nullptr; } + const pixel_type* getRow(unsigned row, std::size_t x0) const { return nullptr; } + bool get_premultiplied() const { return false; } + double get_offset() const { return 0.0; } + double get_scaling() const { return 1.0; } + image_dtype get_dtype() const { return dtype; } +}; + +} // end ns + +#endif // MAPNIK_IMAGE_VIEW_NULL_HPP diff --git a/src/image_util_jpeg.cpp b/src/image_util_jpeg.cpp index ff2b37ea3..e85971de9 100644 --- a/src/image_util_jpeg.cpp +++ b/src/image_util_jpeg.cpp @@ -96,6 +96,12 @@ void jpeg_saver::operator() (image_null const& image) const throw ImageWriterException("Can not save a null image to jpeg"); } +template<> +void jpeg_saver::operator() (image_view_null const& image) const +{ + throw ImageWriterException("Can not save a null image to jpeg"); +} + template void jpeg_saver::operator() (T const& image) const { diff --git a/src/image_util_png.cpp b/src/image_util_png.cpp index 68b2b66df..5b2ccc7f2 100644 --- a/src/image_util_png.cpp +++ b/src/image_util_png.cpp @@ -195,6 +195,18 @@ void png_saver_pal::operator() (image_null const& image) const throw ImageWriterException("null images not supported for png"); } +template<> +void png_saver::operator() (image_view_null const& image) const +{ + throw ImageWriterException("null image views not supported for png"); +} + +template<> +void png_saver_pal::operator() (image_view_null const& image) const +{ + throw ImageWriterException("null image views not supported for png"); +} + template void process_rgba8_png_pal(T const& image, std::string const& t, diff --git a/src/image_util_tiff.cpp b/src/image_util_tiff.cpp index 22f1924f1..fb611ca58 100644 --- a/src/image_util_tiff.cpp +++ b/src/image_util_tiff.cpp @@ -163,12 +163,19 @@ void handle_tiff_options(std::string const& type, tiff_saver::tiff_saver(std::ostream & stream, std::string const& t): stream_(stream), t_(t) {} + template<> void tiff_saver::operator() (image_null const& image) const { throw ImageWriterException("null images not supported"); } +template<> +void tiff_saver::operator() (image_view_null const& image) const +{ + throw ImageWriterException("null image views not supported"); +} + template void tiff_saver::operator() (T const& image) const { diff --git a/src/image_util_webp.cpp b/src/image_util_webp.cpp index 836039e40..eb1075a45 100644 --- a/src/image_util_webp.cpp +++ b/src/image_util_webp.cpp @@ -340,6 +340,12 @@ void webp_saver::operator() (image_null const& image) const throw ImageWriterException("null images not supported"); } +template<> +void webp_saver::operator() (image_view_null const& image) const +{ + throw ImageWriterException("null image views not supported"); +} + template void process_rgba8_webp(T const& image, std::string const& t, std::ostream & stream) { diff --git a/src/image_view.cpp b/src/image_view.cpp index 9a891ec85..138d0e403 100644 --- a/src/image_view.cpp +++ b/src/image_view.cpp @@ -24,11 +24,13 @@ // mapnik #include #include +#include #include namespace mapnik { +template class MAPNIK_DECL image_view; template class MAPNIK_DECL image_view; template class MAPNIK_DECL image_view; template class MAPNIK_DECL image_view;