40 return super::operator[](i);
51 return super::operator[](i);
61template<
typename Image,
typename Pixel>
63 : m_owner(NULL), m_pos(0, 0)
75template<
typename Image,
typename Pixel>
77( image_type& owner,
unsigned int x,
unsigned int y )
78 : m_owner(&owner), m_pos(x, y)
88template<
typename Image,
typename Pixel>
91(
const self_type& that )
const
93 if ( is_final() && that.is_final() )
95 else if ( m_owner == that.m_owner )
96 return m_pos == that.m_pos;
106template<
typename Image,
typename Pixel>
109(
const self_type& that )
const
111 return !(*
this == that);
119template<
typename Image,
typename Pixel>
122 (
const self_type& that )
const
124 if ( this->m_pos.y == that.m_pos.y)
125 return this->m_pos.x < that.m_pos.x;
127 return this->m_pos.y < that.m_pos.y;
135template<
typename Image,
typename Pixel>
138(
const self_type& that )
const
149template<
typename Image,
typename Pixel>
152(
const self_type& that )
const
154 return !(*
this > that);
163template<
typename Image,
typename Pixel>
166(
const self_type& that )
const
168 return !(*
this < that);
176template<
typename Image,
typename Pixel>
177inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type&
186 unsigned int n_y = n / m_owner->width();
187 unsigned int n_x = n % m_owner->width();
201template<
typename Image,
typename Pixel>
202inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type&
211 unsigned int n_y = n / m_owner->width();
212 unsigned int n_x = n % m_owner->width();
229template<
typename Image,
typename Pixel>
230inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type
233 self_type that(*
this);
243template<
typename Image,
typename Pixel>
244inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type
247 self_type that(*
this);
258template<
typename ImageT,
typename PixelT>
259inline typename claw::graphic::image::base_iterator<ImageT, PixelT>::self_type
263 claw::graphic::image::base_iterator<ImageT, PixelT>::self_type& self )
273template<
typename Image,
typename Pixel>
277(
const self_type& that )
const
279 CLAW_PRECOND( is_final() || that.is_final() || (m_owner == that.m_owner) );
281 if ( that.is_final() )
286 return -(m_owner->height() - m_pos.y) * m_owner->width() - m_pos.x;
288 else if ( is_final() )
289 return (that.m_owner->height() - that.m_pos.y) * that.m_owner->width()
292 return m_pos.y * m_owner->width() + m_pos.x
293 - that.m_pos.y * that.m_owner->width() + that.m_pos.x;
300template<
typename Image,
typename Pixel>
301inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type&
308 if ( m_pos.x == m_owner->width() )
321template<
typename Image,
typename Pixel>
322inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type
325 self_type that(*
this);
334template<
typename Image,
typename Pixel>
335inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type&
343 m_pos.x = m_owner->width() - 1;
356template<
typename Image,
typename Pixel>
357inline typename claw::graphic::image::base_iterator<Image, Pixel>::self_type
360 self_type that(*
this);
369template<
typename Image,
typename Pixel>
375 return (*m_owner)[m_pos.y][m_pos.x];
382template<
typename Image,
typename Pixel>
388 return &(*m_owner)[m_pos.y][m_pos.x];
396template<
typename Image,
typename Pixel>
407template<
typename Image,
typename Pixel>
409claw::graphic::image::base_iterator<Image, Pixel>::is_final()
const
413 else if ( m_pos.y >= m_owner->height() )
415 else if ( m_pos.y == m_owner->height() - 1 )
416 return m_pos.x >= m_owner->width();
Some assert macros to strengthen you code.
#define CLAW_PRECOND(b)
Abort the program if a precondition is not true.
#define CLAW_POSTCOND(b)
Abort the program if a postcondition is not true.
Base class for iterators on an image.
self_type & operator+=(int n)
Move the iterator.
self_type operator+(int n) const
Get an iterator at a specific distance of the current iterator.
pixel_type * pointer
The type of the pointers to the values accesssed by the iterator.
self_type & operator-=(int n)
Move the iterator.
self_type & operator++()
Preincrement.
pointer operator->() const
Get a pointer on the pointed pixel.
self_type operator-(int n) const
Get an iterator at a specific distance of the current iterator.
pixel_type & reference
The type of the references to the values accesssed by the iterator.
reference operator*() const
Get a reference on the pointed pixel.
ptrdiff_t difference_type
The type of the distance between two iterators.
reference operator[](int n) const
Get a pixel, using the iterator like an array.
self_type & operator--()
Predecrement.
base_iterator()
Constructor.
super::reference reference
Reference to a pixel..
reference operator[](unsigned int i)
Get a pixel from the line.
super::const_reference const_reference
Const reference to a pixel.
scanline & operator[](unsigned int i)
Gets a line of the image.