[MSPAINT]

- fix incorrect image resizing -- patch by Katayama Hirofumi MZ

CORE-10719 #resolve

svn path=/trunk/; revision=74936
This commit is contained in:
Benedikt Freisen 2017-06-07 10:00:04 +00:00
parent 7ca0d5807c
commit 9a2dd59876
3 changed files with 18 additions and 5 deletions

View file

@ -129,6 +129,11 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY)
int oldWidth = GetWidth();
int oldHeight = GetHeight();
if (nWidth <= 0)
nWidth = 1;
if (nHeight <= 0)
nHeight = 1;
SelectObject(hDrawingDC, hBms[currInd]);
DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]);
hBms[(currInd + 1) % HISTORYSIZE] = CreateDIBWithProperties(nWidth, nHeight);

View file

@ -12,9 +12,9 @@
/* FUNCTIONS ********************************************************/
BOOL resizing = FALSE;
short xOrig;
short yOrig;
static BOOL resizing = FALSE;
static short xOrig;
static short yOrig;
LRESULT CSizeboxWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
@ -76,8 +76,6 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
{
short xRel;
short yRel;
ReleaseCapture();
resizing = FALSE;
int imgXRes = imageModel.GetWidth();
int imgYRes = imageModel.GetHeight();
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom();
@ -100,5 +98,13 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
}
ReleaseCapture();
resizing = FALSE;
return 0;
}
LRESULT CSizeboxWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
resizing = FALSE;
return 0;
}

View file

@ -16,10 +16,12 @@ public:
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
END_MSG_MAP()
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};