Add TPoint operators +=, -=, *=, /=
This commit is contained in:
parent
e7802e30fd
commit
e804d9b5ca
28
image.h
28
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<int> Point;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue