Skip to content

Commit

Permalink
Fix GitHub issue #188: Image compare breaks when zoomed too much with…
Browse files Browse the repository at this point in the history
… large pictures
  • Loading branch information
sdottaka committed Sep 23, 2019
1 parent 99ababb commit 4fd3eb5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/ImgMergeWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,13 @@ class CImgMergeWindow : public IImgMergeWindow
}
case WM_HSCROLL:
case WM_VSCROLL:
if (LOWORD(wParam) == SB_THUMBTRACK)
{
SCROLLINFO si = { si.cbSize = sizeof SCROLLINFO };
si.fMask = SIF_TRACKPOS;
GetScrollInfo(hwnd, (iMsg == WM_HSCROLL) ? SB_HORZ : SB_VERT, &si);
wParam |= (si.nTrackPos & 0xff0000) >> 8;
}
case WM_MOUSEWHEEL:
for (int j = 0; j < pImgWnd->m_nImages; ++j)
{
Expand Down
33 changes: 27 additions & 6 deletions src/ImgWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,32 @@ class CImgWindow

PatBlt(hdcMem, 0, 0, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);

POINT pt = ConvertLPtoDP(0, 0);
RECT rcImg = { pt.x, pt.y, pt.x + static_cast<int>(m_fip->getWidth() * m_zoom), pt.y + static_cast<int>(m_fip->getHeight() * m_zoom) };

if (m_fip->isValid())
m_fip->drawEx(hdcMem, rcImg, false, m_useBackColor ? &m_backColor : NULL);
{
POINT pt = ConvertLPtoDP(0, 0);
RECT rcImg = { pt.x, pt.y, pt.x + static_cast<int>(m_fip->getWidth() * m_zoom), pt.y + static_cast<int>(m_fip->getHeight() * m_zoom) };

if (rcImg.left <= -32767 / 2 || rcImg.right >= 32767 / 2 || rcImg.top <= -32767 / 2 || rcImg.bottom >= 32767 / 2)
{
fipWinImage fipSubImage;
POINT ptTmpLT = ConvertDPtoLP(0, 0);
POINT ptTmpRB = ConvertDPtoLP(rc.right + static_cast<int>(1 * m_zoom), static_cast<int>(rc.bottom + 1 * m_zoom));
POINT ptSubLT = { (ptTmpLT.x >= 0) ? ptTmpLT.x : 0, (ptTmpLT.y >= 0) ? ptTmpLT.y : 0 };
POINT ptSubRB = {
ptTmpRB.x < static_cast<int>(m_fip->getWidth()) ? ptTmpRB.x : static_cast<int>(m_fip->getWidth()),
ptTmpRB.y < static_cast<int>(m_fip->getHeight()) ? ptTmpRB.y : static_cast<int>(m_fip->getHeight())
};
POINT ptSubLTDP = ConvertLPtoDP(ptSubLT.x, ptSubLT.y);
POINT ptSubRBDP = ConvertLPtoDP(ptSubRB.x, ptSubRB.y);
rcImg = { ptSubLTDP.x, ptSubLTDP.y, ptSubRBDP.x, ptSubRBDP.y };
m_fip->copySubImage(fipSubImage, ptSubLT.x, ptSubLT.y, ptSubRB.x, ptSubRB.y);
fipSubImage.drawEx(hdcMem, rcImg, false, m_useBackColor ? &m_backColor : NULL);
}
else
{
m_fip->drawEx(hdcMem, rcImg, false, m_useBackColor ? &m_backColor : NULL);
}
}

BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hdcMem, 0, 0, SRCCOPY);

Expand Down Expand Up @@ -468,10 +489,10 @@ class CImgWindow
OnPaint();
break;
case WM_HSCROLL:
OnHScroll((UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam));
OnHScroll((UINT)(LOWORD(wParam) & 0xff), (int)(unsigned short)HIWORD(wParam) | ((LOWORD(wParam) & 0xff00) << 8)); // See 'case WM_HSCROLL:' in CImgMergeWindow::ChildWndProc()
break;
case WM_VSCROLL:
OnVScroll((UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam));
OnVScroll((UINT)(LOWORD(wParam) & 0xff), (int)(unsigned short)HIWORD(wParam) | ((LOWORD(wParam) & 0xff00) << 8)); // See 'case WM_VSCROLL:' in CImgMergeWindow::ChildWndProc()
break;
case WM_LBUTTONDOWN:
OnLButtonDown((UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam));
Expand Down

0 comments on commit 4fd3eb5

Please sign in to comment.