Fix qdx and qdy computation.
Off-by-1 error.
This commit is contained in:
parent
199ab32254
commit
8adf17510f
12
rotation.cpp
12
rotation.cpp
|
@ -517,8 +517,8 @@ Image* rotate(Image const& src, double angle)
|
||||||
Image* rotated = new Image(w, h, src.type);
|
Image* rotated = new Image(w, h, src.type);
|
||||||
|
|
||||||
DPoint const src_origin = get_mapped_point(*rotated, Point(0, 0), -rotation);
|
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_x = get_mapped_point(*rotated, Point(src.width, 0), -rotation);
|
||||||
DPoint src_delta_y = get_mapped_point(*rotated, Point(0, src.height - 1), -rotation);
|
DPoint src_delta_y = get_mapped_point(*rotated, Point(0, src.height), -rotation);
|
||||||
src_delta_x -= src_origin;
|
src_delta_x -= src_origin;
|
||||||
src_delta_y -= 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;
|
int const q_pos = 1 << q_pos_pow;
|
||||||
|
|
||||||
// TODO: we could have only one delta and deduce the other one
|
// 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 qdx(ceil(src_delta_x.x * q_pos / src.width), ceil(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 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_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);
|
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_qwidth = src.width * q_pos;
|
||||||
int const& src_qheight = src.height * q_pos;
|
int const& src_qheight = src.height * q_pos;
|
||||||
|
|
||||||
Point src_rotated_origin(rot_origin_in_src.x * q_pos + q_pos / 2,
|
Point src_rotated_origin(rot_origin_in_src.x * q_pos,
|
||||||
rot_origin_in_src.y * q_pos + q_pos / 2);
|
rot_origin_in_src.y * q_pos);
|
||||||
// Padding
|
// Padding
|
||||||
uint16_t* padding_table = generate_padding_table(*rotated, src_rotated_origin,
|
uint16_t* padding_table = generate_padding_table(*rotated, src_rotated_origin,
|
||||||
qdx, qdy,
|
qdx, qdy,
|
||||||
|
|
Loading…
Reference in a new issue