From 4f0df34e67c3595d9a630f05bc5ddf5a395ad6c7 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 27 Apr 2018 17:30:25 +1000 Subject: Backport: Use floor instead of casts when centring bitmaps inside the given rectangle. Backport of changeset 6751:23a8e12e4b3d. --- win32/PlatWin.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 07759abf2..0d5cbdacf 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -858,10 +858,10 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig if (rc.Width() > 0) { HDC hMemDC = ::CreateCompatibleDC(hdc); if (rc.Width() > width) - rc.left += static_cast((rc.Width() - width) / 2); + rc.left += floor((rc.Width() - width) / 2); rc.right = rc.left + width; if (rc.Height() > height) - rc.top += static_cast((rc.Height() - height) / 2); + rc.top += floor((rc.Height() - height) / 2); rc.bottom = rc.top + height; const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, @@ -1473,10 +1473,10 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { if (pRenderTarget) { if (rc.Width() > width) - rc.left += static_cast((rc.Width() - width) / 2); + rc.left += floor((rc.Width() - width) / 2); rc.right = rc.left + width; if (rc.Height() > height) - rc.top += static_cast((rc.Height() - height) / 2); + rc.top += floor((rc.Height() - height) / 2); rc.bottom = rc.top + height; std::vector image(height * width * 4); -- cgit v1.2.3