Permalink
Browse files

When using nearest neighbor interpolation and not actually scaling, j…

…ust copy the data. (Note we don't do this for other kinds of interpolation, because the filtering on those interpolations could have an effect even when not actually scaling.)
  • Loading branch information...
1 parent bd94c0d commit 1c9f9b5f6cb3b308df95e56f7230d71963837812 @mdboom mdboom committed May 14, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/_image.cpp
View
@@ -439,11 +439,15 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)
case NEAREST:
{
- typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
- typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
- span_gen_type sg(ia, interpolator);
- renderer_type ri(rb, sa, sg);
- agg::render_scanlines(ras, sl, ri);
+ if (colsIn == numcols && rowsIn == numrows) {
+ memcpy(bufferOut, bufferIn, colsIn * rowsIn * 4);
+ } else {
+ typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
}
break;

0 comments on commit 1c9f9b5

Please sign in to comment.