00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef GIL_PIXEL_ITERATOR_H
00014 #define GIL_PIXEL_ITERATOR_H
00015
00024
00025 #include <cassert>
00026 #include <iterator>
00027 #include "gil_config.hpp"
00028 #include "gil_concept.hpp"
00029 #include "pixel.hpp"
00030
00031 namespace boost { namespace gil {
00032
00033
00034 template <typename Iterator>
00035 class memory_based_step_iterator;
00036
00037 template <typename Iterator> struct dynamic_x_step_type;
00038
00041 template <typename It>
00042 struct is_iterator_adaptor : public mpl::false_{};
00043
00045 template <typename It>
00046 struct iterator_adaptor_get_base;
00047
00049 template <typename It, typename NewBaseIt>
00050 struct iterator_adaptor_rebind;
00051
00053 template <typename It>
00054 struct const_iterator_type;
00055
00056
00057 template <typename T> struct const_iterator_type< T*> { typedef const T* type; };
00058 template <typename T> struct const_iterator_type<const T*> { typedef const T* type; };
00059
00062 template <typename It>
00063 struct iterator_is_mutable{};
00064
00065
00066 template <typename T> struct iterator_is_mutable< T*> : public mpl::true_{};
00067 template <typename T> struct iterator_is_mutable<const T*> : public mpl::false_{};
00068
00073
00074
00075
00077
00079
00081 template <typename Pixel>
00082 struct dynamic_x_step_type<Pixel*> {
00083 typedef memory_based_step_iterator<Pixel*> type;
00084 };
00085
00087 template <typename Pixel>
00088 struct dynamic_x_step_type<const Pixel*> {
00089 typedef memory_based_step_iterator<const Pixel*> type;
00090 };
00091
00092
00094
00096
00097 template <typename Pixel> struct color_space_type< Pixel*> : public color_space_type<Pixel> {};
00098 template <typename Pixel> struct color_space_type<const Pixel*> : public color_space_type<Pixel> {};
00099
00100 template <typename Pixel> struct channel_mapping_type< Pixel*> : public channel_mapping_type<Pixel> {};
00101 template <typename Pixel> struct channel_mapping_type<const Pixel*> : public channel_mapping_type<Pixel> {};
00102
00103 template <typename Pixel> struct is_planar< Pixel*> : public is_planar<Pixel> {};
00104 template <typename Pixel> struct is_planar<const Pixel*> : public is_planar<Pixel> {};
00105
00107
00109
00110 template <typename Pixel> struct channel_type<Pixel*> : public channel_type<Pixel> {};
00111 template <typename Pixel> struct channel_type<const Pixel*> : public channel_type<Pixel> {};
00112
00119
00121
00123
00124 template <typename T>
00125 struct byte_to_memunit : public mpl::int_<1> {};
00126
00127 template <typename P>
00128 inline std::ptrdiff_t memunit_step(const P*) { return sizeof(P); }
00129
00130 template <typename P>
00131 inline std::ptrdiff_t memunit_distance(const P* p1, const P* p2) {
00132 return (gil_reinterpret_cast_c<const unsigned char*>(p2)-gil_reinterpret_cast_c<const unsigned char*>(p1));
00133 }
00134
00135 template <typename P> P* memunit_advanced(const P* p, std::ptrdiff_t diff);
00136
00137 template <typename P>
00138 inline void memunit_advance(P* &p, std::ptrdiff_t diff) {
00139 p=(P*)((unsigned char*)(p)+diff);
00140 }
00141
00142 template <typename P>
00143 inline P* memunit_advanced(const P* p, std::ptrdiff_t diff) {
00144 return (P*)((unsigned char*)(p)+diff);
00145 }
00146
00147
00148
00149
00150
00151 template <typename P>
00152 inline P& memunit_advanced_ref(P* p, std::ptrdiff_t diff) {
00153 return *memunit_advanced(p,diff);
00154 }
00155
00156 } }
00157
00158 #endif