mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-13 02:38:07 +00:00
Added thirdparty: boost library
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/dynamic_images.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_homogeneous.hpp>
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
#include <boost/gil/channel.hpp>
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp> // boost::lazy_enable_if
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// channel_type metafunction
|
||||
/// \brief Generates the channel type for
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct gen_chan_ref
|
||||
{
|
||||
using type = packed_dynamic_channel_reference
|
||||
<
|
||||
B,
|
||||
mp11::mp_at_c<C, 0>::value,
|
||||
M
|
||||
>;
|
||||
};
|
||||
|
||||
//! This implementation works for bit_algined_pixel_reference
|
||||
//! with a homogeneous channel layout.
|
||||
//! The result type will be a packed_dynamic_channel_reference, since the
|
||||
//! offset info will be missing.
|
||||
|
||||
// bit_aligned_pixel_reference
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct channel_type< bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
|
||||
, gen_chan_ref< B, C, L, M >
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct channel_type<const bit_aligned_pixel_reference<B,C,L,M> >
|
||||
: lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
|
||||
, gen_chan_ref< B, C, L, M >
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct gen_chan_ref_p
|
||||
{
|
||||
using type = packed_dynamic_channel_reference
|
||||
<
|
||||
B,
|
||||
get_num_bits<mp11::mp_at_c<C, 0>>::value,
|
||||
true
|
||||
>;
|
||||
};
|
||||
|
||||
// packed_pixel
|
||||
template < typename BitField
|
||||
, typename ChannelRefs
|
||||
, typename Layout
|
||||
>
|
||||
struct channel_type< packed_pixel< BitField
|
||||
, ChannelRefs
|
||||
, Layout
|
||||
>
|
||||
> : lazy_enable_if< is_homogeneous< packed_pixel< BitField
|
||||
, ChannelRefs
|
||||
, Layout
|
||||
>
|
||||
>
|
||||
, gen_chan_ref_p< BitField
|
||||
, ChannelRefs
|
||||
, Layout
|
||||
>
|
||||
> {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct channel_type< const packed_pixel< B, C, L > >
|
||||
: lazy_enable_if< is_homogeneous<packed_pixel< B, C, L > >
|
||||
, gen_chan_ref_p< B, C, L >
|
||||
>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct channel_type< any_image_pixel_t >
|
||||
{
|
||||
using type = any_image_channel_t;
|
||||
};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Copyright 2010 Fabien Castan, Christian Henning
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
|
||||
|
||||
#include <boost/gil/image_view_factory.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace gil {
|
||||
|
||||
template <typename Channel, typename View>
|
||||
struct channel_type_to_index
|
||||
{
|
||||
static constexpr int value = detail::type_to_index
|
||||
<
|
||||
typename color_space_type<View>::type, // color (Boost.MP11-compatible list)
|
||||
Channel // channel type
|
||||
>::value; // index of the channel in the color (Boost.MP11-compatible list)
|
||||
};
|
||||
|
||||
template<typename Channel, typename View>
|
||||
struct channel_view_type : kth_channel_view_type
|
||||
<
|
||||
channel_type_to_index<Channel, View>::value,
|
||||
View
|
||||
>
|
||||
{
|
||||
static constexpr int index = channel_type_to_index
|
||||
<
|
||||
Channel,
|
||||
View
|
||||
>::value;
|
||||
|
||||
using parent_t = kth_channel_view_type<index, View>;
|
||||
using type = typename parent_t::type;
|
||||
|
||||
static type make( const View& src )
|
||||
{
|
||||
return parent_t::make( src );
|
||||
}
|
||||
};
|
||||
|
||||
/// \ingroup ImageViewTransformationsKthChannel
|
||||
template<typename Channel, typename View>
|
||||
auto channel_view(View const& src)
|
||||
-> typename channel_view_type<Channel, View>::type
|
||||
{
|
||||
return channel_view_type<Channel, View>::make(src);
|
||||
}
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_NUM_BITS_HPP
|
||||
|
||||
#include <boost/gil/channel.hpp>
|
||||
#include <boost/gil/detail/is_channel_integral.hpp>
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// get_num_bits metafunctions
|
||||
/// \brief Determines the numbers of bits for the given channel type.
|
||||
|
||||
template <typename T, class = void>
|
||||
struct get_num_bits;
|
||||
|
||||
template<typename B, int I, int S, bool M>
|
||||
struct get_num_bits<packed_channel_reference<B, I, S, M>>
|
||||
: std::integral_constant<int, S>
|
||||
{};
|
||||
|
||||
template<typename B, int I, int S, bool M>
|
||||
struct get_num_bits<packed_channel_reference<B, I, S, M> const>
|
||||
: std::integral_constant<int, S>
|
||||
{};
|
||||
|
||||
template<typename B, int I, bool M>
|
||||
struct get_num_bits<packed_dynamic_channel_reference<B, I, M>>
|
||||
: std::integral_constant<int, I>
|
||||
{};
|
||||
|
||||
template<typename B, int I, bool M>
|
||||
struct get_num_bits<packed_dynamic_channel_reference<B, I, M> const>
|
||||
: std::integral_constant<int, I>
|
||||
{};
|
||||
|
||||
template<int N>
|
||||
struct get_num_bits<packed_channel_value<N>> : std::integral_constant<int, N>
|
||||
{};
|
||||
|
||||
template<int N>
|
||||
struct get_num_bits<packed_channel_value<N> const> : std::integral_constant<int, N>
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct get_num_bits
|
||||
<
|
||||
T,
|
||||
typename std::enable_if
|
||||
<
|
||||
mp11::mp_and
|
||||
<
|
||||
detail::is_channel_integral<T>,
|
||||
mp11::mp_not<std::is_class<T>>
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
: std::integral_constant<std::size_t, sizeof(T) * 8>
|
||||
{};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
|
||||
|
||||
#include <boost/gil/extension/toolbox/dynamic_images.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
|
||||
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// get_pixel_type metafunction
|
||||
/// \brief Depending on Image this function generates either
|
||||
/// the pixel type or the reference type in case
|
||||
/// the image is bit_aligned.
|
||||
template<typename View>
|
||||
struct get_pixel_type
|
||||
{
|
||||
using type = mp11::mp_if
|
||||
<
|
||||
is_bit_aligned<typename View::value_type>,
|
||||
typename View::reference,
|
||||
typename View::value_type
|
||||
>;
|
||||
};
|
||||
|
||||
template<typename ...Views>
|
||||
struct get_pixel_type<any_image_view<Views...>>
|
||||
{
|
||||
using type = any_image_pixel_t;
|
||||
};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_BIT_ALIGNED_TYPE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_BIT_ALIGNED_TYPE_HPP
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_bit_aligned metafunctions
|
||||
/// \brief Determines whether the given type is bit_aligned.
|
||||
|
||||
template< typename PixelRef >
|
||||
struct is_bit_aligned : std::false_type {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_bit_aligned<bit_aligned_pixel_reference<B, C, L, M>> : std::true_type {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_bit_aligned<bit_aligned_pixel_reference<B, C, L, M> const> : std::true_type {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct is_bit_aligned<packed_pixel<B, C, L>> : std::true_type {};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct is_bit_aligned<packed_pixel<B, C, L> const> : std::true_type {};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_HOMOGENEOUS_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_HOMOGENEOUS_HPP
|
||||
|
||||
#include <boost/gil/pixel.hpp>
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_homogeneous metafunctions
|
||||
/// \brief Determines if a pixel types are homogeneous.
|
||||
|
||||
template<typename C,typename CMP, int Next, int Last>
|
||||
struct is_homogeneous_impl;
|
||||
|
||||
template<typename C, typename CMP, int Last>
|
||||
struct is_homogeneous_impl<C, CMP, Last, Last> : std::true_type {};
|
||||
|
||||
template<typename C, typename CMP, int Next, int Last>
|
||||
struct is_homogeneous_impl
|
||||
: mp11::mp_and
|
||||
<
|
||||
is_homogeneous_impl<C, CMP, Next + 1, Last>,
|
||||
std::is_same<CMP, mp11::mp_at_c<C, Next>>
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename P>
|
||||
struct is_homogeneous : std::false_type {};
|
||||
|
||||
// pixel
|
||||
template <typename C, typename L>
|
||||
struct is_homogeneous<pixel<C, L>> : std::true_type {};
|
||||
|
||||
template <typename C, typename L >
|
||||
struct is_homogeneous<pixel<C, L> const> : std::true_type {};
|
||||
|
||||
template <typename C, typename L>
|
||||
struct is_homogeneous<pixel<C, L>&> : std::true_type {};
|
||||
|
||||
template <typename C, typename L>
|
||||
struct is_homogeneous<pixel<C, L> const&> : std::true_type {};
|
||||
|
||||
// planar pixel reference
|
||||
template <typename Channel, typename ColorSpace>
|
||||
struct is_homogeneous<planar_pixel_reference<Channel, ColorSpace>> : std::true_type {};
|
||||
|
||||
template <typename Channel, typename ColorSpace>
|
||||
struct is_homogeneous<planar_pixel_reference<Channel, ColorSpace> const> : std::true_type {};
|
||||
|
||||
template<typename C, typename CMP, int I, int Last>
|
||||
struct is_homogeneous_impl_p {};
|
||||
|
||||
// for packed_pixel
|
||||
template <typename B, typename C, typename L>
|
||||
struct is_homogeneous<packed_pixel<B, C, L>>
|
||||
: is_homogeneous_impl_p
|
||||
<
|
||||
C,
|
||||
mp11::mp_at_c<C, 0>,
|
||||
1,
|
||||
mp11::mp_size<C>::value
|
||||
> {};
|
||||
|
||||
template< typename B
|
||||
, typename C
|
||||
, typename L
|
||||
>
|
||||
struct is_homogeneous<packed_pixel<B, C, L> const>
|
||||
: is_homogeneous_impl_p
|
||||
<
|
||||
C,
|
||||
mp11::mp_at_c<C, 0>,
|
||||
1,
|
||||
mp11::mp_size<C>::value
|
||||
> {};
|
||||
|
||||
// for bit_aligned_pixel_reference
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_homogeneous<bit_aligned_pixel_reference<B, C, L, M>>
|
||||
: is_homogeneous_impl<C, mp11::mp_at_c<C, 0>, 1, mp11::mp_size<C>::value>
|
||||
{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct is_homogeneous<const bit_aligned_pixel_reference<B, C, L, M> >
|
||||
: is_homogeneous_impl<C, mp11::mp_at_c<C, 0>, 1, mp11::mp_size<C>::value>
|
||||
{};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_SIMILAR_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_IS_SIMILAR_HPP
|
||||
|
||||
#include <boost/gil/channel.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// is_similar metafunctions
|
||||
/// \brief Determines if two pixel types are similar.
|
||||
|
||||
template<typename A, typename B>
|
||||
struct is_similar : std::false_type {};
|
||||
|
||||
template<typename A>
|
||||
struct is_similar<A, A> : std::true_type {};
|
||||
|
||||
template<typename B,int I, int S, bool M, int I2>
|
||||
struct is_similar
|
||||
<
|
||||
packed_channel_reference<B, I, S, M>,
|
||||
packed_channel_reference<B, I2, S, M>
|
||||
> : std::true_type {};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
|
||||
#define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
|
||||
|
||||
#include <boost/gil/bit_aligned_pixel_reference.hpp>
|
||||
#include <boost/gil/packed_pixel.hpp>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
/// pixel_bit_size metafunctions
|
||||
/// \brief Accumulates the all channel size.
|
||||
///
|
||||
/// \code
|
||||
/// using image_t = bit_aligned_image5_type<16, 16, 16, 8, 8, devicen_layout_t<5>>::type;
|
||||
/// const int size = pixel_bit_size<image_t::view_t::reference>::value;
|
||||
/// \endcode
|
||||
template< typename PixelRef>
|
||||
struct pixel_bit_size : std::integral_constant<int, 0> {};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M>>
|
||||
: mp11::mp_fold
|
||||
<
|
||||
C,
|
||||
std::integral_constant<int, 0>,
|
||||
mp11::mp_plus
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename B, typename C, typename L, bool M>
|
||||
struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M> const>
|
||||
: mp11::mp_fold
|
||||
<
|
||||
C,
|
||||
std::integral_constant<int, 0>,
|
||||
mp11::mp_plus
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct pixel_bit_size<packed_pixel<B, C, L>>
|
||||
: mp11::mp_fold
|
||||
<
|
||||
C,
|
||||
std::integral_constant<int, 0>,
|
||||
mp11::mp_plus
|
||||
>
|
||||
|
||||
{};
|
||||
|
||||
template <typename B, typename C, typename L>
|
||||
struct pixel_bit_size<const packed_pixel<B,C,L> >
|
||||
: mp11::mp_fold
|
||||
<
|
||||
C,
|
||||
std::integral_constant<int, 0>,
|
||||
mp11::mp_plus
|
||||
>
|
||||
{};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user