eLynx SDK
v3.0.1 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: 00046 typedef Pixel Pixel_t; 00047 00049 friend class boost::iterator_core_access; 00050 00053 00055 explicit PixelIterator(); 00056 00059 template <class PixelU> 00060 PixelIterator(const PixelIterator<PixelU>& iOther); 00061 00065 explicit PixelIterator(Pixel_t * iprPixel, uint32 iWidth); 00066 00068 00071 00073 void increment(); 00074 00076 void decrement(); 00077 00081 bool equal(const PixelIterator& iOther) const; 00082 00084 Pixel_t& dereference() const; 00085 00088 void advance(int32 iDist); 00089 00094 void advance(int32 iWidth, int32 iHeight); 00095 00099 void moveto(int32 iWidth, int32 iHeight); 00100 00103 uint32 distance_to(const PixelIterator& iOther) const; 00105 00108 Pixel& operator[](int32 iIndex); 00109 00112 uint32 getWidth() const; 00113 00116 uint32 getHorizontal() const; 00117 00120 uint32 getVertical() const; 00121 00124 const Pixel_t * getData() const; 00125 00128 const Pixel_t * getFirst() const; 00129 00133 const void * getMap() const; 00134 00138 void * getMap(); 00139 00140 private: 00141 Pixel_t * _prPixel; 00142 Pixel_t * _prBegin; 00143 uint32 _width; 00144 }; 00145 00151 template <class Pixel> 00152 PixelIterator<Pixel> elxDowncast( 00153 boost::shared_ptr<IPixelIterator> ispPixelIter); 00154 00160 template <class Pixel> 00161 PixelIterator<const Pixel> elxConstDowncast( 00162 boost::shared_ptr<IPixelIterator> ispPixelIter); 00163 00164 } // namespace Image 00165 } // namespace eLynx 00166 00167 #include "inl/Pixel/PixelIterator.inl" 00168 00169 #endif // __PixelIterator_h__