Added the introduction of an image_view_null, this could possibly fix windows build issues

This commit is contained in:
Blake Thompson 2015-03-19 21:28:16 -05:00
parent f8010f0ba1
commit 08a3911b0a
9 changed files with 105 additions and 4 deletions

View file

@ -34,7 +34,7 @@ namespace mapnik
{
template <>
class image<null_t>
class MAPNIK_DECL image<null_t>
{
public:
using pixel_type = null_t::type;

View file

@ -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<image_null>;
using image_view_rgba8 = image_view<image_rgba8>;
using image_view_gray8 = image_view<image_gray8>;
using image_view_gray8s = image_view<image_gray8s>;

View file

@ -24,11 +24,13 @@
#define MAPNIK_IMAGE_VIEW_ANY_HPP
#include <mapnik/image_view.hpp>
#include <mapnik/image_view_null.hpp>
#include <mapnik/util/variant.hpp>
namespace mapnik {
using image_view_base = util::variant<image_view_rgba8,
using image_view_base = util::variant<image_view_null,
image_view_rgba8,
image_view_gray8,
image_view_gray8s,
image_view_gray16,
@ -42,7 +44,7 @@ using image_view_base = util::variant<image_view_rgba8,
struct MAPNIK_DECL image_view_any : image_view_base
{
image_view_any() = delete;
image_view_any() = default;
template <typename T>
image_view_any(T && data) noexcept

View file

@ -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 <mapnik/image.hpp>
//stl
#include <stdexcept>
namespace mapnik {
template <>
class MAPNIK_DECL image_view<image_null>
{
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<image_null> const& rhs) {}
image_view<image_null> & operator=(image_view<image_null> const& rhs) { return *this; }
bool operator==(image_view<image_null> const& rhs) const { return true; }
bool operator<(image_view<image_null> 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

View file

@ -96,6 +96,12 @@ void jpeg_saver::operator()<image_null> (image_null const& image) const
throw ImageWriterException("Can not save a null image to jpeg");
}
template<>
void jpeg_saver::operator()<image_view_null> (image_view_null const& image) const
{
throw ImageWriterException("Can not save a null image to jpeg");
}
template <typename T>
void jpeg_saver::operator() (T const& image) const
{

View file

@ -195,6 +195,18 @@ void png_saver_pal::operator()<image_null> (image_null const& image) const
throw ImageWriterException("null images not supported for png");
}
template<>
void png_saver::operator()<image_view_null> (image_view_null const& image) const
{
throw ImageWriterException("null image views not supported for png");
}
template<>
void png_saver_pal::operator()<image_view_null> (image_view_null const& image) const
{
throw ImageWriterException("null image views not supported for png");
}
template <typename T>
void process_rgba8_png_pal(T const& image,
std::string const& t,

View file

@ -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> (image_null const& image) const
{
throw ImageWriterException("null images not supported");
}
template<>
void tiff_saver::operator()<image_view_null> (image_view_null const& image) const
{
throw ImageWriterException("null image views not supported");
}
template <typename T>
void tiff_saver::operator() (T const& image) const
{

View file

@ -340,6 +340,12 @@ void webp_saver::operator()<image_null> (image_null const& image) const
throw ImageWriterException("null images not supported");
}
template<>
void webp_saver::operator()<image_view_null> (image_view_null const& image) const
{
throw ImageWriterException("null image views not supported");
}
template <typename T>
void process_rgba8_webp(T const& image, std::string const& t, std::ostream & stream)
{

View file

@ -24,11 +24,13 @@
// mapnik
#include <mapnik/image_view.hpp>
#include <mapnik/image_view_impl.hpp>
#include <mapnik/image_view_null.hpp>
#include <mapnik/pixel_types.hpp>
namespace mapnik
{
template class MAPNIK_DECL image_view<image_null>;
template class MAPNIK_DECL image_view<image_rgba8>;
template class MAPNIK_DECL image_view<image_gray8>;
template class MAPNIK_DECL image_view<image_gray8s>;