eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // PixelIterator.h Image.Component package 00003 //============================================================================ 00004 // Usage : define image iterator class. 00005 //---------------------------------------------------------------------------- 00006 // Inheritance : 00007 // PixelIterator<Pixel> 00008 // +IPixelIterator 00009 //---------------------------------------------------------------------------- 00010 // Copyright (C) 2006 by eLynx project 00011 // 00012 // This library is free software; you can redistribute it and/or 00013 // modify it under the terms of the GNU Library General Public 00014 // License as published by the Free Software Foundation; either 00015 // version 2 of the License, or (at your option) any later version. 00016 // 00017 // This library is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00020 // See the GNU Library General Public License for more details. 00021 //---------------------------------------------------------------------------- 00022 #ifndef __PixelIterator_h__ 00023 #define __PixelIterator_h__ 00024 00025 #include "elx/core/CoreTypes.h" 00026 #include "IPixelIterator.h" 00027 #include <boost/iterator/iterator_facade.hpp> 00028 #include <boost/shared_ptr.hpp> 00029 00030 namespace eLynx { 00031 namespace Image { 00032 00039 00040 template <class Pixel> 00041 class PixelIterator : 00042 public IPixelIterator, 00043 public boost::iterator_facade< PixelIterator<Pixel>, Pixel, boost::random_access_traversal_tag > 00044 { 00045 public: 00047 friend class boost::iterator_core_access; 00048 00051 00053 explicit PixelIterator(); 00054 00057 template <class PixelU> 00058 PixelIterator(const PixelIterator<PixelU>& iOther); 00059 00063 explicit PixelIterator(Pixel * iprPixel, uint32 iWidth); 00064 00066 00069 00071 void increment(); 00072 00074 void decrement(); 00075 00079 bool equal(const PixelIterator& iOther) const; 00080 00082 Pixel& dereference() const; 00083 00086 void advance(int32 iDist); 00087 00092 void advance(int32 iWidth, int32 iHeight); 00093 00097 void moveto(int32 iWidth, int32 iHeight); 00098 00101 uint32 distance_to(const PixelIterator& iOther) const; 00103 00106 Pixel& operator[](int32 iIndex); 00107 00110 uint32 getWidth() const; 00111 00114 uint32 getHorizontal() const; 00115 00118 uint32 getVertical() const; 00119 00122 const Pixel * getData() const; 00123 00126 const Pixel * getFirst() const; 00127 00131 const void * getMap() const; 00132 00136 void * getMap(); 00137 00138 private: 00139 Pixel * _prPixel; 00140 Pixel * _prBegin; 00141 uint32 _width; 00142 }; 00143 00149 template <class Pixel> 00150 PixelIterator<Pixel> elxDowncast( 00151 boost::shared_ptr<IPixelIterator> ispPixelIter); 00152 00158 template <class Pixel> 00159 PixelIterator<const Pixel> elxConstDowncast( 00160 boost::shared_ptr<IPixelIterator> ispPixelIter); 00161 00162 } // namespace Image 00163 } // namespace eLynx 00164 00165 #include "inl/Pixel/PixelIterator.inl" 00166 00167 #endif // __PixelIterator_h__