X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5c91ac6b3ee117b46b729b6858a7725aefa9cce..8e3f12618963afb2d52b06f8d4a0134a34e802a2:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index ee63a318c4..908e1f89a3 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -127,6 +127,8 @@ wxImage::wxImage( const wxImage* image ) void wxImage::Create( int width, int height ) { + UnRef(); + m_refData = new wxImageRefData(); M_IMGDATA->m_data = (unsigned char *) malloc( width*height*3 ); @@ -2787,17 +2789,35 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i { wxRealPoint src = rotated_point (x + x1, y + y1, cos_angle, -sin_angle, p0); - if (0 < src.x && src.x < GetWidth() - 1 && - 0 < src.y && src.y < GetHeight() - 1) + if (-0.25 < src.x && src.x < GetWidth() - 0.75 && + -0.25 < src.y && src.y < GetHeight() - 0.75) { // interpolate using the 4 enclosing grid-points. Those // points can be obtained using floor and ceiling of the // exact coordinates of the point + // C.M. 2000-02-17: when the point is near the border, special care is required. - const int x1 = wxCint(floor(src.x)); - const int y1 = wxCint(floor(src.y)); - const int x2 = wxCint(ceil(src.x)); - const int y2 = wxCint(ceil(src.y)); + int x1, y1, x2, y2; + + if (0 < src.x && src.x < GetWidth() - 1) + { + x1 = wxCint(floor(src.x)); + x2 = wxCint(ceil(src.x)); + } + else // else means that x is near one of the borders (0 or width-1) + { + x1 = x2 = wxCint (src.x); + } + + if (0 < src.y && src.y < GetHeight() - 1) + { + y1 = wxCint(floor(src.y)); + y2 = wxCint(ceil(src.y)); + } + else + { + y1 = y2 = wxCint (src.y); + } // get four points and the distances (square of the distance, // for efficiency reasons) for the interpolation formula