2015-03-13 23:28:22 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2015-06-16 12:49:16 +02:00
|
|
|
* Copyright (C) 2015 Artem Pavlenko
|
2015-03-13 23:28:22 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <mapnik/image_view_any.hpp>
|
|
|
|
|
|
|
|
namespace mapnik {
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
struct get_view_width_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
std::size_t operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.width();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_height_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
std::size_t operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.height();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_size_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
2015-06-16 04:36:36 +02:00
|
|
|
std::size_t operator()(T const& data) const
|
2015-03-13 23:28:22 +01:00
|
|
|
{
|
2015-05-04 10:57:57 +02:00
|
|
|
return data.size();
|
2015-03-13 23:28:22 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_dtype_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
image_dtype operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.get_dtype();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_row_size_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
2015-06-16 04:36:36 +02:00
|
|
|
std::size_t operator()(T const& data) const
|
2015-03-13 23:28:22 +01:00
|
|
|
{
|
2015-05-04 10:57:57 +02:00
|
|
|
return data.row_size();
|
2015-03-13 23:28:22 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_premultiplied_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
bool operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.get_premultiplied();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_offset_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
double operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.get_offset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct get_view_scaling_visitor
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
double operator()(T const& data) const
|
|
|
|
{
|
|
|
|
return data.get_scaling();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace detail
|
|
|
|
|
|
|
|
std::size_t image_view_any::width() const
|
|
|
|
{
|
|
|
|
return util::apply_visitor(detail::get_view_width_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t image_view_any::height() const
|
|
|
|
{
|
|
|
|
return util::apply_visitor(detail::get_view_height_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
2015-05-04 10:57:57 +02:00
|
|
|
std::size_t image_view_any::size() const
|
2015-03-13 23:28:22 +01:00
|
|
|
{
|
|
|
|
return util::apply_visitor(detail::get_view_size_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
2015-05-04 10:57:57 +02:00
|
|
|
std::size_t image_view_any::row_size() const
|
2015-03-13 23:28:22 +01:00
|
|
|
{
|
|
|
|
return util::apply_visitor(detail::get_view_row_size_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool image_view_any::get_premultiplied() const
|
2015-05-04 10:57:57 +02:00
|
|
|
{
|
2015-03-13 23:28:22 +01:00
|
|
|
return util::apply_visitor(detail::get_view_premultiplied_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
double image_view_any::get_offset() const
|
2015-05-04 10:57:57 +02:00
|
|
|
{
|
2015-03-13 23:28:22 +01:00
|
|
|
return util::apply_visitor(detail::get_view_offset_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
double image_view_any::get_scaling() const
|
2015-05-04 10:57:57 +02:00
|
|
|
{
|
2015-03-13 23:28:22 +01:00
|
|
|
return util::apply_visitor(detail::get_view_scaling_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
image_dtype image_view_any::get_dtype() const
|
2015-05-04 10:57:57 +02:00
|
|
|
{
|
2015-03-13 23:28:22 +01:00
|
|
|
return util::apply_visitor(detail::get_view_dtype_visitor(),*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end mapnik ns
|