pixel_iterator.hppGo to the documentation of this file.00001 /* 00002 Copyright 2005-2007 Adobe Systems Incorporated 00003 00004 Use, modification and distribution are subject to the Boost Software License, 00005 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 00006 http://www.boost.org/LICENSE_1_0.txt). 00007 00008 See http://opensource.adobe.com/gil for most recent version including documentation. 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 "utilities.hpp" 00030 #include "pixel.hpp" 00031 00032 namespace boost { namespace gil { 00033 00034 //forwarded declaration (as this file is included in step_iterator.hpp) 00035 template <typename Iterator> 00036 class memory_based_step_iterator; 00037 00038 template <typename Iterator> struct dynamic_x_step_type; 00039 00042 template <typename It> 00043 struct is_iterator_adaptor : public mpl::false_{}; 00044 00046 template <typename It> 00047 struct iterator_adaptor_get_base; 00048 00050 template <typename It, typename NewBaseIt> 00051 struct iterator_adaptor_rebind; 00052 00054 template <typename It> 00055 struct const_iterator_type; 00056 00057 // The default implementation when the iterator is a C pointer is to use the standard constness semantics 00058 template <typename T> struct const_iterator_type< T*> { typedef const T* type; }; 00059 template <typename T> struct const_iterator_type<const T*> { typedef const T* type; }; 00060 00063 template <typename It> 00064 struct iterator_is_mutable{}; 00065 00066 // The default implementation when the iterator is a C pointer is to use the standard constness semantics 00067 template <typename T> struct iterator_is_mutable< T*> : public mpl::true_{}; 00068 template <typename T> struct iterator_is_mutable<const T*> : public mpl::false_{}; 00069 00074 00075 00076 00078 // HasDynamicXStepTypeConcept 00080 00082 template <typename Pixel> 00083 struct dynamic_x_step_type<Pixel*> { 00084 typedef memory_based_step_iterator<Pixel*> type; 00085 }; 00086 00088 template <typename Pixel> 00089 struct dynamic_x_step_type<const Pixel*> { 00090 typedef memory_based_step_iterator<const Pixel*> type; 00091 }; 00092 00093 00095 // PixelBasedConcept 00097 00098 template <typename Pixel> struct color_space_type< Pixel*> : public color_space_type<Pixel> {}; 00099 template <typename Pixel> struct color_space_type<const Pixel*> : public color_space_type<Pixel> {}; 00100 00101 template <typename Pixel> struct channel_mapping_type< Pixel*> : public channel_mapping_type<Pixel> {}; 00102 template <typename Pixel> struct channel_mapping_type<const Pixel*> : public channel_mapping_type<Pixel> {}; 00103 00104 template <typename Pixel> struct is_planar< Pixel*> : public is_planar<Pixel> {}; 00105 template <typename Pixel> struct is_planar<const Pixel*> : public is_planar<Pixel> {}; 00106 00108 // HomogeneousPixelBasedConcept 00110 00111 template <typename Pixel> struct channel_type<Pixel*> : public channel_type<Pixel> {}; 00112 template <typename Pixel> struct channel_type<const Pixel*> : public channel_type<Pixel> {}; 00113 00120 00122 // MemoryBasedIteratorConcept 00124 00125 template <typename T> 00126 struct byte_to_memunit : public mpl::int_<1> {}; 00127 00128 template <typename P> 00129 inline std::ptrdiff_t memunit_step(const P*) { return sizeof(P); } 00130 00131 template <typename P> 00132 inline std::ptrdiff_t memunit_distance(const P* p1, const P* p2) { 00133 return (gil_reinterpret_cast_c<const unsigned char*>(p2)-gil_reinterpret_cast_c<const unsigned char*>(p1)); 00134 } 00135 00136 template <typename P> 00137 inline void memunit_advance(P* &p, std::ptrdiff_t diff) { 00138 p=(P*)((unsigned char*)(p)+diff); 00139 } 00140 00141 template <typename P> 00142 inline P* memunit_advanced(const P* p, std::ptrdiff_t diff) { 00143 return (P*)((char*)(p)+diff); 00144 } 00145 00146 // memunit_advanced_ref 00147 // (shortcut to advancing a pointer by a given number of memunits and taking the reference in case the compiler is not smart enough) 00148 00149 template <typename P> 00150 inline P& memunit_advanced_ref(P* p, std::ptrdiff_t diff) { 00151 return *memunit_advanced(p,diff); 00152 } 00153 00154 } } // namespace boost::gil 00155 00156 #endif Generated on Sat May 2 13:50:14 2009 for Generic Image Library by 1.5.6 |