143 lines
3.3 KiB
C++
143 lines
3.3 KiB
C++
/*****************************************************************************
|
|
*
|
|
* 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
|
|
*
|
|
*****************************************************************************/
|
|
|
|
#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>
|
|
unsigned operator()(T const& data) const
|
|
{
|
|
return data.getSize();
|
|
}
|
|
};
|
|
|
|
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>
|
|
unsigned operator()(T const& data) const
|
|
{
|
|
return data.getRowSize();
|
|
}
|
|
};
|
|
|
|
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);
|
|
}
|
|
|
|
unsigned image_view_any::getSize() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_size_visitor(),*this);
|
|
}
|
|
|
|
unsigned image_view_any::getRowSize() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_row_size_visitor(),*this);
|
|
}
|
|
|
|
bool image_view_any::get_premultiplied() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_premultiplied_visitor(),*this);
|
|
}
|
|
|
|
double image_view_any::get_offset() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_offset_visitor(),*this);
|
|
}
|
|
|
|
double image_view_any::get_scaling() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_scaling_visitor(),*this);
|
|
}
|
|
|
|
image_dtype image_view_any::get_dtype() const
|
|
{
|
|
return util::apply_visitor(detail::get_view_dtype_visitor(),*this);
|
|
}
|
|
|
|
} // end mapnik ns
|