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 "pixel.hpp" 00030 00031 namespace boost { namespace gil { 00032 00033 //forwarded declaration (as this file is included in step_iterator.hpp) 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 // The default implementation when the iterator is a C pointer is to use the standard constness semantics 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 // The default implementation when the iterator is a C pointer is to use the standard constness semantics 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 // HasDynamicXStepTypeConcept 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 // PixelBasedConcept 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 // HomogeneousPixelBasedConcept 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 // MemoryBasedIteratorConcept 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 // memunit_advanced_ref 00149 // (shortcut to advancing a pointer by a given number of memunits and taking the reference in case the compiler is not smart enough) 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 } } // namespace boost::gil 00157 00158 #endif Generated on Thu Nov 8 21:53:17 2007 for Generic Image Library by ![]() |