void Insert( const tPlane8& in, tPlane8& out, int32_xy pos, uint32_xy size ) { auto yinbegin = in.begin(); auto yinend = in.begin() + size.y(); auto youtbegin = out.begin() + pos.y(); while( yinbegin != yinend ) { copy( yinbegin->begin(), yinbegin->begin() + size.x(), youtbegin->begin() + pos.x() ); ++yinbegin; ++youtbegin; } }
bool rimginterface::Insert( const tImgViewPlanar& aoi, tImgPlanar& target, int32_xy xy ) { assert( target.equals_size_mask( aoi ) ); // test if target position is in img if( xy.x() > static_cast<int>(target.sx()) - 1 || xy.y() > static_cast<int>(target.sy()) - 1 ) { return false; } uint32_xy xxyy( xy.x(), xy.y() ); uint32_xy aoi_ = aoi.size(); uint32_xy result = aoi_ + xxyy; int32_xy aoimax = int32_xy( result.x(), result.y() ); if( aoimax.x() <= 0 && aoimax.y() <= 0 ) { return false; } if( aoimax.x() > static_cast<int>(target.sx()) && aoimax.y() > static_cast<int>(target.sy()) ) { return false; } uint32_xy saoi = aoi.size(); uint32_xy so = target.size(); auto maoibegin = aoi.begin(); auto maoiend = aoi.end(); auto out = target.begin(); uint32_xy size( aoi.size() ); while( maoibegin != maoiend ) { insert::Insert( maoibegin->plane, out->plane, xy, size ); ++maoibegin; ++out; } return true; }
bool tAoi::inside( int32_xy const& p )const { bool ret = false; int x = p.x(); int y = p.y(); if( x >= px() && x < static_cast<int>( ( px() + sx() ) ) && y >= py() && y < static_cast<int>( ( py() + sy() ) ) ) { ret = true; } return ret; }
inline uint32_xy to( int32_xy xy ) { return uint32_xy( xy.x(), xy.y() ); }
tAoi::tAoi( int32_xy const& pos0, uint32_xy const& size0 ):_pos( pos0.x(), pos0.y() ), _size( size0.x(), size0.y() ) {}