8 #ifndef BOOST_GIL_BIT_ALIGNED_PIXEL_ITERATOR_HPP     9 #define BOOST_GIL_BIT_ALIGNED_PIXEL_ITERATOR_HPP    11 #include <boost/gil/bit_aligned_pixel_reference.hpp>    12 #include <boost/gil/pixel_iterator.hpp>    14 #include <boost/config.hpp>    15 #include <boost/iterator/iterator_facade.hpp>    18 #include <type_traits>    20 namespace boost { 
namespace gil {
    36 template <
typename NonAlignedPixelReference>
    38                                                   typename NonAlignedPixelReference::value_type,
    39                                                   std::random_access_iterator_tag,
    40                                                   const NonAlignedPixelReference,
    41                                                   typename NonAlignedPixelReference::bit_range_t::difference_type> {
    43     using parent_t = iterator_facade<bit_aligned_pixel_iterator<NonAlignedPixelReference>,
    44                             typename NonAlignedPixelReference::value_type,
    45                             std::random_access_iterator_tag,
    46                             const NonAlignedPixelReference,
    47                             typename NonAlignedPixelReference::bit_range_t::difference_type>;
    50     using bit_range_t = 
typename NonAlignedPixelReference::bit_range_t;
    52     using difference_type = 
typename parent_t::difference_type;
    53     using reference = 
typename parent_t::reference;
    68     reference operator->()
         const { 
return **
this; }
    69     const bit_range_t& bit_range()
 const { 
return _bit_range; }
    70           bit_range_t& bit_range()       { 
return _bit_range; }
    72     bit_range_t _bit_range;
    73     static constexpr 
int bit_size = NonAlignedPixelReference::bit_size;
    75     friend class boost::iterator_core_access;
    76     reference dereference()
     const { 
return NonAlignedPixelReference(_bit_range); }
    77     void increment()                  { ++_bit_range; }
    78     void decrement()                  { --_bit_range; }
    79     void advance(difference_type d)   { _bit_range.bit_advance(d*bit_size); }
    81     difference_type distance_to(
const bit_aligned_pixel_iterator& it)
 const { 
return _bit_range.bit_distance_to(it._bit_range) / bit_size; }
    82     bool equal(
const bit_aligned_pixel_iterator& it)
 const { 
return _bit_range==it._bit_range; }
    85 template <
typename NonAlignedPixelReference>
    86 struct const_iterator_type<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
    89         bit_aligned_pixel_iterator<typename NonAlignedPixelReference::const_reference>;
    92 template <
typename NonAlignedPixelReference>
    93 struct iterator_is_mutable<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
    94     : std::integral_constant<bool, NonAlignedPixelReference::is_mutable>
    97 template <
typename NonAlignedPixelReference>
    98 struct is_iterator_adaptor<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
   106 template <
typename NonAlignedPixelReference>
   107 struct color_space_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > : 
public color_space_type<NonAlignedPixelReference> {};
   109 template <
typename NonAlignedPixelReference>
   110 struct channel_mapping_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > : 
public channel_mapping_type<NonAlignedPixelReference> {};
   112 template <
typename NonAlignedPixelReference>
   113 struct is_planar<bit_aligned_pixel_iterator<NonAlignedPixelReference> > : 
public is_planar<NonAlignedPixelReference> {}; 
   119 template <
typename NonAlignedPixelReference>
   120 struct byte_to_memunit<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
   121     : std::integral_constant<int, 8>
   124 template <
typename NonAlignedPixelReference>
   125 inline std::ptrdiff_t memunit_step(
const bit_aligned_pixel_iterator<NonAlignedPixelReference>&) {
   126     return NonAlignedPixelReference::bit_size;
   129 template <
typename NonAlignedPixelReference>
   130 inline std::ptrdiff_t memunit_distance(
const bit_aligned_pixel_iterator<NonAlignedPixelReference>& p1, 
const bit_aligned_pixel_iterator<NonAlignedPixelReference>& p2) {
   131     return (p2.bit_range().current_byte() - p1.bit_range().current_byte())*8 + p2.bit_range().bit_offset() - p1.bit_range().bit_offset();
   134 template <
typename NonAlignedPixelReference>
   135 inline void memunit_advance(bit_aligned_pixel_iterator<NonAlignedPixelReference>& p, std::ptrdiff_t diff) {
   136     p.bit_range().bit_advance(diff);
   139 template <
typename NonAlignedPixelReference>
   140 inline bit_aligned_pixel_iterator<NonAlignedPixelReference> memunit_advanced(
const bit_aligned_pixel_iterator<NonAlignedPixelReference>& p, std::ptrdiff_t diff) {
   141     bit_aligned_pixel_iterator<NonAlignedPixelReference> ret=p;
   142     memunit_advance(ret, diff);
   146 template <
typename NonAlignedPixelReference> 
inline   147 NonAlignedPixelReference memunit_advanced_ref(bit_aligned_pixel_iterator<NonAlignedPixelReference> it, std::ptrdiff_t diff) {
   148     return *memunit_advanced(it,diff);
   154 template <
typename NonAlignedPixelReference>
   155 struct dynamic_x_step_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > {
   156     using type = memory_based_step_iterator<bit_aligned_pixel_iterator<NonAlignedPixelReference> >;
   163 template <
typename B, 
typename C, 
typename L, 
bool M>
   164 struct iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,false,false,false>
   166     using type = bit_aligned_pixel_iterator<bit_aligned_pixel_reference<B,C,L,false>> ;
   169 template <
typename B, 
typename C, 
typename L, 
bool M>
   170 struct iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,false,false,true>
   172     using type = bit_aligned_pixel_iterator<bit_aligned_pixel_reference<B,C,L,true>>;
   175 template <
typename B, 
typename C, 
typename L, 
bool M, 
bool IsPlanar, 
bool IsStep, 
bool IsMutable>
   176 struct iterator_type_from_pixel<bit_aligned_pixel_reference<B,C,L,M>,IsPlanar,IsStep,IsMutable>
   177     : 
public iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,IsPlanar,IsStep,IsMutable> {};
   185 template <
typename NonAlignedPixelReference>
 reference operator[](difference_type d) const
Definition: bit_aligned_pixel_iterator.hpp:66
An iterator over non-byte-aligned pixels. Models PixelIteratorConcept, PixelBasedConcept,...
Definition: bit_aligned_pixel_iterator.hpp:37
BOOST_FORCEINLINE bool equal(boost::gil::iterator_from_2d< Loc1 > first, boost::gil::iterator_from_2d< Loc1 > last, boost::gil::iterator_from_2d< Loc2 > first2)
std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d
Definition: algorithm.hpp:1029
BOOST_FORCEINLINE auto copy(boost::gil::pixel< T, CS > *first, boost::gil::pixel< T, CS > *last, boost::gil::pixel< T, CS > *dst) -> boost::gil::pixel< T, CS > *
Copy when both src and dst are interleaved and of the same type can be just memmove.
Definition: algorithm.hpp:139