From 8ff0d754accf574f4990d94041f8235e6712e1a5 Mon Sep 17 00:00:00 2001 From: Victor Erukhimov Date: Thu, 21 Oct 2010 03:47:57 +0000 Subject: [PATCH] Adding back MatConstIterator_::pos implementation --- modules/core/include/opencv2/core/mat.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 617f148..46bb41f 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -1804,6 +1804,25 @@ template inline MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(i return b; } +// Fixing a back compatibility problem -- to be reviewed by Vadim +template inline Point MatConstIterator_<_Tp>::pos() const +{ + if( !m ) + return Point(); + if( m->isContinuous() ) + { + ptrdiff_t ofs = ptr - (_Tp*)m->data; + int y = (int)(ofs / m->cols), x = (int)(ofs - (ptrdiff_t)y*m->cols); + return Point(x, y); + } + else + { + ptrdiff_t ofs = (uchar*)ptr - m->data; + int y = (int)(ofs / m->step), x = (int)((ofs - y*m->step)/sizeof(_Tp)); + return Point(x, y); + } +} + static inline bool operator == (const MatConstIterator& a, const MatConstIterator& b) { return a.m == b.m && a.ptr == b.ptr; } -- 2.7.4