8 #ifndef BOOST_GIL_METAFUNCTIONS_HPP     9 #define BOOST_GIL_METAFUNCTIONS_HPP    11 #include <boost/gil/channel.hpp>    12 #include <boost/gil/dynamic_step.hpp>    13 #include <boost/gil/concepts.hpp>    14 #include <boost/gil/concepts/detail/type_traits.hpp>    15 #include <boost/gil/detail/mp11.hpp>    18 #include <type_traits>    20 namespace boost { 
namespace gil {
    23 template <
typename T, 
typename L> 
struct pixel;
    24 template <
typename BitField,
typename ChannelRefs,
typename Layout> 
struct packed_pixel;
    30 template <
typename Pixel, 
bool IsPlanar, 
typename Alloc> 
class image;
    32 template <
typename T> 
struct color_space_type;
    33 template <
typename T> 
struct channel_mapping_type;
    36 template <
typename BitField, 
typename ChannelBitSizes, 
typename Layout, 
bool IsMutable> 
struct bit_aligned_pixel_reference;
    56 template <
typename PixelRef>
    59 template <
typename T, 
typename L>
    62 template <
typename T, 
typename L>
    63 struct pixel_reference_is_basic<const pixel<T, L>&> : std::true_type {};
    65 template <
typename TR, 
typename CS>
    66 struct pixel_reference_is_basic<planar_pixel_reference<TR, CS>> : std::true_type {};
    68 template <
typename TR, 
typename CS>
    69 struct pixel_reference_is_basic<const planar_pixel_reference<TR, CS>> : std::true_type {};
    74 template <
typename Iterator>
    78 template <
typename T, 
typename L>
    82 template <
typename T, 
typename L>
    86 template <
typename T, 
typename CS>
    90 template <
typename T, 
typename CS>
    94 template <
typename T, 
typename L>
    98 template <
typename T, 
typename L>
   102 template <
typename T, 
typename CS>
   108 template <
typename T, 
typename CS>
   116 template <
typename Loc>
   119 template <
typename Iterator>
   128 template <
typename View>
   131 template <
typename Loc>
   136 template <
typename Img>
   139 template <
typename Pixel, 
bool IsPlanar, 
typename Alloc>
   147 template <
typename I>
   152 template <
typename It, 
bool IsBase, 
bool EqualsStepType>
   153 struct iterator_is_step_impl;
   156 template <
typename It, 
bool IsBase>
   157 struct iterator_is_step_impl<It, IsBase, true> : std::true_type {};
   160 template <
typename It>
   161 struct iterator_is_step_impl<It, true, false> : std::false_type {};
   164 template <
typename It>
   165 struct iterator_is_step_impl<It, false, false>
   166     : 
public iterator_is_step<typename iterator_adaptor_get_base<It>::type> {};
   172 template <
typename I>
   173 struct iterator_is_step
   174     : detail::iterator_is_step_impl
   177         !is_iterator_adaptor<I>::value,
   178         std::is_same<I, typename dynamic_x_step_type<I>::type
   201 template <
typename PixelReference>
   207             typename detail::remove_const_and_reference<PixelReference>::type,
   208             typename detail::remove_const_and_reference<PixelReference>::type::value_type
   215 template <
typename Pixel>
   217     : mp11::mp_or<is_reference<Pixel>, pixel_reference_is_proxy<Pixel>> {};
   227 template <
typename R>
   229     : std::integral_constant<bool, std::remove_reference<R>::type::is_mutable>
   232 template <
typename R>
   268 template <
typename T, 
typename L> 
struct pixel_reference_type<T,L,false,false> { 
using type = pixel<T,L> 
const&; };
   269 template <
typename T, 
typename L> 
struct pixel_reference_type<T,L,true,true> { 
using type = planar_pixel_reference<typename channel_traits<T>::reference,
typename color_space_type<L>::type> 
const; };       
   270 template <
typename T, 
typename L> 
struct pixel_reference_type<T,L,true,false> { 
using type = planar_pixel_reference<typename channel_traits<T>::const_reference,
typename color_space_type<L>::type> 
const; };
   276 template <
typename Pixel> 
struct iterator_type_from_pixel<Pixel,false,false,false> { 
using type = 
const Pixel *; };
   277 template <
typename Pixel> 
struct iterator_type_from_pixel<Pixel,true,false,true> {
   278     using type = planar_pixel_iterator<typename channel_traits<typename channel_type<Pixel>::type>::pointer,
typename color_space_type<Pixel>::type>;
   280 template <
typename Pixel> 
struct iterator_type_from_pixel<Pixel,true,false,false> {
   281     using type = planar_pixel_iterator<typename channel_traits<typename channel_type<Pixel>::type>::const_pointer,
typename color_space_type<Pixel>::type>;
   283 template <
typename Pixel, 
bool IsPlanar, 
bool IsMutable> 
struct iterator_type_from_pixel<Pixel,IsPlanar,true,IsMutable> {
   284     using type = memory_based_step_iterator<typename iterator_type_from_pixel<Pixel,IsPlanar,false,IsMutable>::type>;
   289 template <
typename T, 
typename L, 
bool IsPlanar=false, 
bool IsStep=false, 
bool IsMutable=true> 
struct iterator_type{};
   291 template <
typename T, 
typename L> 
struct iterator_type<T,L,false,false,false> { 
using type = pixel<T,L> 
const*; };
   292 template <
typename T, 
typename L> 
struct iterator_type<T,L,true,false,true> { 
using type = planar_pixel_iterator<T*,typename L::color_space_t>; };               
   293 template <
typename T, 
typename L> 
struct iterator_type<T,L,true,false,false> { 
using type = planar_pixel_iterator<const T*,typename L::color_space_t>; };        
   294 template <
typename T, 
typename L, 
bool IsPlanar, 
bool IsMutable> 
struct iterator_type<T,L,IsPlanar,true,IsMutable> {
   295     using type = memory_based_step_iterator<typename iterator_type<T,L,IsPlanar,false,IsMutable>::type>;
   300 template <
typename XIterator>
   310 template <
typename BitField, 
typename FirstBit, 
typename NumBits>
   311 struct packed_channel_reference_type
   313     using type = packed_channel_reference
   315             BitField, FirstBit::value, NumBits::value, 
true   319 template <
typename BitField, 
typename ChannelBitSizes>
   320 class packed_channel_references_vector_type
   322     template <
typename FirstBit, 
typename NumBits>
   323     using reference_type = 
typename packed_channel_reference_type<BitField, FirstBit, NumBits>::type;
   327     using first_bit_list = mp11::mp_fold_q
   330             mp11::mp_list<std::integral_constant<int, 0>>,
   338                     mp11::mp_bind<mp_back, mp11::_1>,
   344     static_assert(mp11::mp_at_c<first_bit_list, 0>::value == 0, 
"packed channel first bit must be 0");
   347     using type = mp11::mp_transform
   350             mp_pop_back<first_bit_list>,
   365 template <
typename BitField, 
typename ChannelBitSizes, 
typename Layout>
   371             typename detail::packed_channel_references_vector_type
   390 template <
typename BitField, 
typename ChannelBitSizes, 
typename Layout, 
typename Alloc=std::allocator<
unsigned char>>
   398 template <
typename BitField, 
unsigned Size1, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   405 template <
typename BitField, 
unsigned Size1, 
unsigned Size2, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   407     : 
packed_image_type<BitField, mp11::mp_list_c<unsigned, Size1, Size2>, Layout, Alloc>
   412 template <
typename BitField, 
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   414     : 
packed_image_type<BitField, mp11::mp_list_c<unsigned, Size1, Size2, Size3>, Layout, Alloc>
   419 template <
typename BitField, 
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
unsigned Size4, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   421     : 
packed_image_type<BitField, mp11::mp_list_c<unsigned, Size1, Size2, Size3, Size4>, Layout, Alloc>
   426 template <
typename BitField, 
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
unsigned Size4, 
unsigned Size5, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   428     : 
packed_image_type<BitField, mp11::mp_list_c<unsigned, Size1, Size2, Size3, Size4, Size5>, Layout, Alloc> {};
   439     typename ChannelBitSizes,
   441     typename Alloc = std::allocator<unsigned char>
   447     static constexpr 
int bit_size =
   451             std::integral_constant<int, 0>,
   455     using bitfield_t = 
typename detail::min_fast_uint<bit_size + 7>::type;
   456     using bit_alignedref_t = bit_aligned_pixel_reference<bitfield_t, ChannelBitSizes, Layout, true> 
const;
   464 template <
unsigned Size1, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   469 template <
unsigned Size1, 
unsigned Size2, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   474 template <
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   479 template <
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
unsigned Size4, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   484 template <
unsigned Size1, 
unsigned Size2, 
unsigned Size3, 
unsigned Size4, 
unsigned Size5, 
typename Layout, 
typename Alloc = std::allocator<
unsigned char>>
   490 template <
typename Channel, 
typename Layout>
   498 template <
typename BitField, 
int NumBits, 
bool IsMutable, 
typename Layout>
   499 struct pixel_value_type<packed_dynamic_channel_reference<BitField, NumBits, IsMutable>, Layout>
   503 template <
typename BitField, 
int NumBits, 
bool IsMutable, 
typename Layout>
   504 struct pixel_value_type<packed_dynamic_channel_reference<BitField, NumBits, IsMutable> const, Layout>
   505     : packed_pixel_type<BitField, mp11::mp_list_c<unsigned, NumBits>, Layout>
   508 template <
typename BitField, 
int FirstBit, 
int NumBits, 
bool IsMutable, 
typename Layout>
   509 struct pixel_value_type<packed_channel_reference<BitField, FirstBit, NumBits, IsMutable>, Layout>
   510     : packed_pixel_type<BitField, mp11::mp_list_c<unsigned, NumBits>, Layout>
   513 template <
typename BitField, 
int FirstBit, 
int NumBits, 
bool IsMutable, 
typename Layout>
   514 struct pixel_value_type<packed_channel_reference<BitField, FirstBit, NumBits, IsMutable> const, Layout>
   515     : packed_pixel_type<BitField, mp11::mp_list_c<unsigned, NumBits>, Layout>
   518 template <
int NumBits, 
typename Layout>
   519 struct pixel_value_type<packed_channel_value<NumBits>, Layout>
   520     : packed_pixel_type<typename detail::min_fast_uint<NumBits>::type, mp11::mp_list_c<unsigned, NumBits>, Layout>
   525 template <
typename T, 
typename L, 
bool IsPlanar = false, 
bool IsStepX = false, 
bool IsMutable = true>
   536 template <
typename T, 
typename L, 
bool IsPlanar = false, 
bool IsStepX = false, 
bool IsMutable = true>
   547 template <
typename T, 
typename L, 
bool IsPlanar = false, 
typename Alloc = std::allocator<
unsigned char>>
   555 template <
typename Pixel, 
bool IsPlanar=false, 
bool IsStepX=false, 
bool IsMutable=true>
   567         typename T = use_default,
   568         typename L = use_default,
   569         typename IsPlanar = use_default,
   570         typename IsMutable = use_default>
   573     using pixel_t = 
typename std::remove_reference<Ref>::type;
   575     using channel_t = 
typename mp11::mp_if
   577             std::is_same<T, use_default>,
   582     using layout_t = 
typename  mp11::mp_if
   584             std::is_same<L, use_default>,
   587                 typename color_space_type<pixel_t>::type,
   588                 typename channel_mapping_type<pixel_t>::type
   593     static bool const mut = mp11::mp_if
   595             std::is_same<IsMutable, use_default>,
   600     static bool const planar = mp11::mp_if
   602             std::is_same<IsPlanar, use_default>,
   617     typename T = use_default,
   618     typename L = use_default,
   619     typename IsPlanar = use_default,
   620     typename IsStep = use_default,
   621     typename IsMutable = use_default
   625     using channel_t = 
typename mp11::mp_if
   627             std::is_same<T, use_default>,
   632     using layout_t = 
typename mp11::mp_if
   634             std::is_same<L, use_default>,
   637                 typename color_space_type<Iterator>::type,
   638                 typename channel_mapping_type<Iterator>::type
   643     static const bool mut = mp11::mp_if
   645             std::is_same<IsMutable, use_default>,
   650     static bool const planar = mp11::mp_if
   652             std::is_same<IsPlanar, use_default>,
   657     static bool const step = mp11::mp_if
   659             std::is_same<IsStep, use_default>,
   671 template <
typename View, 
typename T = use_default, 
typename L = use_default, 
typename IsPlanar = use_default, 
typename StepX = use_default, 
typename IsMutable = use_default>
   674     using channel_t = 
typename mp11::mp_if
   676             std::is_same<T, use_default>,
   681     using layout_t = 
typename mp11::mp_if
   683             std::is_same<L, use_default>,
   686                 typename color_space_type<View>::type,
   687                 typename channel_mapping_type<View>::type
   692     static bool const mut = mp11::mp_if
   694             std::is_same<IsMutable, use_default>,
   699     static bool const planar = mp11::mp_if
   701             std::is_same<IsPlanar, use_default>,
   706     static bool const step = mp11::mp_if
   708             std::is_same<StepX, use_default>,
   714     using type = 
typename view_type<channel_t, layout_t, planar, step, mut>::type;
   720 template <
typename Image, 
typename T = use_default, 
typename L = use_default, 
typename IsPlanar = use_default>
   723     using channel_t = 
typename mp11::mp_if
   725             std::is_same<T, use_default>,
   730     using layout_t = 
typename mp11::mp_if
   732             std::is_same<L, use_default>,
   735                 typename color_space_type<Image>::type,
   736                 typename channel_mapping_type<Image>::type>,
   740     static bool const planar = mp11::mp_if
   742             std::is_same<IsPlanar, use_default>,
 metafunction predicate determining whether the given iterator is a plain one or an adaptor over anoth...
Definition: metafunctions.hpp:34
Returns the type of an interleaved packed image: an image whose channels may not be byte-aligned,...
Definition: metafunctions.hpp:391
Determines whether the given pixel reference is a proxy class or a native C++ reference.
Definition: metafunctions.hpp:202
A reference proxy to a planar pixel.
Definition: metafunctions.hpp:25
Returns the type of a homogeneous image given the channel type, layout, and whether it operates on pl...
Definition: metafunctions.hpp:548
Determines if the given locator has a horizontal step that could be set dynamically.
Definition: metafunctions.hpp:185
Returns the type of a homogeneous view given the channel type, layout, whether it operates on planar ...
Definition: metafunctions.hpp:537
A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,...
Definition: image_view.hpp:53
returns the base iterator for a given iterator adaptor. Provide an specialization when introducing ne...
Definition: metafunctions.hpp:35
Returns the type of a single-channel image given its bitfield type, the bit size of its channel and i...
Definition: metafunctions.hpp:399
Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept,...
Definition: metafunctions.hpp:23
Returns the type of a homogeneous iterator given the channel type, layout, whether it operates on pla...
Definition: metafunctions.hpp:289
Returns the type of a four channel image given its bitfield type, the bit size of its channels and it...
Definition: metafunctions.hpp:420
Returns the type of a two channel image given its bitfield type, the bit size of its channels and its...
Definition: metafunctions.hpp:406
Returns the type of a five channel bit-aligned image given the bit size of its channels and its layou...
Definition: metafunctions.hpp:485
Constructs a pixel iterator type from a source pixel iterator type by changing some of the properties...
Definition: metafunctions.hpp:623
An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept,...
Definition: algorithm.hpp:34
Determines if a given pixel iterator is basic Basic iterators must use gil::pixel (if interleaved),...
Definition: metafunctions.hpp:75
Constructs a pixel reference type from a source pixel reference type by changing some of the properti...
Definition: metafunctions.hpp:571
Returns the type of a four channel bit-aligned image given the bit size of its channels and its layou...
Definition: metafunctions.hpp:480
Memory-based pixel locator. Models: PixelLocatorConcept,HasDynamicXStepTypeConcept,...
Definition: algorithm.hpp:38
Given a pixel iterator defining access to pixels along a row, returns the types of the corresponding ...
Definition: metafunctions.hpp:301
Basic images must use basic views and std::allocator.
Definition: metafunctions.hpp:137
Determines if the given pixel reference is mutable (i.e. its channels can be changed)
Definition: metafunctions.hpp:228
Determines if the given locator is mutable (i.e. its pixels can be changed)
Definition: metafunctions.hpp:239
Constructs a homogeneous image type from a source image type by changing some of the properties....
Definition: metafunctions.hpp:721
Represents a color space and ordering of channels in memory.
Definition: utilities.hpp:266
container interface over image view. Models ImageConcept, PixelBasedConcept
Definition: image.hpp:41
Determines if a given locator is basic. A basic locator is memory-based and has basic x_iterator and ...
Definition: metafunctions.hpp:117
Returns the type of a homogeneous pixel reference given the channel type, layout, whether it operates...
Definition: metafunctions.hpp:266
Returns the type of a packed image whose pixels may not be byte aligned. For example,...
Definition: metafunctions.hpp:443
Determines if the given view has a vertical step that could be set dynamically.
Definition: metafunctions.hpp:197
Determines if the given view is mutable (i.e. its pixels can be changed)
Definition: metafunctions.hpp:242
Definition: color_convert.hpp:31
Returns the type of a homogeneous pixel given the channel type and layout.
Definition: metafunctions.hpp:491
Returns the type of a homogeneous locator given the channel type, layout, whether it operates on plan...
Definition: metafunctions.hpp:526
Metafunction predicate returning whether the given iterator allows for changing its values.
Definition: pixel_iterator.hpp:49
Constructs an image view type from a source view type by changing some of the properties....
Definition: metafunctions.hpp:672
Returns the type of a packed pixel given its bitfield type, the bit size of its channels and its layo...
Definition: metafunctions.hpp:366
Heterogeneous pixel value whose channel references can be constructed from the pixel bitfield and the...
Definition: metafunctions.hpp:24
Given a model of a pixel, determines whether the model represents a pixel reference (as opposed to pi...
Definition: metafunctions.hpp:216
Returns the type of a single-channel bit-aligned image given the bit size of its channel and its layo...
Definition: metafunctions.hpp:465
Determines if a given pixel reference is basic Basic references must use gil::pixel& (if interleaved)...
Definition: metafunctions.hpp:57
Returns the type of a three channel image given its bitfield type, the bit size of its channels and i...
Definition: metafunctions.hpp:413
Determines if the given locator has a vertical step that could be set dynamically.
Definition: metafunctions.hpp:189
Basic views must be over basic locators.
Definition: metafunctions.hpp:129
Determines if the given iterator has a step that could be set dynamically.
Definition: metafunctions.hpp:148
Returns the type of a two channel bit-aligned image given the bit size of its channels and its layout...
Definition: metafunctions.hpp:470
Returns the type of a pixel iterator given the pixel type, whether it operates on planar data,...
Definition: metafunctions.hpp:274
Returns the type of a view the pixel type, whether it operates on planar data and whether it has a st...
Definition: metafunctions.hpp:556
MEMORY-BASED STEP ITERATOR.
Definition: algorithm.hpp:36
Returns the type of a three channel bit-aligned image given the bit size of its channels and its layo...
Definition: metafunctions.hpp:475
Determines if the given view has a horizontal step that could be set dynamically.
Definition: metafunctions.hpp:193
Returns the type of a five channel image given its bitfield type, the bit size of its channels and it...
Definition: metafunctions.hpp:427