annotate DEPENDENCIES/generic/include/boost/gil/pixel_iterator.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright 2005-2007 Adobe Systems Incorporated
Chris@16 3
Chris@16 4 Use, modification and distribution are subject to the Boost Software License,
Chris@16 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt).
Chris@16 7
Chris@16 8 See http://opensource.adobe.com/gil for most recent version including documentation.
Chris@16 9 */
Chris@16 10
Chris@16 11 /*************************************************************************************************/
Chris@16 12
Chris@16 13 #ifndef GIL_PIXEL_ITERATOR_H
Chris@16 14 #define GIL_PIXEL_ITERATOR_H
Chris@16 15
Chris@16 16 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 17 /// \file
Chris@16 18 /// \brief pixel iterator support
Chris@16 19 /// \author Lubomir Bourdev and Hailin Jin \n
Chris@16 20 /// Adobe Systems Incorporated
Chris@16 21 /// \date 2005-2007 \n May 16, 2006
Chris@16 22 ///
Chris@16 23 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 24
Chris@16 25 #include <cassert>
Chris@16 26 #include <iterator>
Chris@16 27 #include "gil_config.hpp"
Chris@16 28 #include "gil_concept.hpp"
Chris@16 29 #include "utilities.hpp"
Chris@16 30 #include "pixel.hpp"
Chris@16 31
Chris@16 32 namespace boost { namespace gil {
Chris@16 33
Chris@16 34 //forwarded declaration (as this file is included in step_iterator.hpp)
Chris@16 35 template <typename Iterator>
Chris@16 36 class memory_based_step_iterator;
Chris@16 37
Chris@16 38 template <typename Iterator> struct dynamic_x_step_type;
Chris@16 39
Chris@16 40 /// \brief metafunction predicate determining whether the given iterator is a plain one or an adaptor over another iterator.
Chris@16 41 /// Examples of adaptors are the step iterator and the dereference iterator adaptor.
Chris@16 42 template <typename It>
Chris@16 43 struct is_iterator_adaptor : public mpl::false_{};
Chris@16 44
Chris@16 45 /// \brief returns the base iterator for a given iterator adaptor. Provide an specialization when introducing new iterator adaptors
Chris@16 46 template <typename It>
Chris@16 47 struct iterator_adaptor_get_base;
Chris@16 48
Chris@16 49 /// \brief Changes the base iterator of an iterator adaptor. Provide an specialization when introducing new iterator adaptors
Chris@16 50 template <typename It, typename NewBaseIt>
Chris@16 51 struct iterator_adaptor_rebind;
Chris@16 52
Chris@16 53 /// \brief Returns the type of an iterator just like the input iterator, except operating over immutable values
Chris@16 54 template <typename It>
Chris@16 55 struct const_iterator_type;
Chris@16 56
Chris@16 57 // The default implementation when the iterator is a C pointer is to use the standard constness semantics
Chris@16 58 template <typename T> struct const_iterator_type< T*> { typedef const T* type; };
Chris@16 59 template <typename T> struct const_iterator_type<const T*> { typedef const T* type; };
Chris@16 60
Chris@16 61 /// \brief Metafunction predicate returning whether the given iterator allows for changing its values
Chris@16 62 /// \ingroup GILIsMutable
Chris@16 63 template <typename It>
Chris@16 64 struct iterator_is_mutable{};
Chris@16 65
Chris@16 66 // The default implementation when the iterator is a C pointer is to use the standard constness semantics
Chris@16 67 template <typename T> struct iterator_is_mutable< T*> : public mpl::true_{};
Chris@16 68 template <typename T> struct iterator_is_mutable<const T*> : public mpl::false_{};
Chris@16 69
Chris@16 70 /// \defgroup PixelIteratorModelInterleavedPtr C pointer to a pixel
Chris@16 71 /// \ingroup PixelIteratorModel
Chris@16 72 /// \brief Iterators over interleaved pixels.
Chris@16 73 /// A C pointer to a model of PixelValueConcept is used as an iterator over interleaved pixels. Models PixelIteratorConcept, HomogeneousPixelBasedConcept, HasDynamicXStepTypeConcept, MemoryBasedIteratorConcept
Chris@16 74
Chris@16 75
Chris@16 76
Chris@16 77 /////////////////////////////
Chris@16 78 // HasDynamicXStepTypeConcept
Chris@16 79 /////////////////////////////
Chris@16 80
Chris@16 81 /// \ingroup PixelIteratorModelInterleavedPtr
Chris@16 82 template <typename Pixel>
Chris@16 83 struct dynamic_x_step_type<Pixel*> {
Chris@16 84 typedef memory_based_step_iterator<Pixel*> type;
Chris@16 85 };
Chris@16 86
Chris@16 87 /// \ingroup PixelIteratorModelInterleavedPtr
Chris@16 88 template <typename Pixel>
Chris@16 89 struct dynamic_x_step_type<const Pixel*> {
Chris@16 90 typedef memory_based_step_iterator<const Pixel*> type;
Chris@16 91 };
Chris@16 92
Chris@16 93
Chris@16 94 /////////////////////////////
Chris@16 95 // PixelBasedConcept
Chris@16 96 /////////////////////////////
Chris@16 97
Chris@16 98 template <typename Pixel> struct color_space_type< Pixel*> : public color_space_type<Pixel> {};
Chris@16 99 template <typename Pixel> struct color_space_type<const Pixel*> : public color_space_type<Pixel> {};
Chris@16 100
Chris@16 101 template <typename Pixel> struct channel_mapping_type< Pixel*> : public channel_mapping_type<Pixel> {};
Chris@16 102 template <typename Pixel> struct channel_mapping_type<const Pixel*> : public channel_mapping_type<Pixel> {};
Chris@16 103
Chris@16 104 template <typename Pixel> struct is_planar< Pixel*> : public is_planar<Pixel> {};
Chris@16 105 template <typename Pixel> struct is_planar<const Pixel*> : public is_planar<Pixel> {};
Chris@16 106
Chris@16 107 /////////////////////////////
Chris@16 108 // HomogeneousPixelBasedConcept
Chris@16 109 /////////////////////////////
Chris@16 110
Chris@16 111 template <typename Pixel> struct channel_type<Pixel*> : public channel_type<Pixel> {};
Chris@16 112 template <typename Pixel> struct channel_type<const Pixel*> : public channel_type<Pixel> {};
Chris@16 113
Chris@16 114 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 115 ///
Chris@16 116 /// Support for pixel iterator movement measured in memory units (bytes or bits) as opposed to pixel type. \n
Chris@16 117 /// Necessary to handle image row alignment and channel plane alignment.
Chris@16 118 ///
Chris@16 119 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 120
Chris@16 121 /////////////////////////////
Chris@16 122 // MemoryBasedIteratorConcept
Chris@16 123 /////////////////////////////
Chris@16 124
Chris@16 125 template <typename T>
Chris@16 126 struct byte_to_memunit : public mpl::int_<1> {};
Chris@16 127
Chris@16 128 template <typename P>
Chris@16 129 inline std::ptrdiff_t memunit_step(const P*) { return sizeof(P); }
Chris@16 130
Chris@16 131 template <typename P>
Chris@16 132 inline std::ptrdiff_t memunit_distance(const P* p1, const P* p2) {
Chris@16 133 return (gil_reinterpret_cast_c<const unsigned char*>(p2)-gil_reinterpret_cast_c<const unsigned char*>(p1));
Chris@16 134 }
Chris@16 135
Chris@16 136 template <typename P>
Chris@16 137 inline void memunit_advance(P* &p, std::ptrdiff_t diff) {
Chris@16 138 p=(P*)((unsigned char*)(p)+diff);
Chris@16 139 }
Chris@16 140
Chris@16 141 template <typename P>
Chris@16 142 inline P* memunit_advanced(const P* p, std::ptrdiff_t diff) {
Chris@16 143 return (P*)((char*)(p)+diff);
Chris@16 144 }
Chris@16 145
Chris@16 146 // memunit_advanced_ref
Chris@16 147 // (shortcut to advancing a pointer by a given number of memunits and taking the reference in case the compiler is not smart enough)
Chris@16 148
Chris@16 149 template <typename P>
Chris@16 150 inline P& memunit_advanced_ref(P* p, std::ptrdiff_t diff) {
Chris@16 151 return *memunit_advanced(p,diff);
Chris@16 152 }
Chris@16 153
Chris@16 154 } } // namespace boost::gil
Chris@16 155
Chris@16 156 #endif