
14 Mar
2013
14 Mar
'13
6:15 p.m.
2013/3/14 Christian Henning> > My patch attached. I didn't write any tests (yet?). > > Could you give me a short description what this patch does. > Thanks! > Christian > Sure: Index: boost/gil/extension/numeric/sampler.hpp =================================================================== --- boost/gil/extension/numeric/sampler.hpp (revision 796) +++ boost/gil/extension/numeric/sampler.hpp (working copy) ### This fixed a compile error on platforms, where ptrdiff_t isn't int: @@ -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 { ### wrong comment and formula - // 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 { ### comment elaborated a bit, and formula unchanged, reformated only - // 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 { ### added the top-right corner pixel case - 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); + } ### elaborated the comment and the formula unchanged (formated only) + 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 ### formated only - detail::add_dst_mul_src ::value> > >()(*loc,1,mp); + detail::add_dst_mul_src ::value> > >()(*loc, 1 ,mp); } } Regards, Kris