mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[MSPAINT] Fix unzooming coordinate conversion (#9251)
Always rounding of unzooming coordinate values had caused display glitch (e.g. black line on top edge in zooming). JIRA issue: CORE-19466 - Add bRound parameter to UnZoomed function. If bRound is TRUE, then do round by kernel32!MulDiv function. Otherwise don't round. - Add bRound parameter to CCanvasWindow::CanvasToImage. - Make bRound = FALSE default. - Use bRound = TRUE for CCanvasWindow::OnButtonDown, CCanvasWindow::OnButtonDblClk, CCanvasWindow::OnMouseMove, and CCanvasWindow::OnButtonUp.
This commit is contained in:
@@ -196,17 +196,17 @@ VOID CCanvasWindow::ImageToCanvas(RECT& rc)
|
||||
::OffsetRect(&rc, GRIP_SIZE - GetScrollPos(SB_HORZ), GRIP_SIZE - GetScrollPos(SB_VERT));
|
||||
}
|
||||
|
||||
VOID CCanvasWindow::CanvasToImage(POINT& pt)
|
||||
VOID CCanvasWindow::CanvasToImage(POINT& pt, BOOL bRound)
|
||||
{
|
||||
pt.x -= GRIP_SIZE - GetScrollPos(SB_HORZ);
|
||||
pt.y -= GRIP_SIZE - GetScrollPos(SB_VERT);
|
||||
UnZoomed(pt);
|
||||
UnZoomed(pt, bRound);
|
||||
}
|
||||
|
||||
VOID CCanvasWindow::CanvasToImage(RECT& rc)
|
||||
VOID CCanvasWindow::CanvasToImage(RECT& rc, BOOL bRound)
|
||||
{
|
||||
::OffsetRect(&rc, GetScrollPos(SB_HORZ) - GRIP_SIZE, GetScrollPos(SB_VERT) - GRIP_SIZE);
|
||||
UnZoomed(rc);
|
||||
UnZoomed(rc, bRound);
|
||||
}
|
||||
|
||||
VOID CCanvasWindow::GetImageRect(RECT& rc)
|
||||
@@ -475,7 +475,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
||||
if (hitSelection != HIT_NONE)
|
||||
{
|
||||
m_drawing = TRUE;
|
||||
CanvasToImage(pt);
|
||||
CanvasToImage(pt, TRUE);
|
||||
SetCapture();
|
||||
toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, FALSE);
|
||||
Invalidate();
|
||||
@@ -507,7 +507,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
||||
return 0;
|
||||
}
|
||||
|
||||
CanvasToImage(pt);
|
||||
CanvasToImage(pt, TRUE);
|
||||
|
||||
if (hit == HIT_INNER)
|
||||
{
|
||||
@@ -531,7 +531,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
||||
LRESULT CCanvasWindow::OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
CanvasToImage(pt);
|
||||
CanvasToImage(pt, TRUE);
|
||||
|
||||
m_drawing = FALSE;
|
||||
::ReleaseCapture();
|
||||
@@ -557,7 +557,7 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
|
||||
return 0;
|
||||
}
|
||||
|
||||
CanvasToImage(pt);
|
||||
CanvasToImage(pt, TRUE);
|
||||
|
||||
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
|
||||
Invalidate();
|
||||
@@ -672,7 +672,7 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
|
||||
LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
CanvasToImage(pt);
|
||||
CanvasToImage(pt, TRUE);
|
||||
|
||||
::ReleaseCapture();
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ public:
|
||||
|
||||
VOID ImageToCanvas(POINT& pt);
|
||||
VOID ImageToCanvas(RECT& rc);
|
||||
VOID CanvasToImage(POINT& pt);
|
||||
VOID CanvasToImage(RECT& rc);
|
||||
VOID CanvasToImage(POINT& pt, BOOL bRound = FALSE);
|
||||
VOID CanvasToImage(RECT& rc, BOOL bRound = FALSE);
|
||||
VOID GetImageRect(RECT& rc);
|
||||
VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget);
|
||||
VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0);
|
||||
|
||||
@@ -172,9 +172,11 @@ static inline int Zoomed(int xy)
|
||||
return MulDiv(xy, toolsModel.GetZoom(), DEFAULT_ZOOM);
|
||||
}
|
||||
|
||||
static inline int UnZoomed(int xy)
|
||||
static inline int UnZoomed(int xy, BOOL bRound = FALSE)
|
||||
{
|
||||
return MulDiv(xy, DEFAULT_ZOOM, toolsModel.GetZoom());
|
||||
if (bRound)
|
||||
return MulDiv(xy, DEFAULT_ZOOM, toolsModel.GetZoom());
|
||||
return xy * DEFAULT_ZOOM / toolsModel.GetZoom();
|
||||
}
|
||||
|
||||
static inline void Zoomed(POINT& pt)
|
||||
@@ -187,12 +189,13 @@ static inline void Zoomed(RECT& rc)
|
||||
rc = { Zoomed(rc.left), Zoomed(rc.top), Zoomed(rc.right), Zoomed(rc.bottom) };
|
||||
}
|
||||
|
||||
static inline void UnZoomed(POINT& pt)
|
||||
static inline void UnZoomed(POINT& pt, BOOL bRound = FALSE)
|
||||
{
|
||||
pt = { UnZoomed(pt.x), UnZoomed(pt.y) };
|
||||
pt = { UnZoomed(pt.x, bRound), UnZoomed(pt.y, bRound) };
|
||||
}
|
||||
|
||||
static inline void UnZoomed(RECT& rc)
|
||||
static inline void UnZoomed(RECT& rc, BOOL bRound = FALSE)
|
||||
{
|
||||
rc = { UnZoomed(rc.left), UnZoomed(rc.top), UnZoomed(rc.right), UnZoomed(rc.bottom) };
|
||||
rc = { UnZoomed(rc.left, bRound), UnZoomed(rc.top, bRound),
|
||||
UnZoomed(rc.right, bRound), UnZoomed(rc.bottom, bRound) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user