diff --git a/image.h b/image.h index 09d6d90..1f9cb96 100644 --- a/image.h +++ b/image.h @@ -29,6 +29,34 @@ struct TPoint { : x(a) , y(b) {} + + TPoint& operator+=(TPoint const& rhs) + { + x += rhs.x; + y += rhs.y; + return *this; + } + + TPoint& operator-=(TPoint const& rhs) + { + x -= rhs.x; + y -= rhs.y; + return *this; + } + + TPoint& operator*=(TPoint const& rhs) + { + x *= rhs.x; + y *= rhs.y; + return *this; + } + + TPoint& operator/=(TPoint const& rhs) + { + x /= rhs.x; + y /= rhs.y; + return *this; + } }; typedef TPoint Point; diff --git a/rotation.cpp b/rotation.cpp index 052cfbf..e99dc0b 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -234,10 +234,8 @@ Image* rotate(Image const& src, double angle) 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); - src_delta_x.x = src_delta_x.x - src_origin.x; - src_delta_x.y = src_delta_x.y - src_origin.y; - src_delta_y.x = src_delta_y.x - src_origin.x; - src_delta_y.y = src_delta_y.y - src_origin.y; + src_delta_x -= src_origin; + src_delta_y -= src_origin; // Quantized delta unsigned int const q_pow = 4; @@ -273,8 +271,7 @@ Image* rotate(Image const& src, double angle) q_pow, q); } - src_rotated_point.x += qdx.x; - src_rotated_point.y += qdx.y; + src_rotated_point += qdx; buffer_index += rotated->pixel_size; }