8 #ifndef BOOST_GIL_METAFUNCTIONS_HPP
9 #define BOOST_GIL_METAFUNCTIONS_HPP
11 #include <boost/gil/channel.hpp>
12 #include <boost/gil/concepts.hpp>
14 #include <boost/mpl/accumulate.hpp>
15 #include <boost/mpl/back.hpp>
16 #include <boost/mpl/bool.hpp>
17 #include <boost/mpl/if.hpp>
18 #include <boost/mpl/pop_back.hpp>
19 #include <boost/mpl/push_back.hpp>
20 #include <boost/mpl/transform.hpp>
21 #include <boost/mpl/vector.hpp>
22 #include <boost/mpl/vector_c.hpp>
23 #include <boost/type_traits.hpp>
27 namespace boost {
namespace gil {
30 template <
typename T,
typename L>
struct pixel;
31 template <
typename BitField,
typename ChannelRefVec,
typename Layout>
struct packed_pixel;
37 template <
typename Pixel,
bool IsPlanar,
typename Alloc>
class image;
39 template <
typename T>
struct color_space_type;
40 template <
typename T>
struct channel_mapping_type;
65 template <
typename T,
typename L>
struct pixel_reference_is_basic<const pixel<T,L>&> :
public mpl::true_ {};
66 template <
typename TR,
typename Cs>
struct pixel_reference_is_basic<planar_pixel_reference<TR,Cs> > :
public mpl::true_ {};
67 template <
typename TR,
typename Cs>
struct pixel_reference_is_basic<const planar_pixel_reference<TR,Cs> > :
public mpl::true_ {};
73 template <
typename Iterator>
75 template <
typename T,
typename L>
77 template <
typename T,
typename L>
78 struct iterator_is_basic<const pixel<T,L>* > :
public mpl::true_ {};
79 template <
typename T,
typename Cs>
80 struct iterator_is_basic<planar_pixel_iterator< T*,Cs> > :
public mpl::true_ {};
81 template <
typename T,
typename Cs>
82 struct iterator_is_basic<planar_pixel_iterator<const T*,Cs> > :
public mpl::true_ {};
83 template <
typename T,
typename L>
84 struct iterator_is_basic<memory_based_step_iterator< pixel<T,L>*> > :
public mpl::true_ {};
85 template <
typename T,
typename L>
86 struct iterator_is_basic<memory_based_step_iterator<const pixel<T,L>*> > :
public mpl::true_ {};
87 template <
typename T,
typename Cs>
88 struct iterator_is_basic<memory_based_step_iterator<planar_pixel_iterator< T*,Cs> > > :
public mpl::true_ {};
89 template <
typename T,
typename Cs>
90 struct iterator_is_basic<memory_based_step_iterator<planar_pixel_iterator<const T*,Cs> > > :
public mpl::true_ {};
106 template <
typename Pixel,
bool IsPlanar,
typename Alloc>
struct image_is_basic<
image<Pixel,IsPlanar,Alloc> > :
public mpl::true_ {};
115 template <
typename It,
bool IsBase,
bool EqualsStepType>
struct iterator_is_step_impl;
117 template <
typename It,
bool IsBase>
struct iterator_is_step_impl<It,IsBase,true> :
public mpl::true_{};
120 template <
typename It>
struct iterator_is_step_impl<It,true,false> :
public mpl::false_{};
123 template <
typename It>
struct iterator_is_step_impl<It,false,false>
124 :
public iterator_is_step<typename iterator_adaptor_get_base<It>::type>{};
129 template <
typename I>
struct iterator_is_step
130 :
public detail::iterator_is_step_impl<I,
131 !is_iterator_adaptor<I>::type::value,
132 is_same<I,typename dynamic_x_step_type<I>::type>::value >{};
152 template <
typename PixelReference>
154 :
public mpl::not_<is_same<typename remove_const_and_reference<PixelReference>::type,
155 typename remove_const_and_reference<PixelReference>::type::value_type> > {};
159 template <
typename Pixel>
160 struct pixel_is_reference :
public mpl::or_<is_reference<Pixel>, pixel_reference_is_proxy<Pixel> > {};
205 template <
typename T,
typename L>
struct pixel_reference_type<T,L,false,false> {
typedef const pixel<T,L>& type; };
206 template <
typename T,
typename L>
struct pixel_reference_type<T,L,true,true> {
typedef const planar_pixel_reference<typename channel_traits<T>::reference,
typename color_space_type<L>::type> type; };
207 template <
typename T,
typename L>
struct pixel_reference_type<T,L,true,false> {
typedef const planar_pixel_reference<typename channel_traits<T>::const_reference,
typename color_space_type<L>::type> type; };
213 template <
typename Pixel>
struct iterator_type_from_pixel<Pixel,false,false,false> {
typedef const Pixel* type; };
214 template <
typename Pixel>
struct iterator_type_from_pixel<Pixel,true,false,true> {
215 typedef planar_pixel_iterator<typename channel_traits<typename channel_type<Pixel>::type>::pointer,
typename color_space_type<Pixel>::type> type;
217 template <
typename Pixel>
struct iterator_type_from_pixel<Pixel,true,false,false> {
218 typedef planar_pixel_iterator<typename channel_traits<typename channel_type<Pixel>::type>::const_pointer,
typename color_space_type<Pixel>::type> type;
220 template <
typename Pixel,
bool IsPlanar,
bool IsMutable>
struct iterator_type_from_pixel<Pixel,IsPlanar,true,IsMutable> {
221 typedef memory_based_step_iterator<typename iterator_type_from_pixel<Pixel,IsPlanar,false,IsMutable>::type> type;
226 template <
typename T,
typename L,
bool IsPlanar=false,
bool IsStep=false,
bool IsMutable=true>
struct iterator_type{};
228 template <
typename T,
typename L>
struct iterator_type<T,L,false,false,false> {
typedef const pixel<T,L>* type; };
229 template <
typename T,
typename L>
struct iterator_type<T,L,true,false,true> {
typedef planar_pixel_iterator<T*,typename L::color_space_t> type; };
230 template <
typename T,
typename L>
struct iterator_type<T,L,true,false,false> {
typedef planar_pixel_iterator<const T*,typename L::color_space_t> type; };
231 template <
typename T,
typename L,
bool IsPlanar,
bool IsMutable>
struct iterator_type<T,L,IsPlanar,true,IsMutable> {
232 typedef memory_based_step_iterator<typename iterator_type<T,L,IsPlanar,false,IsMutable>::type> type;
237 template <
typename XIterator>
245 template <
typename BitField,
typename FirstBit,
typename NumBits>
246 struct packed_channel_reference_type {
247 typedef const packed_channel_reference<BitField,FirstBit::value,NumBits::value,true> type;
250 template <
typename BitField,
typename ChannelBitSizesVector>
251 class packed_channel_references_vector_type {
254 typedef typename mpl::accumulate<ChannelBitSizesVector, mpl::vector1<mpl::int_<0> >,
255 mpl::push_back<mpl::_1, mpl::plus<mpl::back<mpl::_1>, mpl::_2> > >::type first_bits_vector;
257 typedef typename mpl::transform<typename mpl::pop_back<first_bits_vector>::type, ChannelBitSizesVector,
258 packed_channel_reference_type<BitField, mpl::_1,mpl::_2> >::type type;
271 template <
typename BitField,
typename ChannelBitSizeVector,
typename Layout>
287 template <
typename BitField,
typename ChannelBitSizeVector,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
294 template <
typename BitField,
unsigned Size1,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
299 template <
typename BitField,
unsigned Size1,
unsigned Size2,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
304 template <
typename BitField,
unsigned Size1,
unsigned Size2,
unsigned Size3,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
309 template <
typename BitField,
unsigned Size1,
unsigned Size2,
unsigned Size3,
unsigned Size4,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
314 template <
typename BitField,
unsigned Size1,
unsigned Size2,
unsigned Size3,
unsigned Size4,
unsigned Size5,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
324 template <
typename ChannelBitSizeVector,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
327 BOOST_STATIC_CONSTANT(
int, bit_size = (mpl::accumulate<ChannelBitSizeVector, mpl::int_<0>, mpl::plus<mpl::_1, mpl::_2> >::type::value));
328 typedef typename detail::min_fast_uint<bit_size+7>::type bitfield_t;
336 template <
unsigned Size1,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
341 template <
unsigned Size1,
unsigned Size2,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
346 template <
unsigned Size1,
unsigned Size2,
unsigned Size3,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
351 template <
unsigned Size1,
unsigned Size2,
unsigned Size3,
unsigned Size4,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
356 template <
unsigned Size1,
unsigned Size2,
unsigned Size3,
unsigned Size4,
unsigned Size5,
typename Layout,
typename Alloc=std::allocator<
unsigned char> >
363 template <
typename Channel,
typename Layout>
369 template <
typename BitField,
int NumBits,
bool IsMutable,
typename Layout>
370 struct pixel_value_type< packed_dynamic_channel_reference<BitField,NumBits,IsMutable>,Layout> :
372 template <
typename BitField,
int NumBits,
bool IsMutable,
typename Layout>
373 struct pixel_value_type<const packed_dynamic_channel_reference<BitField,NumBits,IsMutable>,Layout> :
374 public packed_pixel_type<BitField, mpl::vector1_c<unsigned,NumBits>, Layout> {};
376 template <
typename BitField,
int FirstBit,
int NumBits,
bool IsMutable,
typename Layout>
377 struct pixel_value_type< packed_channel_reference<BitField,FirstBit,NumBits,IsMutable>,Layout> :
378 public packed_pixel_type<BitField, mpl::vector1_c<unsigned,NumBits>, Layout> {};
379 template <
typename BitField,
int FirstBit,
int NumBits,
bool IsMutable,
typename Layout>
380 struct pixel_value_type<const packed_channel_reference<BitField,FirstBit,NumBits,IsMutable>,Layout> :
381 public packed_pixel_type<BitField, mpl::vector1_c<unsigned,NumBits>, Layout> {};
383 template <
int NumBits,
typename Layout>
384 struct pixel_value_type<packed_channel_value<NumBits>,Layout> :
385 public packed_pixel_type<typename detail::min_fast_uint<NumBits>::type, mpl::vector1_c<unsigned,NumBits>, Layout> {};
390 template <
typename T,
typename L,
bool IsPlanar=false,
bool IsStepX=false,
bool IsMutable=true>
397 template <
typename T,
typename L,
bool IsPlanar=false,
bool IsStepX=false,
bool IsMutable=true>
404 template <
typename T,
typename L,
bool IsPlanar=false,
typename Alloc=std::allocator<
unsigned char> >
411 template <
typename Pixel,
bool IsPlanar=false,
bool IsStepX=false,
bool IsMutable=true>
420 template <
typename Ref,
typename T=use_default,
typename L=use_default,
typename IsPlanar=use_default,
typename IsMutable=use_default>
422 typedef typename remove_reference<Ref>::type pixel_t;
424 typedef typename mpl::if_<is_same<L, use_default>,
427 static const bool planar=mpl::if_<is_same<IsPlanar,use_default>, is_planar<pixel_t>, IsPlanar>::type::value;
435 template <
typename Iterator,
typename T=use_default,
typename L=use_default,
typename IsPlanar=use_default,
typename IsStep=use_default,
typename IsMutable=use_default>
438 typedef typename mpl::if_<is_same<L,use_default>,
442 static const bool planar=mpl::if_<is_same<IsPlanar,use_default>, is_planar<Iterator>, IsPlanar>::type::value;
451 template <
typename View,
typename T=use_default,
typename L=use_default,
typename IsPlanar=use_default,
typename StepX=use_default,
typename IsMutable=use_default>
454 typedef typename mpl::if_<is_same<L,use_default>,
456 static const bool mut =mpl::if_<is_same<IsMutable,use_default>,
view_is_mutable<View>, IsMutable>::type::value;
457 static const bool planar=mpl::if_<is_same<IsPlanar,use_default>, is_planar<View>, IsPlanar>::type::value;
466 template <
typename Image,
typename T=use_default,
typename L=use_default,
typename IsPlanar=use_default>
469 typedef typename mpl::if_<is_same<L,use_default>,
471 static const bool planar=mpl::if_<is_same<IsPlanar,use_default>, is_planar<Image>, IsPlanar>::type::value;
metafunction predicate determining whether the given iterator is a plain one or an adaptor over anoth...
Definition: concepts.hpp:60
Returns the type of an interleaved packed image: an image whose channels may not be byte-aligned...
Definition: metafunctions.hpp:288
Determines whether the given pixel reference is a proxy class or a native C++ reference.
Definition: metafunctions.hpp:153
A reference proxy to a planar pixel. Models: HomogeneousColorBaseConcept, HomogeneousPixelConcept.
Definition: metafunctions.hpp:32
Returns the type of a homogeneous image given the channel type, layout, and whether it operates on pl...
Definition: metafunctions.hpp:405
Determines if the given locator has a horizontal step that could be set dynamically.
Definition: metafunctions.hpp:136
Returns the type of a homogeneous view given the channel type, layout, whether it operates on planar ...
Definition: metafunctions.hpp:398
A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,PixelBasedConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConcept.
Definition: image_view.hpp:50
returns the base iterator for a given iterator adaptor. Provide an specialization when introducing ne...
Definition: concepts.hpp:62
Returns the type of a single-channel image given its bitfield type, the bit size of its channel and i...
Definition: metafunctions.hpp:295
Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept, PixelValueConcept, HomogeneousPixelBasedConcept.
Definition: metafunctions.hpp:30
Returns the type of a homogeneous iterator given the channel type, layout, whether it operates on pla...
Definition: metafunctions.hpp:226
Returns the type of a four channel image given its bitfield type, the bit size of its channels and it...
Definition: metafunctions.hpp:310
Returns the type of a two channel image given its bitfield type, the bit size of its channels and its...
Definition: metafunctions.hpp:300
Returns the type of a five channel bit-aligned image given the bit size of its channels and its layou...
Definition: metafunctions.hpp:357
Heterogeneous pixel reference corresponding to non-byte-aligned bit range. Models ColorBaseConcept...
Definition: bit_aligned_pixel_reference.hpp:113
Constructs a pixel iterator type from a source pixel iterator type by changing some of the properties...
Definition: metafunctions.hpp:436
An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept, HomogeneousPixelBasedConcept, MemoryBasedIteratorConcept, HasDynamicXStepTypeConcept.
Definition: algorithm.hpp:34
Determines if a given pixel iterator is basic Basic iterators must use gil::pixel (if interleaved)...
Definition: metafunctions.hpp:74
Constructs a pixel reference type from a source pixel reference type by changing some of the properti...
Definition: metafunctions.hpp:421
Returns the type of a four channel bit-aligned image given the bit size of its channels and its layou...
Definition: metafunctions.hpp:352
Memory-based pixel locator. Models: PixelLocatorConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConceptThe class takes a step iterator as a parameter. The step iterator provides navigation along the vertical axis while its base iterator provides horizontal navigation.
Definition: algorithm.hpp:38
Given a pixel iterator defining access to pixels along a row, returns the types of the corresponding ...
Definition: metafunctions.hpp:238
Basic images must use basic views and std::allocator.
Definition: metafunctions.hpp:105
Determines if the given pixel reference is mutable (i.e. its channels can be changed) ...
Definition: metafunctions.hpp:170
Determines if the given locator is mutable (i.e. its pixels can be changed)
Definition: metafunctions.hpp:176
Constructs a homogeneous image type from a source image type by changing some of the properties...
Definition: metafunctions.hpp:467
Represents a color space and ordering of channels in memory.
Definition: utilities.hpp:246
container interface over image view. Models ImageConcept, PixelBasedConcept
Definition: image.hpp:39
Determines if a given locator is basic. A basic locator is memory-based and has basic x_iterator and ...
Definition: metafunctions.hpp:95
Returns the type of a homogeneous pixel reference given the channel type, layout, whether it operates...
Definition: metafunctions.hpp:203
Returns the type of a packed image whose pixels may not be byte aligned. For example, an "rgb222" image is bit-aligned because its pixel spans six bits.
Definition: metafunctions.hpp:325
Determines if the given view has a vertical step that could be set dynamically.
Definition: metafunctions.hpp:148
Determines if the given view is mutable (i.e. its pixels can be changed)
Definition: metafunctions.hpp:179
Definition: color_convert.hpp:30
Returns the type of a homogeneous pixel given the channel type and layout.
Definition: metafunctions.hpp:364
Returns the type of a homogeneous locator given the channel type, layout, whether it operates on plan...
Definition: metafunctions.hpp:391
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: concepts.hpp:59
Constructs an image view type from a source view type by changing some of the properties.Use use_default for the properties of the source view that you want to keep.
Definition: metafunctions.hpp:452
Returns the type of a packed pixel given its bitfield type, the bit size of its channels and its layo...
Definition: metafunctions.hpp:272
Heterogeneous pixel value whose channel references can be constructed from the pixel bitfield and the...
Definition: concepts.hpp:73
Given a model of a pixel, determines whether the model represents a pixel reference (as opposed to pi...
Definition: metafunctions.hpp:160
Returns the type of a single-channel bit-aligned image given the bit size of its channel and its layo...
Definition: metafunctions.hpp:337
Determines if a given pixel reference is basic Basic references must use gil::pixel& (if interleaved)...
Definition: metafunctions.hpp:63
Returns the type of a three channel image given its bitfield type, the bit size of its channels and i...
Definition: metafunctions.hpp:305
Determines if the given locator has a vertical step that could be set dynamically.
Definition: metafunctions.hpp:140
Basic views must be over basic locators.
Definition: metafunctions.hpp:100
Determines if the given iterator has a step that could be set dynamically.
Definition: metafunctions.hpp:113
Returns the type of a two channel bit-aligned image given the bit size of its channels and its layout...
Definition: metafunctions.hpp:342
Returns the type of a pixel iterator given the pixel type, whether it operates on planar data...
Definition: metafunctions.hpp:211
Returns the type of a view the pixel type, whether it operates on planar data and whether it has a st...
Definition: metafunctions.hpp:412
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:347
Determines if the given view has a horizontal step that could be set dynamically. ...
Definition: metafunctions.hpp:144
Returns the type of a five channel image given its bitfield type, the bit size of its channels and it...
Definition: metafunctions.hpp:315