Boost GIL


channel.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3 
4  Use, modification and distribution are subject to the Boost Software License,
5  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6  http://www.boost.org/LICENSE_1_0.txt).
7 
8  See http://stlab.adobe.com/gil for most recent version including documentation.
9 */
10 
11 /*************************************************************************************************/
12 
13 #ifndef GIL_CHANNEL_HPP
14 #define GIL_CHANNEL_HPP
15 
26 
27 #include "utilities.hpp"
28 
29 #include <boost/config.hpp>
30 #include <boost/config/pragma_message.hpp>
31 #include <boost/integer/integer_mask.hpp>
32 #include <boost/type_traits/remove_cv.hpp>
33 
34 #include <limits>
35 #include <cassert>
36 #include <cstdint>
37 
38 #if defined(BOOST_GIL_DOXYGEN_ONLY)
39 #define BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS
47 #endif
48 
49 #if defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
50 #if defined(sun) || defined(__sun) || \ // SunOS
51  defined(__osf__) || defined(__osf) || \ // Tru64
52  defined(_hpux) || defined(hpux) || \ // HP-UX
53  defined(__arm__) || defined(__ARM_ARCH) || \ // ARM
54  defined(_AIX) // AIX
55 #error Unaligned access strictly disabled for some UNIX platforms or ARM architecture
56 #elif defined(__i386__) || defined(__x86_64__) || defined(__vax__)
57  // The check for little-endian architectures that tolerate unaligned memory
58  // accesses is just an optimization. Nothing will break if it fails to detect
59  // a suitable architecture.
60  //
61  // Unfortunately, this optimization may be a C/C++ strict aliasing rules violation
62  // if accessed data buffer has effective type that cannot be aliased
63  // without leading to undefined behaviour.
64 BOOST_PRAGMA_MESSAGE("CAUTION: Unaligned access tolerated on little-endian may cause undefined behaviour")
65 #else
66 #error Unaligned access disabled for unknown platforms and architectures
67 #endif
68 #endif // defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
69 
70 namespace boost { namespace gil {
71 
86 
87 namespace detail {
88  template <typename T, bool is_class> struct channel_traits_impl;
89 
90  // channel traits for custom class
91  template <typename T>
92  struct channel_traits_impl<T, true> {
93  typedef typename T::value_type value_type;
94  typedef typename T::reference reference;
95  typedef typename T::pointer pointer;
96  typedef typename T::const_reference const_reference;
97  typedef typename T::const_pointer const_pointer;
98  BOOST_STATIC_CONSTANT(bool, is_mutable=T::is_mutable);
99  static value_type min_value() { return T::min_value(); }
100  static value_type max_value() { return T::max_value(); }
101  };
102 
103  // channel traits implementation for built-in integral or floating point channel type
104  template <typename T>
105  struct channel_traits_impl<T, false> {
106  typedef T value_type;
107  typedef T& reference;
108  typedef T* pointer;
109  typedef const T& const_reference;
110  typedef T const* const_pointer;
111  BOOST_STATIC_CONSTANT(bool, is_mutable=true);
112  static value_type min_value() { return (std::numeric_limits<T>::min)(); }
113  static value_type max_value() { return (std::numeric_limits<T>::max)(); }
114  };
115 
116  // channel traits implementation for constant built-in scalar or floating point type
117  template <typename T>
118  struct channel_traits_impl<const T, false> : public channel_traits_impl<T, false> {
119  typedef const T& reference;
120  typedef const T* pointer;
121  BOOST_STATIC_CONSTANT(bool, is_mutable=false);
122  };
123 }
124 
143 template <typename T>
144 struct channel_traits : public detail::channel_traits_impl<T, is_class<T>::value> {};
145 
146 // Channel traits for C++ reference type - remove the reference
147 template <typename T> struct channel_traits< T&> : public channel_traits<T> {};
148 
149 // Channel traits for constant C++ reference type
150 template <typename T> struct channel_traits<const T&> : public channel_traits<T> {
151  typedef typename channel_traits<T>::const_reference reference;
152  typedef typename channel_traits<T>::const_pointer pointer;
153  BOOST_STATIC_CONSTANT(bool, is_mutable=false);
154 };
155 
161 
182 template <typename BaseChannelValue, // base channel (models ChannelValueConcept)
185  typename MinVal, typename MaxVal> // classes with a static apply() function returning the minimum/maximum channel values
186 struct scoped_channel_value {
187  typedef scoped_channel_value value_type;
188  typedef value_type& reference;
189  typedef value_type* pointer;
190  typedef const value_type& const_reference;
191  typedef const value_type* const_pointer;
192  BOOST_STATIC_CONSTANT(bool, is_mutable=channel_traits<BaseChannelValue>::is_mutable);
193 
194  typedef BaseChannelValue base_channel_t;
195 
196  static value_type min_value() { return MinVal::apply(); }
197  static value_type max_value() { return MaxVal::apply(); }
198 
199  scoped_channel_value() {}
200  scoped_channel_value(const scoped_channel_value& c) : _value(c._value) {}
201  scoped_channel_value(BaseChannelValue val) : _value(val) {}
202 
203  scoped_channel_value& operator++() { ++_value; return *this; }
204  scoped_channel_value& operator--() { --_value; return *this; }
205 
206  scoped_channel_value operator++(int) { scoped_channel_value tmp=*this; this->operator++(); return tmp; }
207  scoped_channel_value operator--(int) { scoped_channel_value tmp=*this; this->operator--(); return tmp; }
208 
209  template <typename Scalar2> scoped_channel_value& operator+=(Scalar2 v) { _value+=v; return *this; }
210  template <typename Scalar2> scoped_channel_value& operator-=(Scalar2 v) { _value-=v; return *this; }
211  template <typename Scalar2> scoped_channel_value& operator*=(Scalar2 v) { _value*=v; return *this; }
212  template <typename Scalar2> scoped_channel_value& operator/=(Scalar2 v) { _value/=v; return *this; }
213 
214  scoped_channel_value& operator=(BaseChannelValue v) { _value=v; return *this; }
215  operator BaseChannelValue() const { return _value; }
216 private:
217  BaseChannelValue _value;
218 };
219 
220 template <typename T>
221 struct float_point_zero
222 {
223  static constexpr T apply() { return 0.0f; }
224 };
225 
226 template <typename T>
227 struct float_point_one
228 {
229  static constexpr T apply() { return 1.0f; }
230 };
231 
237 
238 // It is necessary for packed channels to have their own value type. They cannot simply use an integral large enough to store the data. Here is why:
239 // - Any operation that requires returning the result by value will otherwise return the built-in integral type, which will have incorrect range
240 // That means that after getting the value of the channel we cannot properly do channel_convert, channel_invert, etc.
241 // - Two channels are declared compatible if they have the same value type. That means that a packed channel is incorrectly declared compatible with an integral type
242 namespace detail {
243  // returns the smallest fast unsigned integral type that has at least NumBits bits
244  template <int NumBits>
245  struct min_fast_uint : public mpl::if_c< (NumBits<=8),
246  uint_least8_t,
247  typename mpl::if_c< (NumBits<=16),
248  uint_least16_t,
249  typename mpl::if_c< (NumBits<=32),
250  uint_least32_t,
251  uintmax_t
252  >::type
253  >::type
254  > {};
255 
256  template <int NumBits>
257  struct num_value_fn : public mpl::if_c< ( NumBits < 32 )
258  , uint32_t
259  , uint64_t
260  > {};
261 
262  template <int NumBits>
263  struct max_value_fn : public mpl::if_c< ( NumBits <= 32 )
264  , uint32_t
265  , uint64_t
266  > {};
267 }
268 
285 template <int NumBits>
288 class packed_channel_value {
289 
290 public:
291  typedef typename detail::min_fast_uint<NumBits>::type integer_t;
292 
293 
294  typedef packed_channel_value value_type;
295  typedef value_type& reference;
296  typedef const value_type& const_reference;
297  typedef value_type* pointer;
298  typedef const value_type* const_pointer;
299 
300  static value_type min_value() { return 0; }
301  static value_type max_value() { return low_bits_mask_t< NumBits >::sig_bits; }
302 
303  BOOST_STATIC_CONSTANT(bool, is_mutable=true);
304 
305  packed_channel_value() {}
306 
307  packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v & low_bits_mask_t<NumBits>::sig_bits_fast ); }
308  template <typename Scalar> packed_channel_value(Scalar v) { _value = packed_channel_value( static_cast< integer_t >( v ) ); }
309 
310  static unsigned int num_bits() { return NumBits; }
311 
312  operator integer_t() const { return _value; }
313 private:
314  integer_t _value;
315 };
316 
317 namespace detail {
318 
319 template <std::size_t K>
320 struct static_copy_bytes {
321  void operator()(const unsigned char* from, unsigned char* to) const {
322  *to = *from;
323  static_copy_bytes<K-1>()(++from,++to);
324  }
325 };
326 
327 template <>
328 struct static_copy_bytes<0> {
329  void operator()(const unsigned char* , unsigned char*) const {}
330 };
331 
332 template <typename Derived, typename BitField, int NumBits, bool Mutable>
333 class packed_channel_reference_base {
334 protected:
335  typedef typename mpl::if_c<Mutable,void*,const void*>::type data_ptr_t;
336 public:
337  data_ptr_t _data_ptr; // void* pointer to the first byte of the bit range
338 
339  typedef packed_channel_value<NumBits> value_type;
340  typedef const Derived reference;
341  typedef value_type* pointer;
342  typedef const value_type* const_pointer;
343  BOOST_STATIC_CONSTANT(int, num_bits=NumBits);
344  BOOST_STATIC_CONSTANT(bool, is_mutable=Mutable);
345 
346  static value_type min_value() { return channel_traits<value_type>::min_value(); }
347  static value_type max_value() { return channel_traits<value_type>::max_value(); }
348 
349  typedef BitField bitfield_t;
350  typedef typename value_type::integer_t integer_t;
351 
352  packed_channel_reference_base(data_ptr_t data_ptr) : _data_ptr(data_ptr) {}
353  packed_channel_reference_base(const packed_channel_reference_base& ref) : _data_ptr(ref._data_ptr) {}
354  const Derived& operator=(integer_t v) const { set(v); return derived(); }
355 
356  const Derived& operator++() const { set(get()+1); return derived(); }
357  const Derived& operator--() const { set(get()-1); return derived(); }
358 
359  Derived operator++(int) const { Derived tmp=derived(); this->operator++(); return tmp; }
360  Derived operator--(int) const { Derived tmp=derived(); this->operator--(); return tmp; }
361 
362  template <typename Scalar2> const Derived& operator+=(Scalar2 v) const { set( static_cast<integer_t>( get() + v )); return derived(); }
363  template <typename Scalar2> const Derived& operator-=(Scalar2 v) const { set( static_cast<integer_t>( get() - v )); return derived(); }
364  template <typename Scalar2> const Derived& operator*=(Scalar2 v) const { set( static_cast<integer_t>( get() * v )); return derived(); }
365  template <typename Scalar2> const Derived& operator/=(Scalar2 v) const { set( static_cast<integer_t>( get() / v )); return derived(); }
366 
367  operator integer_t() const { return get(); }
368  data_ptr_t operator &() const {return _data_ptr;}
369 protected:
370 
371  typedef typename detail::num_value_fn< NumBits >::type num_value_t;
372  typedef typename detail::max_value_fn< NumBits >::type max_value_t;
373 
374  static const num_value_t num_values = static_cast< num_value_t >( 1 ) << NumBits ;
375  static const max_value_t max_val = static_cast< max_value_t >( num_values - 1 );
376 
377 #if defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
378  const bitfield_t& get_data() const { return *static_cast<const bitfield_t*>(_data_ptr); }
379  void set_data(const bitfield_t& val) const { *static_cast< bitfield_t*>(_data_ptr) = val; }
380 #else
381  bitfield_t get_data() const {
382  bitfield_t ret;
383  static_copy_bytes<sizeof(bitfield_t) >()(gil_reinterpret_cast_c<const unsigned char*>(_data_ptr),gil_reinterpret_cast<unsigned char*>(&ret));
384  return ret;
385  }
386  void set_data(const bitfield_t& val) const {
387  static_copy_bytes<sizeof(bitfield_t) >()(gil_reinterpret_cast_c<const unsigned char*>(&val),gil_reinterpret_cast<unsigned char*>(_data_ptr));
388  }
389 #endif
390 
391 private:
392  void set(integer_t value) const { // can this be done faster??
393  this->derived().set_unsafe(((value % num_values) + num_values) % num_values);
394  }
395  integer_t get() const { return derived().get(); }
396  const Derived& derived() const { return static_cast<const Derived&>(*this); }
397 };
398 } // namespace detail
399 
416 template <typename BitField, // A type that holds the bits of the pixel from which the channel is referenced. Typically an integral type, like std::uint16_t
417  int FirstBit, int NumBits,// Defines the sequence of bits in the data value that contain the channel
418  bool Mutable> // true if the reference is mutable
419 class packed_channel_reference;
420 
421 template <typename BitField, // A type that holds the bits of the pixel from which the channel is referenced. Typically an integral type, like std::uint16_t
422  int NumBits, // Defines the sequence of bits in the data value that contain the channel
423  bool Mutable> // true if the reference is mutable
424 class packed_dynamic_channel_reference;
425 
428 template <typename BitField, int FirstBit, int NumBits>
429 class packed_channel_reference<BitField,FirstBit,NumBits,false>
430  : public detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,false>,BitField,NumBits,false> {
431  typedef detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,false>,BitField,NumBits,false> parent_t;
432  friend class packed_channel_reference<BitField,FirstBit,NumBits,true>;
433 
434  static const BitField channel_mask = static_cast< BitField >( parent_t::max_val ) << FirstBit;
435 
436  void operator=(const packed_channel_reference&);
437 public:
438  typedef const packed_channel_reference<BitField,FirstBit,NumBits,false> const_reference;
439  typedef const packed_channel_reference<BitField,FirstBit,NumBits,true> mutable_reference;
440  typedef typename parent_t::integer_t integer_t;
441 
442  explicit packed_channel_reference(const void* data_ptr) : parent_t(data_ptr) {}
443  packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data_ptr) {}
444  packed_channel_reference(const mutable_reference& ref) : parent_t(ref._data_ptr) {}
445 
446  unsigned first_bit() const { return FirstBit; }
447 
448  integer_t get() const { return integer_t((this->get_data()&channel_mask) >> FirstBit); }
449 };
450 
453 template <typename BitField, int FirstBit, int NumBits>
454 class packed_channel_reference<BitField,FirstBit,NumBits,true>
455  : public detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true> {
456  typedef detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true> parent_t;
457  friend class packed_channel_reference<BitField,FirstBit,NumBits,false>;
458 
459  static const BitField channel_mask = static_cast< BitField >( parent_t::max_val ) << FirstBit;
460 
461 public:
462  typedef const packed_channel_reference<BitField,FirstBit,NumBits,false> const_reference;
463  typedef const packed_channel_reference<BitField,FirstBit,NumBits,true> mutable_reference;
464  typedef typename parent_t::integer_t integer_t;
465 
466  explicit packed_channel_reference(void* data_ptr) : parent_t(data_ptr) {}
467  packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data_ptr) {}
468 
469  const packed_channel_reference& operator=(integer_t value) const { assert(value<=parent_t::max_val); set_unsafe(value); return *this; }
470  const packed_channel_reference& operator=(const mutable_reference& ref) const { set_from_reference(ref.get_data()); return *this; }
471  const packed_channel_reference& operator=(const const_reference& ref) const { set_from_reference(ref.get_data()); return *this; }
472 
473  template <bool Mutable1>
474  const packed_channel_reference& operator=(const packed_dynamic_channel_reference<BitField,NumBits,Mutable1>& ref) const { set_unsafe(ref.get()); return *this; }
475 
476  unsigned first_bit() const { return FirstBit; }
477 
478  integer_t get() const { return integer_t((this->get_data()&channel_mask) >> FirstBit); }
479  void set_unsafe(integer_t value) const { this->set_data((this->get_data() & ~channel_mask) | (( static_cast< BitField >( value )<<FirstBit))); }
480 private:
481  void set_from_reference(const BitField& other_bits) const { this->set_data((this->get_data() & ~channel_mask) | (other_bits & channel_mask)); }
482 };
483 
484 } } // namespace boost::gil
485 
486 namespace std {
487 // We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
488 // swap with 'left bias':
489 // - swap between proxy and anything
490 // - swap between value type and proxy
491 // - swap between proxy and proxy
492 
495 template <typename BF, int FB, int NB, bool M, typename R> inline
496 void swap(const boost::gil::packed_channel_reference<BF,FB,NB,M> x, R& y) {
497  boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
498 }
499 
500 
503 template <typename BF, int FB, int NB, bool M> inline
504 void swap(typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type& x, const boost::gil::packed_channel_reference<BF,FB,NB,M> y) {
505  boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
506 }
507 
510 template <typename BF, int FB, int NB, bool M> inline
511 void swap(const boost::gil::packed_channel_reference<BF,FB,NB,M> x, const boost::gil::packed_channel_reference<BF,FB,NB,M> y) {
512  boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
513 }
514 } // namespace std
515 
516 namespace boost { namespace gil {
517 
535 template <typename BitField, int NumBits>
539 class packed_dynamic_channel_reference<BitField,NumBits,false>
540  : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false> {
541  typedef detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false> parent_t;
542  friend class packed_dynamic_channel_reference<BitField,NumBits,true>;
543 
544  unsigned _first_bit; // 0..7
545 
546  void operator=(const packed_dynamic_channel_reference&);
547 public:
548  typedef const packed_dynamic_channel_reference<BitField,NumBits,false> const_reference;
549  typedef const packed_dynamic_channel_reference<BitField,NumBits,true> mutable_reference;
550  typedef typename parent_t::integer_t integer_t;
551 
552  packed_dynamic_channel_reference(const void* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
553  packed_dynamic_channel_reference(const const_reference& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
554  packed_dynamic_channel_reference(const mutable_reference& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
555 
556  unsigned first_bit() const { return _first_bit; }
557 
558  integer_t get() const {
559  const BitField channel_mask = static_cast< integer_t >( parent_t::max_val ) <<_first_bit;
560  return static_cast< integer_t >(( this->get_data()&channel_mask ) >> _first_bit );
561  }
562 };
563 
567 template <typename BitField, int NumBits>
568 class packed_dynamic_channel_reference<BitField,NumBits,true>
569  : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true> {
570  typedef detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true> parent_t;
571  friend class packed_dynamic_channel_reference<BitField,NumBits,false>;
572 
573  unsigned _first_bit;
574 
575 public:
578  typedef typename parent_t::integer_t integer_t;
579 
580  packed_dynamic_channel_reference(void* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
581  packed_dynamic_channel_reference(const packed_dynamic_channel_reference& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
582 
583  const packed_dynamic_channel_reference& operator=(integer_t value) const { assert(value<=parent_t::max_val); set_unsafe(value); return *this; }
584  const packed_dynamic_channel_reference& operator=(const mutable_reference& ref) const { set_unsafe(ref.get()); return *this; }
585  const packed_dynamic_channel_reference& operator=(const const_reference& ref) const { set_unsafe(ref.get()); return *this; }
586 
587  template <typename BitField1, int FirstBit1, bool Mutable1>
588  const packed_dynamic_channel_reference& operator=(const packed_channel_reference<BitField1, FirstBit1, NumBits, Mutable1>& ref) const
589  { set_unsafe(ref.get()); return *this; }
590 
591  unsigned first_bit() const { return _first_bit; }
592 
593  integer_t get() const {
594  const BitField channel_mask = static_cast< integer_t >( parent_t::max_val ) << _first_bit;
595  return static_cast< integer_t >(( this->get_data()&channel_mask ) >> _first_bit );
596  }
597 
598  void set_unsafe(integer_t value) const {
599  const BitField channel_mask = static_cast< integer_t >( parent_t::max_val ) << _first_bit;
600  this->set_data((this->get_data() & ~channel_mask) | value<<_first_bit);
601  }
602 };
603 } } // namespace boost::gil
604 
605 namespace std {
606 // We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
607 // swap with 'left bias':
608 // - swap between proxy and anything
609 // - swap between value type and proxy
610 // - swap between proxy and proxy
611 
612 
615 template <typename BF, int NB, bool M, typename R> inline
616 void swap(const boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, R& y) {
617  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
618 }
619 
620 
623 template <typename BF, int NB, bool M> inline
624 void swap(typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type& x, const boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
625  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
626 }
627 
630 template <typename BF, int NB, bool M> inline
631 void swap(const boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, const boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
632  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
633 }
634 } // namespace std
635 
636 namespace boost {
637 
638 template <int NumBits>
639 struct is_integral<gil::packed_channel_value<NumBits> > : public mpl::true_ {};
640 
641 template <typename BitField, int FirstBit, int NumBits, bool IsMutable>
642 struct is_integral<gil::packed_channel_reference<BitField,FirstBit,NumBits,IsMutable> > : public mpl::true_ {};
643 
644 template <typename BitField, int NumBits, bool IsMutable>
645 struct is_integral<gil::packed_dynamic_channel_reference<BitField,NumBits,IsMutable> > : public mpl::true_ {};
646 
647 template <typename BaseChannelValue, typename MinVal, typename MaxVal>
648 struct is_integral<gil::scoped_channel_value<BaseChannelValue,MinVal,MaxVal> > : public is_integral<BaseChannelValue> {};
649 
650 } // namespace boost
651 
652 // \brief Determines the fundamental type which may be used, e.g., to cast from larger to smaller channel types.
653 namespace boost { namespace gil {
654 template <typename T>
655 struct base_channel_type_impl { typedef T type; };
656 
657 template <int N>
658 struct base_channel_type_impl<packed_channel_value<N> >
659 { typedef typename packed_channel_value<N>::integer_t type; };
660 
661 template <typename B, int F, int N, bool M>
662 struct base_channel_type_impl<packed_channel_reference<B, F, N, M> >
663 { typedef typename packed_channel_reference<B,F,N,M>::integer_t type; };
664 
665 template <typename B, int N, bool M>
666 struct base_channel_type_impl<packed_dynamic_channel_reference<B, N, M> >
667 { typedef typename packed_dynamic_channel_reference<B,N,M>::integer_t type; };
668 
669 template <typename ChannelValue, typename MinV, typename MaxV>
670 struct base_channel_type_impl<scoped_channel_value<ChannelValue, MinV, MaxV> >
671 { typedef ChannelValue type; };
672 
673 template <typename T>
674 struct base_channel_type : base_channel_type_impl<typename remove_cv<T>::type > {};
675 
676 }} //namespace boost::gil
677 
678 #endif
void swap(const boost::gil::packed_dynamic_channel_reference< BF, NB, M > x, const boost::gil::packed_dynamic_channel_reference< BF, NB, M > y)
swap for packed_dynamic_channel_reference
Definition: channel.hpp:631
Models a constant subbyte channel reference whose bit offset is a runtime parameter. Models ChannelConcept Same as packed_channel_reference, except that the offset is a runtime parameter.
Definition: channel.hpp:539
Models a mutable subbyte channel reference whose bit offset is a runtime parameter. Models ChannelConcept Same as packed_channel_reference, except that the offset is a runtime parameter.
Definition: channel.hpp:568
Various utilities not specific to the image library. Some are non-standard STL extensions or generic ...