From 05777d59f817bcec8fda001775c0f9793a5387e5 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sat, 28 Jun 2014 18:35:48 +0200 Subject: [PATCH] Deduce src points needed for interpolation. Computing the four points is too heavy. --- rotation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rotation.cpp b/rotation.cpp index cc65513..fd7ef13 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -467,9 +467,10 @@ void rotate_pixel(Image const& src, Image& rotated, // Bilinear interpolation unsigned int src_index_1 = (floor(src_rotated_point.y) * src.width + floor(src_rotated_point.x)) * 3; - unsigned int src_index_2 = (floor(src_rotated_point.y) * src.width + ceil(src_rotated_point.x)) * 3; - unsigned int src_index_3 = (ceil(src_rotated_point.y) * src.width + floor(src_rotated_point.x)) * 3; - unsigned int src_index_4 = (ceil(src_rotated_point.y) * src.width + ceil(src_rotated_point.x)) * 3; + unsigned int src_index_2 = src_index_1 + 3; + unsigned int src_index_3 = src_index_1 + 3 * src.width; + unsigned int src_index_4 = src_index_3 + 3; + if (src_index_1 >= src_limit || src_index_1 >= src_limit) return;