Fix qdx and qdy computation.

Off-by-1 error.
master
Fabien Freling 2014-08-06 22:24:20 +02:00
parent 199ab32254
commit 8adf17510f
1 changed files with 6 additions and 6 deletions

View File

@ -517,8 +517,8 @@ Image* rotate(Image const& src, double angle)
Image* rotated = new Image(w, h, src.type);
DPoint const src_origin = get_mapped_point(*rotated, Point(0, 0), -rotation);
DPoint src_delta_x = get_mapped_point(*rotated, Point(src.width - 1, 0), -rotation);
DPoint src_delta_y = get_mapped_point(*rotated, Point(0, src.height - 1), -rotation);
DPoint src_delta_x = get_mapped_point(*rotated, Point(src.width, 0), -rotation);
DPoint src_delta_y = get_mapped_point(*rotated, Point(0, src.height), -rotation);
src_delta_x -= src_origin;
src_delta_y -= src_origin;
@ -527,8 +527,8 @@ Image* rotate(Image const& src, double angle)
int const q_pos = 1 << q_pos_pow;
// TODO: we could have only one delta and deduce the other one
Point const qdx((src_delta_x.x * q_pos) / src.width, (src_delta_x.y * q_pos) / src.width);
Point const qdy((src_delta_y.x * q_pos) / src.height, (src_delta_y.y * q_pos) / src.height);
Point const qdx(ceil(src_delta_x.x * q_pos / src.width), ceil(src_delta_x.y * q_pos / src.width));
Point const qdy(ceil(src_delta_y.x * q_pos / src.height), ceil(src_delta_y.y * q_pos / src.height));
DPoint const rot_origin_in_src_grid = get_mapped_point(*rotated, Point(0, 0), -rotation);
DPoint const rot_origin_in_src = convert_img_coord_precision(src, rot_origin_in_src_grid);
@ -542,8 +542,8 @@ Image* rotate(Image const& src, double angle)
int const& src_qwidth = src.width * q_pos;
int const& src_qheight = src.height * q_pos;
Point src_rotated_origin(rot_origin_in_src.x * q_pos + q_pos / 2,
rot_origin_in_src.y * q_pos + q_pos / 2);
Point src_rotated_origin(rot_origin_in_src.x * q_pos,
rot_origin_in_src.y * q_pos);
// Padding
uint16_t* padding_table = generate_padding_table(*rotated, src_rotated_origin,
qdx, qdy,