Index: boost/gil/extension/numeric/sampler.hpp =================================================================== --- boost/gil/extension/numeric/sampler.hpp (revision 796) +++ boost/gil/extension/numeric/sampler.hpp (working copy) @@ -45,7 +45,7 @@ template bool sample(nearest_neighbor_sampler, const SrcView& src, const point2& p, DstP& result) { - point2 center(iround(p)); + typename SrcView::point_t center(iround(p)); if (center.x>=0 && center.y>=0 && center.x::value> > >()(loc.x()[1], frac.x * frac.y ,mp); + detail::add_dst_mul_src::value> > >()(loc.x()[1], 1 ,mp); } else if (p0.y+1::value> > >()(loc.x()[1], frac.x *(1-frac.y),mp); + // on the first column, but not the top-left nor bottom-left corner pixel + detail::add_dst_mul_src::value> > >()(loc.x()[1], (1-frac.y),mp); ++loc.y(); - detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x * frac.y ,mp); + detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.y ,mp); } else { - // on the last row, but not the bottom-right corner pixel - detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x ,mp); + // the bottom-left corner pixel + detail::add_dst_mul_src::value> > >()(loc.x()[1], 1 ,mp); } } else if (p0.x+1::value> > >()(*loc, (1-frac.x)* frac.y ,mp); - detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x * frac.y ,mp); + detail::add_dst_mul_src::value> > >()(*loc, (1-frac.x) ,mp); + detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x ,mp); } else if (p0.y+1::value> > >()(*loc, (1-frac.x)*(1-frac.y),mp); detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x *(1-frac.y),mp); ++loc.y(); @@ -153,24 +155,30 @@ } else { - // on the last row, but not the bottom-right corner pixel - detail::add_dst_mul_src::value> > >()(*loc, (1-frac.x),mp); - detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x ,mp); + // on the last row, but not the bottom-left nor bottom-right corner pixel + detail::add_dst_mul_src::value> > >()(*loc, (1-frac.x) ,mp); + detail::add_dst_mul_src::value> > >()(loc.x()[1], frac.x ,mp); } } else { - if (p0.y+1::value> > >()(*loc, (1-frac.y),mp); + // the top-right corner pixel + ++loc.y(); + detail::add_dst_mul_src::value> > >()(*loc, 1 ,mp); + } + else if (p0.y+1::value> > >()(*loc, (1-frac.y),mp); ++loc.y(); - detail::add_dst_mul_src::value> > >()(*loc, frac.y ,mp); + detail::add_dst_mul_src::value> > >()(*loc, frac.y ,mp); } else { // the bottom-right corner pixel - detail::add_dst_mul_src::value> > >()(*loc,1,mp); + detail::add_dst_mul_src::value> > >()(*loc, 1 ,mp); } }