Boost GIL


pixel_iterator.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_PIXEL_ITERATOR_HPP
9 #define BOOST_GIL_PIXEL_ITERATOR_HPP
10 
11 #include <boost/gil/concepts.hpp>
12 #include <boost/gil/dynamic_step.hpp>
13 #include <boost/gil/utilities.hpp>
14 #include <boost/gil/pixel.hpp>
15 
16 #include <iterator>
17 
18 namespace boost { namespace gil {
19 
20 //forwarded declaration (as this file is included in step_iterator.hpp)
21 template <typename Iterator>
22 class memory_based_step_iterator;
23 
26 template <typename It>
27 struct is_iterator_adaptor : public mpl::false_{};
28 
30 template <typename It>
31 struct iterator_adaptor_get_base;
32 
34 template <typename It, typename NewBaseIt>
36 
38 template <typename It>
40 
41 // The default implementation when the iterator is a C pointer is to use the standard constness semantics
42 template <typename T> struct const_iterator_type<T*> { using type = T const*; };
43 template <typename T> struct const_iterator_type<T const*> { using type = T const*; };
44 
47 template <typename It>
49 
50 // The default implementation when the iterator is a C pointer is to use the standard constness semantics
51 template <typename T> struct iterator_is_mutable< T*> : public mpl::true_{};
52 template <typename T> struct iterator_is_mutable<const T*> : public mpl::false_{};
53 
58 
59 
60 
62 // HasDynamicXStepTypeConcept
64 
66 template <typename Pixel>
67 struct dynamic_x_step_type<Pixel*> {
69 };
70 
72 template <typename Pixel>
73 struct dynamic_x_step_type<const Pixel*> {
75 };
76 
77 
79 // PixelBasedConcept
81 
82 template <typename Pixel> struct color_space_type< Pixel*> : public color_space_type<Pixel> {};
83 template <typename Pixel> struct color_space_type<const Pixel*> : public color_space_type<Pixel> {};
84 
85 template <typename Pixel> struct channel_mapping_type< Pixel*> : public channel_mapping_type<Pixel> {};
86 template <typename Pixel> struct channel_mapping_type<const Pixel*> : public channel_mapping_type<Pixel> {};
87 
88 template <typename Pixel> struct is_planar< Pixel*> : public is_planar<Pixel> {};
89 template <typename Pixel> struct is_planar<const Pixel*> : public is_planar<Pixel> {};
90 
92 // HomogeneousPixelBasedConcept
94 
95 template <typename Pixel> struct channel_type<Pixel*> : public channel_type<Pixel> {};
96 template <typename Pixel> struct channel_type<const Pixel*> : public channel_type<Pixel> {};
97 
104 
106 // MemoryBasedIteratorConcept
108 
109 template <typename T>
110 struct byte_to_memunit : public mpl::int_<1> {};
111 
112 template <typename P>
113 inline std::ptrdiff_t memunit_step(const P*) { return sizeof(P); }
114 
115 template <typename P>
116 inline std::ptrdiff_t memunit_distance(const P* p1, const P* p2) {
117  return (gil_reinterpret_cast_c<const unsigned char*>(p2)-gil_reinterpret_cast_c<const unsigned char*>(p1));
118 }
119 
120 template <typename P>
121 inline void memunit_advance(P* &p, std::ptrdiff_t diff) {
122  p=(P*)((unsigned char*)(p)+diff);
123 }
124 
125 template <typename P>
126 inline P* memunit_advanced(const P* p, std::ptrdiff_t diff) {
127  return (P*)((char*)(p)+diff);
128 }
129 
130 // memunit_advanced_ref
131 // (shortcut to advancing a pointer by a given number of memunits and taking the reference in case the compiler is not smart enough)
132 
133 template <typename P>
134 inline P& memunit_advanced_ref(P* p, std::ptrdiff_t diff) {
135  return *memunit_advanced(p,diff);
136 }
137 
138 } } // namespace boost::gil
139 
140 #endif
Definition: pixel_iterator.hpp:110
Definition: algorithm.hpp:30
Definition: color_convert.hpp:30
Changes the base iterator of an iterator adaptor. Provide an specialization when introducing new iter...
Definition: pixel_iterator.hpp:35
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: pixel_iterator.hpp:48
Returns the type of an iterator just like the input iterator, except operating over immutable values...
Definition: pixel_iterator.hpp:39
Base template for types that model HasDynamicXStepTypeConcept.
Definition: dynamic_step.hpp:17
MEMORY-BASED STEP ITERATOR.
Definition: algorithm.hpp:36