| 264 | |
| 265 | |
| 266 | Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) : size(&rows) |
| 267 | { |
| 268 | initEmpty(); |
| 269 | CV_Assert( m.dims >= 2 ); |
| 270 | if( m.dims > 2 ) |
| 271 | { |
| 272 | AutoBuffer<Range> rs(m.dims); |
| 273 | rs[0] = _rowRange; |
| 274 | rs[1] = _colRange; |
| 275 | for( int i = 2; i < m.dims; i++ ) |
| 276 | rs[i] = Range::all(); |
| 277 | *this = m(rs); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | *this = m; |
| 282 | try |
| 283 | { |
| 284 | if( _rowRange != Range::all() && _rowRange != Range(0,rows) ) |
| 285 | { |
| 286 | CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end |
| 287 | && _rowRange.end <= m.rows ); |
| 288 | rows = _rowRange.size(); |
| 289 | data += step*_rowRange.start; |
| 290 | flags |= SUBMATRIX_FLAG; |
| 291 | } |
| 292 | |
| 293 | if( _colRange != Range::all() && _colRange != Range(0,cols) ) |
| 294 | { |
| 295 | CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end |
| 296 | && _colRange.end <= m.cols ); |
| 297 | cols = _colRange.size(); |
| 298 | data += _colRange.start*elemSize(); |
| 299 | flags &= cols < m.cols ? ~CONTINUOUS_FLAG : -1; |
| 300 | flags |= SUBMATRIX_FLAG; |
| 301 | } |
| 302 | } |
| 303 | catch(...) |
| 304 | { |
| 305 | release(); |
| 306 | throw; |
| 307 | } |
| 308 | |
| 309 | if( rows == 1 ) |
| 310 | flags |= CONTINUOUS_FLAG; |
| 311 | |
| 312 | if( rows <= 0 || cols <= 0 ) |
| 313 | { |
| 314 | release(); |
| 315 | rows = cols = 0; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | |
| 320 | Mat::Mat(const Mat& m, const Rect& roi) |
nothing calls this directly
no test coverage detected