Commit a379d011 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed MatConstIterator<> (ticket #776)

parent 86802ec9
......@@ -1808,7 +1808,7 @@ template<typename _Tp> inline Point MatConstIterator_<_Tp>::pos() const
CV_DbgAssert( m->dims <= 2 );
if( m->isContinuous() )
{
ptrdiff_t ofs = ptr - (_Tp*)m->data;
ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data;
int y = (int)(ofs / m->cols), x = (int)(ofs - (ptrdiff_t)y*m->cols);
return Point(x, y);
}
......
......@@ -2203,7 +2203,7 @@ void MatConstIterator::seek(ptrdiff_t ofs, bool relative)
y = ofs/m->cols;
int y1 = std::min(std::max((int)y, 0), m->rows-1);
sliceStart = m->data + y1*m->step[0];
sliceEnd = sliceStart + (m->cols-1)*elemSize;
sliceEnd = sliceStart + m->cols*elemSize;
ptr = y < 0 ? sliceStart : y >= m->rows ? sliceEnd :
sliceStart + (ofs - y*m->cols)*elemSize;
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment