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/stl_interfaces/iterator_interface.hpp>
20namespace boost {
namespace gil {
36template <
typename NonAlignedPixelReference>
38#if !BOOST_STL_INTERFACES_USE_DEDUCED_THIS
39 bit_aligned_pixel_iterator<NonAlignedPixelReference>,
41 std::random_access_iterator_tag,
42 typename NonAlignedPixelReference::value_type,
43 const NonAlignedPixelReference,
44 typename NonAlignedPixelReference::value_type*,
45 typename NonAlignedPixelReference::bit_range_t::difference_type>
48 using parent_t = stl_interfaces::iterator_interface<
49#if !BOOST_STL_INTERFACES_USE_DEDUCED_THIS
52 std::random_access_iterator_tag,
53 typename NonAlignedPixelReference::value_type,
54 const NonAlignedPixelReference,
55 typename NonAlignedPixelReference::value_type*,
56 typename NonAlignedPixelReference::bit_range_t::difference_type>;
60 using bit_range_t =
typename NonAlignedPixelReference::bit_range_t;
63 using difference_type =
typename parent_t::difference_type;
64 using reference =
typename parent_t::reference;
65 using iterator_category =
typename parent_t::iterator_concept;
76 constexpr auto operator*()
const noexcept -> reference {
return dereference(); }
82 auto bit_range()
const -> bit_range_t
const& {
return _bit_range; }
83 auto bit_range() -> bit_range_t& {
return _bit_range; }
86 bit_range_t _bit_range;
87 static constexpr int bit_size = NonAlignedPixelReference::bit_size;
89 auto dereference()
const -> reference {
return NonAlignedPixelReference(_bit_range); }
90 void advance(difference_type d) { _bit_range.bit_advance(d*bit_size); }
92 auto distance_to(
bit_aligned_pixel_iterator const& it)
const -> difference_type {
return _bit_range.bit_distance_to(it._bit_range) / bit_size; }
96template <
typename NonAlignedPixelReference>
103template <
typename NonAlignedPixelReference>
104struct iterator_is_mutable<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
105 : std::integral_constant<bool, NonAlignedPixelReference::is_mutable>
108template <
typename NonAlignedPixelReference>
109struct is_iterator_adaptor<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
117template <
typename NonAlignedPixelReference>
118struct color_space_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > :
public color_space_type<NonAlignedPixelReference> {};
120template <
typename NonAlignedPixelReference>
121struct channel_mapping_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > :
public channel_mapping_type<NonAlignedPixelReference> {};
123template <
typename NonAlignedPixelReference>
124struct is_planar<bit_aligned_pixel_iterator<NonAlignedPixelReference> > :
public is_planar<NonAlignedPixelReference> {};
130template <
typename NonAlignedPixelReference>
131struct byte_to_memunit<bit_aligned_pixel_iterator<NonAlignedPixelReference>>
132 : std::integral_constant<int, 8>
135template <
typename NonAlignedPixelReference>
136inline auto memunit_step(
const bit_aligned_pixel_iterator<NonAlignedPixelReference>&) -> std::ptrdiff_t
138 return NonAlignedPixelReference::bit_size;
141template <
typename NonAlignedPixelReference>
142inline auto memunit_distance(bit_aligned_pixel_iterator<NonAlignedPixelReference>
const& p1, bit_aligned_pixel_iterator<NonAlignedPixelReference>
const& p2) -> std::ptrdiff_t
144 return (p2.bit_range().current_byte() - p1.bit_range().current_byte())*8 + p2.bit_range().bit_offset() - p1.bit_range().bit_offset();
147template <
typename NonAlignedPixelReference>
148inline void memunit_advance(bit_aligned_pixel_iterator<NonAlignedPixelReference>& p, std::ptrdiff_t diff) {
149 p.bit_range().bit_advance(diff);
152template <
typename NonAlignedPixelReference>
153inline auto memunit_advanced(bit_aligned_pixel_iterator<NonAlignedPixelReference>
const& p, std::ptrdiff_t diff) -> bit_aligned_pixel_iterator<NonAlignedPixelReference> {
154 bit_aligned_pixel_iterator<NonAlignedPixelReference> ret=p;
155 memunit_advance(ret, diff);
159template <
typename NonAlignedPixelReference>
inline
160auto memunit_advanced_ref(bit_aligned_pixel_iterator<NonAlignedPixelReference> it, std::ptrdiff_t diff) -> NonAlignedPixelReference
162 return *memunit_advanced(it,diff);
168template <
typename NonAlignedPixelReference>
169struct dynamic_x_step_type<bit_aligned_pixel_iterator<NonAlignedPixelReference> > {
170 using type = memory_based_step_iterator<bit_aligned_pixel_iterator<NonAlignedPixelReference> >;
177template <
typename B,
typename C,
typename L,
bool M>
178struct iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,false,false,false>
180 using type = bit_aligned_pixel_iterator<bit_aligned_pixel_reference<B,C,L,false>> ;
183template <
typename B,
typename C,
typename L,
bool M>
184struct iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,false,false,true>
186 using type = bit_aligned_pixel_iterator<bit_aligned_pixel_reference<B,C,L,true>>;
189template <
typename B,
typename C,
typename L,
bool M,
bool IsPlanar,
bool IsStep,
bool IsMutable>
190struct iterator_type_from_pixel<bit_aligned_pixel_reference<B,C,L,M>,IsPlanar,IsStep,IsMutable>
191 :
public iterator_type_from_pixel<const bit_aligned_pixel_reference<B,C,L,M>,IsPlanar,IsStep,IsMutable> {};
199template <
typename NonAlignedPixelReference>
205 return std::copy(first,last,dst);
An iterator over non-byte-aligned pixels. Models PixelIteratorConcept, PixelBasedConcept,...
Definition bit_aligned_pixel_iterator.hpp:46
Definition bit_aligned_pixel_reference.hpp:34
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition algorithm.hpp:36
Returns the type of an iterator just like the input iterator, except operating over immutable values.
Definition pixel_iterator.hpp:40