https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2b623c1d0427cb0e5d54f9...
commit 2b623c1d0427cb0e5d54f928a1469f7f32ca7282 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Tue Jun 13 23:23:48 2023 +0900 Commit: GitHub noreply@github.com CommitDate: Tue Jun 13 23:23:48 2023 +0900
[MSPAINT] Refactor ImageModel (#5335)
- Unify ImageModel::Insert and ImageModel::CopyPrevious to ImageModel::PushImageForUndo. - Delete useless stuffs. - Fix some memory leaks. - Fix IDM_IMAGECROP. CORE-17969, CORE-18867 --- base/applications/mspaint/common.h | 9 - base/applications/mspaint/dib.cpp | 4 +- base/applications/mspaint/dib.h | 2 +- base/applications/mspaint/history.cpp | 246 ++++++++++++--------------- base/applications/mspaint/history.h | 35 ++-- base/applications/mspaint/mouse.cpp | 18 +- base/applications/mspaint/selectionmodel.cpp | 4 +- base/applications/mspaint/winproc.cpp | 7 +- 8 files changed, 143 insertions(+), 182 deletions(-)
diff --git a/base/applications/mspaint/common.h b/base/applications/mspaint/common.h index 0b9890d27f9..4aefbb2dcff 100644 --- a/base/applications/mspaint/common.h +++ b/base/applications/mspaint/common.h @@ -21,15 +21,6 @@ #define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2) #define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3) #define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4) -#define WM_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5) -#define WM_IMAGEMODELIMAGECHANGED (WM_APP + 6) -#define WM_SELECTIONMODELREFRESHNEEDED (WM_APP + 7) - -/* width of the rectangle defined by a RECT structure */ -#define RECT_WIDTH(a) ((a).right - (a).left) - -/* height of the rectangle defined by a RECT structure */ -#define RECT_HEIGHT(a) ((a).bottom - (a).top)
/* this simplifies checking and unchecking menu items */ #define CHECKED_IF(a) ((a) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)) diff --git a/base/applications/mspaint/dib.cpp b/base/applications/mspaint/dib.cpp index 4afa00c4771..51d09d86d6b 100644 --- a/base/applications/mspaint/dib.cpp +++ b/base/applications/mspaint/dib.cpp @@ -76,7 +76,7 @@ GetDIBHeight(HBITMAP hBitmap) return bm.bmHeight; }
-BOOL SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC) +BOOL SaveDIBToFile(HBITMAP hBitmap, LPCTSTR FileName, HDC hDC) { CImageDx img; img.Attach(hBitmap); @@ -135,7 +135,7 @@ HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCTSTR name, DWORD dwFileSize, BOOL i }
// update image - imageModel.Insert(hBitmap); + imageModel.PushImageForUndo(hBitmap); imageModel.ClearHistory();
// update fileSize diff --git a/base/applications/mspaint/dib.h b/base/applications/mspaint/dib.h index c01326f7b11..cc873913114 100644 --- a/base/applications/mspaint/dib.h +++ b/base/applications/mspaint/dib.h @@ -20,7 +20,7 @@ int GetDIBWidth(HBITMAP hbm);
int GetDIBHeight(HBITMAP hbm);
-BOOL SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC); +BOOL SaveDIBToFile(HBITMAP hBitmap, LPCTSTR FileName, HDC hDC);
HBITMAP DoLoadImageFile(HWND hwnd, LPCTSTR name, BOOL fIsMainFile);
diff --git a/base/applications/mspaint/history.cpp b/base/applications/mspaint/history.cpp index 4220bae84bd..ae6fb27b451 100644 --- a/base/applications/mspaint/history.cpp +++ b/base/applications/mspaint/history.cpp @@ -4,6 +4,7 @@ * FILE: base/applications/mspaint/history.cpp * PURPOSE: Undo and redo functionality * PROGRAMMERS: Benedikt Freisen + * Katayama Hirofumi MZ */
#include "precomp.h" @@ -12,97 +13,86 @@ ImageModel imageModel;
/* FUNCTIONS ********************************************************/
-void ImageModel::NotifyDimensionsChanged() -{ - if (canvasWindow.IsWindow()) - canvasWindow.SendMessage(WM_IMAGEMODELDIMENSIONSCHANGED); -} - void ImageModel::NotifyImageChanged() { if (canvasWindow.IsWindow()) - canvasWindow.SendMessage(WM_IMAGEMODELIMAGECHANGED); + canvasWindow.Invalidate(FALSE); }
ImageModel::ImageModel() + : hDrawingDC(::CreateCompatibleDC(NULL)) + , currInd(0) + , undoSteps(0) + , redoSteps(0) { - currInd = 0; - undoSteps = 0; - redoSteps = 0; - imageSaved = TRUE; + ZeroMemory(hBms, sizeof(hBms));
- // prepare a minimal usable bitmap - int imgXRes = 1; - int imgYRes = 1; + hBms[0] = CreateDIBWithProperties(1, 1); + ::SelectObject(hDrawingDC, hBms[0]);
- hDrawingDC = CreateCompatibleDC(NULL); - SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, paletteModel.GetFgColor())); - SelectObject(hDrawingDC, CreateSolidBrush(paletteModel.GetBgColor())); - - hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes); - SelectObject(hDrawingDC, hBms[0]); - Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1); + imageSaved = TRUE; }
-void ImageModel::CopyPrevious() +ImageModel::~ImageModel() { - ATLTRACE("%s: %d\n", __FUNCTION__, currInd); - DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); - hBms[(currInd + 1) % HISTORYSIZE] = CopyDIBImage(hBms[currInd]); - currInd = (currInd + 1) % HISTORYSIZE; - if (undoSteps < HISTORYSIZE - 1) - undoSteps++; - redoSteps = 0; - SelectObject(hDrawingDC, hBms[currInd]); - imageSaved = FALSE; + ::DeleteDC(hDrawingDC); + + for (size_t i = 0; i < HISTORYSIZE; ++i) + { + if (hBms[i]) + ::DeleteObject(hBms[i]); + } }
void ImageModel::Undo(BOOL bClearRedo) { ATLTRACE("%s: %d\n", __FUNCTION__, undoSteps); - if (undoSteps > 0) - { - int oldWidth = GetWidth(); - int oldHeight = GetHeight(); - selectionModel.m_bShow = FALSE; - currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE; - SelectObject(hDrawingDC, hBms[currInd]); - undoSteps--; - if (bClearRedo) - redoSteps = 0; - else if (redoSteps < HISTORYSIZE - 1) - redoSteps++; - if (GetWidth() != oldWidth || GetHeight() != oldHeight) - NotifyDimensionsChanged(); - NotifyImageChanged(); - } + if (!CanUndo()) + return; + + selectionModel.m_bShow = FALSE; + + // Select previous item + currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE; + ::SelectObject(hDrawingDC, hBms[currInd]); + + undoSteps--; + if (bClearRedo) + redoSteps = 0; + else if (redoSteps < HISTORYSIZE - 1) + redoSteps++; + + NotifyImageChanged(); }
void ImageModel::Redo() { ATLTRACE("%s: %d\n", __FUNCTION__, redoSteps); - if (redoSteps > 0) - { - int oldWidth = GetWidth(); - int oldHeight = GetHeight(); - selectionModel.m_bShow = FALSE; - currInd = (currInd + 1) % HISTORYSIZE; - SelectObject(hDrawingDC, hBms[currInd]); - redoSteps--; - if (undoSteps < HISTORYSIZE - 1) - undoSteps++; - if (GetWidth() != oldWidth || GetHeight() != oldHeight) - NotifyDimensionsChanged(); - NotifyImageChanged(); - } + if (!CanRedo()) + return; + + selectionModel.m_bShow = FALSE; + + // Select next item + currInd = (currInd + 1) % HISTORYSIZE; + ::SelectObject(hDrawingDC, hBms[currInd]); + + redoSteps--; + if (undoSteps < HISTORYSIZE - 1) + undoSteps++; + + NotifyImageChanged(); }
void ImageModel::ResetToPrevious() { ATLTRACE("%s: %d\n", __FUNCTION__, currInd); - DeleteObject(hBms[currInd]); + + // Revert current item with previous item + ::DeleteObject(hBms[currInd]); hBms[currInd] = CopyDIBImage(hBms[(currInd + HISTORYSIZE - 1) % HISTORYSIZE]); - SelectObject(hDrawingDC, hBms[currInd]); + ::SelectObject(hDrawingDC, hBms[currInd]); + NotifyImageChanged(); }
@@ -112,61 +102,61 @@ void ImageModel::ClearHistory() redoSteps = 0; }
-void ImageModel::Insert(HBITMAP hbm) +void ImageModel::PushImageForUndo(HBITMAP hbm) { - int oldWidth = GetWidth(); - int oldHeight = GetHeight(); - DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); - hBms[(currInd + 1) % HISTORYSIZE] = hbm; + ATLTRACE("%s: %d\n", __FUNCTION__, currInd); + + // Go to the next item with an HBITMAP or current item + ::DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); + hBms[(currInd + 1) % HISTORYSIZE] = (hbm ? hbm : CopyDIBImage(hBms[currInd])); currInd = (currInd + 1) % HISTORYSIZE; + ::SelectObject(hDrawingDC, hBms[currInd]); + if (undoSteps < HISTORYSIZE - 1) undoSteps++; redoSteps = 0; - SelectObject(hDrawingDC, hBms[currInd]); - if (GetWidth() != oldWidth || GetHeight() != oldHeight) - NotifyDimensionsChanged(); + + imageSaved = FALSE; NotifyImageChanged(); }
void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY) { - HDC hdc; - HPEN oldPen; - HBRUSH oldBrush; - int oldWidth = GetWidth(); - int oldHeight = GetHeight(); - + // We cannot create bitmaps of size zero 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); - currInd = (currInd + 1) % HISTORYSIZE; - if (undoSteps < HISTORYSIZE - 1) - undoSteps++; - redoSteps = 0; + // Create an HBITMAP + HBITMAP hbmCropped = CreateDIBWithProperties(nWidth, nHeight); + if (!hbmCropped) + return; + + // Select the HBITMAP by memory DC + HDC hdcMem = ::CreateCompatibleDC(hDrawingDC); + HGDIOBJ hbmOld = ::SelectObject(hdcMem, hbmCropped); + + // Fill background of the HBITMAP + RECT rcBack = { 0, 0, nWidth, nHeight }; + HBRUSH hbrBack = ::CreateSolidBrush(paletteModel.GetBgColor()); + ::FillRect(hdcMem, &rcBack, hbrBack); + ::DeleteObject(hbrBack);
- hdc = CreateCompatibleDC(hDrawingDC); - SelectObject(hdc, hBms[currInd]); + // Copy the old content + ::BitBlt(hdcMem, -nOffsetX, -nOffsetY, GetWidth(), GetHeight(), hDrawingDC, 0, 0, SRCCOPY);
- oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, paletteModel.GetBgColor())); - oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(paletteModel.GetBgColor())); - Rectangle(hdc, 0, 0, nWidth, nHeight); - BitBlt(hdc, -nOffsetX, -nOffsetY, GetWidth(), GetHeight(), hDrawingDC, 0, 0, SRCCOPY); - DeleteObject(SelectObject(hdc, oldBrush)); - DeleteObject(SelectObject(hdc, oldPen)); - DeleteDC(hdc); - SelectObject(hDrawingDC, hBms[currInd]); + // Clean up + ::SelectObject(hdcMem, hbmOld); + ::DeleteDC(hdcMem); + + // Push it + PushImageForUndo(hbmCropped);
- if (GetWidth() != oldWidth || GetHeight() != oldHeight) - NotifyDimensionsChanged(); NotifyImageChanged(); }
-void ImageModel::SaveImage(LPTSTR lpFileName) +void ImageModel::SaveImage(LPCTSTR lpFileName) { SaveDIBToFile(hBms[currInd], lpFileName, hDrawingDC); } @@ -176,16 +166,6 @@ BOOL ImageModel::IsImageSaved() const return imageSaved; }
-BOOL ImageModel::CanUndo() const -{ - return undoSteps > 0; -} - -BOOL ImageModel::CanRedo() const -{ - return redoSteps > 0; -} - void ImageModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY) { int oldWidth = GetWidth(); @@ -195,20 +175,18 @@ void ImageModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSk if (oldWidth != newWidth || oldHeight != newHeight) { HBITMAP hbm0 = CopyDIBImage(hBms[currInd], newWidth, newHeight); - Insert(hbm0); + PushImageForUndo(hbm0); } if (nSkewDegX) { HBITMAP hbm1 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegX, FALSE); - Insert(hbm1); + PushImageForUndo(hbm1); } if (nSkewDegY) { HBITMAP hbm2 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegY, TRUE); - Insert(hbm2); + PushImageForUndo(hbm2); } - if (GetWidth() != oldWidth || GetHeight() != oldHeight) - NotifyDimensionsChanged(); NotifyImageChanged(); }
@@ -225,17 +203,11 @@ int ImageModel::GetHeight() const void ImageModel::InvertColors() { RECT rect = {0, 0, GetWidth(), GetHeight()}; - CopyPrevious(); + PushImageForUndo(); InvertRect(hDrawingDC, &rect); NotifyImageChanged(); }
-void ImageModel::Clear(COLORREF color) -{ - Rectangle(hDrawingDC, 0 - 1, 0 - 1, GetWidth() + 1, GetHeight() + 1); - NotifyImageChanged(); -} - HDC ImageModel::GetDC() { return hDrawingDC; @@ -243,7 +215,7 @@ HDC ImageModel::GetDC()
void ImageModel::FlipHorizontally() { - CopyPrevious(); + PushImageForUndo(); StretchBlt(hDrawingDC, GetWidth() - 1, 0, -GetWidth(), GetHeight(), GetDC(), 0, 0, GetWidth(), GetHeight(), SRCCOPY); NotifyImageChanged(); @@ -251,7 +223,7 @@ void ImageModel::FlipHorizontally()
void ImageModel::FlipVertically() { - CopyPrevious(); + PushImageForUndo(); StretchBlt(hDrawingDC, 0, GetHeight() - 1, GetWidth(), -GetHeight(), GetDC(), 0, 0, GetWidth(), GetHeight(), SRCCOPY); NotifyImageChanged(); @@ -261,23 +233,21 @@ void ImageModel::RotateNTimes90Degrees(int iN) { switch (iN) { - case 1: - case 3: - DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); - hBms[(currInd + 1) % HISTORYSIZE] = Rotate90DegreeBlt(hDrawingDC, GetWidth(), GetHeight(), iN == 1, FALSE); - currInd = (currInd + 1) % HISTORYSIZE; - if (undoSteps < HISTORYSIZE - 1) - undoSteps++; - redoSteps = 0; - SelectObject(hDrawingDC, hBms[currInd]); - imageSaved = FALSE; - NotifyDimensionsChanged(); - break; - case 2: - CopyPrevious(); - StretchBlt(hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(), GetDC(), - 0, 0, GetWidth(), GetHeight(), SRCCOPY); - break; + case 1: + case 3: + { + HBITMAP hbm = Rotate90DegreeBlt(hDrawingDC, GetWidth(), GetHeight(), iN == 1, FALSE); + if (hbm) + PushImageForUndo(hbm); + break; + } + case 2: + { + PushImageForUndo(); + StretchBlt(hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(), + hDrawingDC, 0, 0, GetWidth(), GetHeight(), SRCCOPY); + break; + } } NotifyImageChanged(); } diff --git a/base/applications/mspaint/history.h b/base/applications/mspaint/history.h index d7a65f9e892..86c312df871 100644 --- a/base/applications/mspaint/history.h +++ b/base/applications/mspaint/history.h @@ -13,38 +13,37 @@
class ImageModel { -private: - void NotifyDimensionsChanged(); - void NotifyImageChanged(); - HDC hDrawingDC; -public: - HBITMAP hBms[HISTORYSIZE]; -private: - int currInd; - int undoSteps; - int redoSteps; public: ImageModel(); - void CopyPrevious(void); + virtual ~ImageModel(); + + HDC GetDC(); + BOOL CanUndo() const { return undoSteps > 0; } + BOOL CanRedo() const { return redoSteps > 0; } + void PushImageForUndo(HBITMAP hbm = NULL); + void ResetToPrevious(void); void Undo(BOOL bClearRedo = FALSE); void Redo(void); - void ResetToPrevious(void); void ClearHistory(void); - void Insert(HBITMAP hbm); void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0); - void SaveImage(LPTSTR lpFileName); + void SaveImage(LPCTSTR lpFileName); BOOL IsImageSaved() const; - BOOL CanUndo() const; - BOOL CanRedo() const; void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0); int GetWidth() const; int GetHeight() const; void InvertColors(); - void Clear(COLORREF color = 0x00ffffff); - HDC GetDC(); void FlipHorizontally(); void FlipVertically(); void RotateNTimes90Degrees(int iN); void DeleteSelection(); void Bound(POINT& pt); + +protected: + HDC hDrawingDC; // The device context for this class + int currInd; // The current index + int undoSteps; // The undo-able count + int redoSteps; // The redo-able count + HBITMAP hBms[HISTORYSIZE]; // A rotation buffer of HBITMAPs + + void NotifyImageChanged(); }; diff --git a/base/applications/mspaint/mouse.cpp b/base/applications/mspaint/mouse.cpp index 9fe51d00044..23bfa69043c 100644 --- a/base/applications/mspaint/mouse.cpp +++ b/base/applications/mspaint/mouse.cpp @@ -113,7 +113,7 @@ struct FreeSelTool : ToolBase selectionModel.Landing(); if (bLeftButton) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); selectionModel.m_bShow = FALSE; selectionModel.ResetPtStack(); POINT pt = { x, y }; @@ -187,7 +187,7 @@ struct RectSelTool : ToolBase selectionModel.Landing(); if (bLeftButton) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); selectionModel.m_bShow = FALSE; ::SetRectEmpty(&selectionModel.m_rc); } @@ -246,7 +246,7 @@ struct GenericDrawTool : ToolBase
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); draw(bLeftButton, x, y); }
@@ -293,7 +293,7 @@ struct FillTool : ToolBase
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); Fill(m_hdc, x, y, bLeftButton ? m_fg : m_bg); } }; @@ -341,7 +341,7 @@ struct ZoomTool : ToolBase
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); if (bLeftButton) { if (toolsModel.GetZoom() < MAX_ZOOM) @@ -419,7 +419,7 @@ struct TextTool : ToolBase if (!textEditWindow.IsWindow()) textEditWindow.Create(canvasWindow);
- imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); UpdatePoint(x, y); }
@@ -449,7 +449,7 @@ struct TextTool : ToolBase
// Draw the text INT style = (toolsModel.IsBackgroundTransparent() ? 0 : 1); - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); Text(m_hdc, rc.left, rc.top, rc.right, rc.bottom, m_fg, m_bg, szText, textEditWindow.GetFont(), style);
@@ -554,7 +554,7 @@ struct BezierTool : ToolBase
if (pointSP == 0) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); pointSP++; } } @@ -642,7 +642,7 @@ struct ShapeTool : ToolBase
if (pointSP == 0 && !bDoubleClick) { - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); draw(bLeftButton, x, y); pointSP++; } diff --git a/base/applications/mspaint/selectionmodel.cpp b/base/applications/mspaint/selectionmodel.cpp index 56d74ce877e..33ff6f05722 100644 --- a/base/applications/mspaint/selectionmodel.cpp +++ b/base/applications/mspaint/selectionmodel.cpp @@ -194,7 +194,7 @@ void SelectionModel::Landing() ClearMask(); ClearColor();
- imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); }
void SelectionModel::InsertFromHBITMAP(HBITMAP hBm, INT x, INT y) @@ -445,7 +445,7 @@ void SelectionModel::CancelSelection() if (!m_bShow) return;
- imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); if (m_bShow) imageModel.Undo(TRUE);
diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index c1deaa155bc..80a225b8a8a 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -204,7 +204,7 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window) SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0)); toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
- imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); selectionModel.InsertFromHBITMAP(bitmap, 0, 0); selectionModel.m_bShow = TRUE; canvasWindow.Invalidate(FALSE); @@ -761,7 +761,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH break; } case IDM_IMAGEDELETEIMAGE: - imageModel.CopyPrevious(); + imageModel.PushImageForUndo(); Rect(imageModel.GetDC(), 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetBgColor(), paletteModel.GetBgColor(), 0, TRUE); canvasWindow.Invalidate(FALSE); break; @@ -829,7 +829,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent()); break; case IDM_IMAGECROP: - imageModel.Insert(CopyDIBImage(selectionModel.GetBitmap())); + imageModel.PushImageForUndo(CopyDIBImage(selectionModel.GetBitmap())); + imageModel.DeleteSelection(); break;
case IDM_VIEWTOOLBOX: