ReactOS  0.4.15-dev-5452-g3c95c95
ImageModel Class Reference

#include <history.h>

Collaboration diagram for ImageModel:

Public Member Functions

 ImageModel ()
 
void CopyPrevious (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)
 
BOOL IsImageSaved () const
 
BOOL HasUndoSteps () const
 
BOOL HasRedoSteps () 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 DrawSelectionBackground (COLORREF rgbBG)
 
void DeleteSelection ()
 
void Bound (POINT &pt)
 

Public Attributes

HBITMAP hBms [HISTORYSIZE]
 

Private Member Functions

void NotifyDimensionsChanged ()
 
void NotifyImageChanged ()
 

Private Attributes

HDC hDrawingDC
 
int currInd
 
int undoSteps
 
int redoSteps
 

Detailed Description

Definition at line 14 of file history.h.

Constructor & Destructor Documentation

◆ ImageModel()

ImageModel::ImageModel ( )

Definition at line 27 of file history.cpp.

28 {
29  currInd = 0;
30  undoSteps = 0;
31  redoSteps = 0;
32  imageSaved = TRUE;
33 
34  // prepare a minimal usable bitmap
35  int imgXRes = 1;
36  int imgYRes = 1;
37 
41 
42  hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
44  Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
45 }
int redoSteps
Definition: history.h:25
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int currInd
Definition: history.h:23
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define TRUE
Definition: types.h:120
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
COLORREF GetBgColor() const
COLORREF GetFgColor() const
#define PS_SOLID
Definition: wingdi.h:586
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:17
int undoSteps
Definition: history.h:24
BOOL imageSaved
Definition: main.cpp:54
PaletteModel paletteModel
Definition: main.cpp:28
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Member Function Documentation

◆ Bound()

void ImageModel::Bound ( POINT pt)

Definition at line 305 of file history.cpp.

306 {
307  pt.x = max(0, min(pt.x, GetWidth()));
308  pt.y = max(0, min(pt.y, GetHeight()));
309 }
#define max(a, b)
Definition: svc.c:63
#define pt(x, y)
Definition: drawing.c:79
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
#define min(a, b)
Definition: monoChain.cc:55

Referenced by FreeSelTool::OnMouseMove(), RectSelTool::OnMouseMove(), and TextTool::UpdatePoint().

◆ Clear()

void ImageModel::Clear ( COLORREF  color = 0x00ffffff)

Definition at line 233 of file history.cpp.

234 {
235  Rectangle(hDrawingDC, 0 - 1, 0 - 1, GetWidth() + 1, GetHeight() + 1);
237 }
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC hDrawingDC
Definition: history.h:19
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
void NotifyImageChanged()
Definition: history.cpp:21

◆ ClearHistory()

void ImageModel::ClearHistory ( void  )

Definition at line 109 of file history.cpp.

110 {
111  undoSteps = 0;
112  redoSteps = 0;
113 }
int redoSteps
Definition: history.h:25
int undoSteps
Definition: history.h:24

Referenced by _tWinMain(), and SetBitmapAndInfo().

◆ CopyPrevious()

void ImageModel::CopyPrevious ( void  )

Definition at line 47 of file history.cpp.

48 {
49  ATLTRACE("%s: %d\n", __FUNCTION__, currInd);
52  currInd = (currInd + 1) % HISTORYSIZE;
53  if (undoSteps < HISTORYSIZE - 1)
54  undoSteps++;
55  redoSteps = 0;
57  imageSaved = FALSE;
58 }
int redoSteps
Definition: history.h:25
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:14
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ATLTRACE(format,...)
Definition: atltrace.h:276
#define FALSE
Definition: types.h:117
int undoSteps
Definition: history.h:24
BOOL imageSaved
Definition: main.cpp:54
#define __FUNCTION__
Definition: types.h:112
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Referenced by DeleteSelection(), FlipHorizontally(), FlipVertically(), CMainWindow::InsertSelectionFromHBITMAP(), InvertColors(), FreeSelTool::OnButtonDown(), RectSelTool::OnButtonDown(), GenericDrawTool::OnButtonDown(), FillTool::OnButtonDown(), ZoomTool::OnButtonDown(), TextTool::OnButtonDown(), BezierTool::OnButtonDown(), ShapeTool::OnButtonDown(), TextTool::OnButtonUp(), CMainWindow::OnCommand(), CSelectionWindow::OnLButtonUp(), RotateNTimes90Degrees(), SelectionModel::RotateNTimes90Degrees(), and SelectionModel::StretchSkew().

◆ Crop()

void ImageModel::Crop ( int  nWidth,
int  nHeight,
int  nOffsetX = 0,
int  nOffsetY = 0 
)

Definition at line 131 of file history.cpp.

132 {
133  HDC hdc;
134  HPEN oldPen;
135  HBRUSH oldBrush;
136  int oldWidth = GetWidth();
137  int oldHeight = GetHeight();
138 
139  if (nWidth <= 0)
140  nWidth = 1;
141  if (nHeight <= 0)
142  nHeight = 1;
143 
146  hBms[(currInd + 1) % HISTORYSIZE] = CreateDIBWithProperties(nWidth, nHeight);
147  currInd = (currInd + 1) % HISTORYSIZE;
148  if (undoSteps < HISTORYSIZE - 1)
149  undoSteps++;
150  redoSteps = 0;
151 
154 
155  oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, paletteModel.GetBgColor()));
156  oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(paletteModel.GetBgColor()));
157  Rectangle(hdc, 0, 0, nWidth, nHeight);
158  BitBlt(hdc, -nOffsetX, -nOffsetY, GetWidth(), GetHeight(), hDrawingDC, 0, 0, SRCCOPY);
159  DeleteObject(SelectObject(hdc, oldBrush));
160  DeleteObject(SelectObject(hdc, oldPen));
161  DeleteDC(hdc);
163 
164  if (GetWidth() != oldWidth || GetHeight() != oldHeight)
167 }
int redoSteps
Definition: history.h:25
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
static HDC
Definition: imagelist.c:92
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
COLORREF GetBgColor() const
#define PS_SOLID
Definition: wingdi.h:586
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:17
int GetWidth() const
Definition: history.cpp:215
int undoSteps
Definition: history.h:24
HDC hdc
Definition: main.c:9
int GetHeight() const
Definition: history.cpp:220
PaletteModel paletteModel
Definition: main.cpp:28
BOOL WINAPI DeleteDC(_In_ HDC)
void NotifyDimensionsChanged()
Definition: history.cpp:15
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
void NotifyImageChanged()
Definition: history.cpp:21
#define SRCCOPY
Definition: wingdi.h:333
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49

Referenced by _tWinMain(), CMainWindow::InsertSelectionFromHBITMAP(), CMainWindow::OnCommand(), and CSizeboxWindow::OnLButtonUp().

◆ DeleteSelection()

void ImageModel::DeleteSelection ( )

Definition at line 293 of file history.cpp.

294 {
295  if (selectionWindow.IsWindowVisible())
296  ResetToPrevious();
297  CopyPrevious();
298  if (selectionWindow.IsWindowVisible())
299  Undo(TRUE);
301  selectionWindow.ShowWindow(SW_HIDE);
303 }
void CopyPrevious(void)
Definition: history.cpp:47
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
COLORREF GetBgColor() const
PaletteModel paletteModel
Definition: main.cpp:28
void DrawSelectionBackground(COLORREF rgbBG)
Definition: history.cpp:285
void NotifyImageChanged()
Definition: history.cpp:21
void Undo(BOOL bClearRedo=FALSE)
Definition: history.cpp:60
void ResetToPrevious(void)
Definition: history.cpp:100
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by CMainWindow::OnCommand(), SelectionModel::RotateNTimes90Degrees(), and SelectionModel::StretchSkew().

◆ DrawSelectionBackground()

void ImageModel::DrawSelectionBackground ( COLORREF  rgbBG)

Definition at line 285 of file history.cpp.

286 {
289  else
291 }
ToolsModel toolsModel
Definition: main.cpp:18
HDC hDrawingDC
Definition: history.h:19
SelectionModel selectionModel
Definition: main.cpp:20
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg)
void DrawBackgroundRect(HDC hDCImage, COLORREF crBg)
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76

Referenced by DeleteSelection(), CSelectionWindow::ForceRefreshSelectionContents(), CSelectionWindow::OnLButtonUp(), and CSelectionWindow::OnMouseMove().

◆ FlipHorizontally()

void ImageModel::FlipHorizontally ( )

Definition at line 244 of file history.cpp.

245 {
246  CopyPrevious();
247  StretchBlt(hDrawingDC, GetWidth() - 1, 0, -GetWidth(), GetHeight(), GetDC(), 0, 0,
248  GetWidth(), GetHeight(), SRCCOPY);
250 }
void CopyPrevious(void)
Definition: history.cpp:47
HDC hDrawingDC
Definition: history.h:19
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HDC GetDC()
Definition: history.cpp:239
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
void NotifyImageChanged()
Definition: history.cpp:21
#define SRCCOPY
Definition: wingdi.h:333

Referenced by CMainWindow::OnCommand().

◆ FlipVertically()

void ImageModel::FlipVertically ( )

Definition at line 252 of file history.cpp.

253 {
254  CopyPrevious();
255  StretchBlt(hDrawingDC, 0, GetHeight() - 1, GetWidth(), -GetHeight(), GetDC(), 0, 0,
256  GetWidth(), GetHeight(), SRCCOPY);
258 }
void CopyPrevious(void)
Definition: history.cpp:47
HDC hDrawingDC
Definition: history.h:19
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HDC GetDC()
Definition: history.cpp:239
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
void NotifyImageChanged()
Definition: history.cpp:21
#define SRCCOPY
Definition: wingdi.h:333

Referenced by CMainWindow::OnCommand().

◆ GetDC()

◆ GetHeight()

◆ GetWidth()

◆ HasRedoSteps()

BOOL ImageModel::HasRedoSteps ( ) const

Definition at line 184 of file history.cpp.

185 {
186  return redoSteps > 0;
187 }
int redoSteps
Definition: history.h:25

Referenced by CMainWindow::OnInitMenuPopup().

◆ HasUndoSteps()

BOOL ImageModel::HasUndoSteps ( ) const

Definition at line 179 of file history.cpp.

180 {
181  return undoSteps > 0;
182 }
int undoSteps
Definition: history.h:24

Referenced by CMainWindow::OnInitMenuPopup().

◆ Insert()

void ImageModel::Insert ( HBITMAP  hbm)

Definition at line 115 of file history.cpp.

116 {
117  int oldWidth = GetWidth();
118  int oldHeight = GetHeight();
120  hBms[(currInd + 1) % HISTORYSIZE] = hbm;
121  currInd = (currInd + 1) % HISTORYSIZE;
122  if (undoSteps < HISTORYSIZE - 1)
123  undoSteps++;
124  redoSteps = 0;
126  if (GetWidth() != oldWidth || GetHeight() != oldHeight)
129 }
int redoSteps
Definition: history.h:25
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int GetWidth() const
Definition: history.cpp:215
int undoSteps
Definition: history.h:24
int GetHeight() const
Definition: history.cpp:220
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
void NotifyDimensionsChanged()
Definition: history.cpp:15
void NotifyImageChanged()
Definition: history.cpp:21
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Referenced by CMainWindow::OnCommand(), SetBitmapAndInfo(), and StretchSkew().

◆ InvertColors()

void ImageModel::InvertColors ( )

Definition at line 225 of file history.cpp.

226 {
227  RECT rect = {0, 0, GetWidth(), GetHeight()};
228  CopyPrevious();
231 }
void CopyPrevious(void)
Definition: history.cpp:47
HDC hDrawingDC
Definition: history.h:19
BOOL WINAPI InvertRect(_In_ HDC, _In_ LPCRECT)
& rect
Definition: startmenu.cpp:1413
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
void NotifyImageChanged()
Definition: history.cpp:21

Referenced by CMainWindow::OnCommand().

◆ IsImageSaved()

BOOL ImageModel::IsImageSaved ( ) const

Definition at line 174 of file history.cpp.

175 {
176  return imageSaved;
177 }
BOOL imageSaved
Definition: main.cpp:54

Referenced by CMainWindow::ConfirmSave().

◆ NotifyDimensionsChanged()

void ImageModel::NotifyDimensionsChanged ( )
private

Definition at line 15 of file history.cpp.

16 {
17  if (imageArea.IsWindow())
19 }
BOOL IsWindow() const
Definition: atlwin.h:941
CImgAreaWindow imageArea
Definition: main.cpp:72
#define WM_IMAGEMODELDIMENSIONSCHANGED
Definition: precomp.h:37
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110

Referenced by Crop(), Insert(), Redo(), RotateNTimes90Degrees(), StretchSkew(), and Undo().

◆ NotifyImageChanged()

void ImageModel::NotifyImageChanged ( )
private

Definition at line 21 of file history.cpp.

22 {
23  if (imageArea.IsWindow())
25 }
BOOL IsWindow() const
Definition: atlwin.h:941
CImgAreaWindow imageArea
Definition: main.cpp:72
#define WM_IMAGEMODELIMAGECHANGED
Definition: precomp.h:38
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110

Referenced by Clear(), Crop(), DeleteSelection(), FlipHorizontally(), FlipVertically(), Insert(), InvertColors(), Redo(), ResetToPrevious(), RotateNTimes90Degrees(), StretchSkew(), and Undo().

◆ Redo()

void ImageModel::Redo ( void  )

Definition at line 81 of file history.cpp.

82 {
83  ATLTRACE("%s: %d\n", __FUNCTION__, redoSteps);
84  if (redoSteps > 0)
85  {
86  int oldWidth = GetWidth();
87  int oldHeight = GetHeight();
88  selectionWindow.ShowWindow(SW_HIDE);
89  currInd = (currInd + 1) % HISTORYSIZE;
91  redoSteps--;
92  if (undoSteps < HISTORYSIZE - 1)
93  undoSteps++;
94  if (GetWidth() != oldWidth || GetHeight() != oldHeight)
97  }
98 }
int redoSteps
Definition: history.h:25
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
#define SW_HIDE
Definition: winuser.h:762
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define ATLTRACE(format,...)
Definition: atltrace.h:276
int GetWidth() const
Definition: history.cpp:215
int undoSteps
Definition: history.h:24
int GetHeight() const
Definition: history.cpp:220
void NotifyDimensionsChanged()
Definition: history.cpp:15
void NotifyImageChanged()
Definition: history.cpp:21
#define __FUNCTION__
Definition: types.h:112
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by CMainWindow::OnCommand().

◆ ResetToPrevious()

void ImageModel::ResetToPrevious ( void  )

Definition at line 100 of file history.cpp.

101 {
102  ATLTRACE("%s: %d\n", __FUNCTION__, currInd);
107 }
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:14
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ATLTRACE(format,...)
Definition: atltrace.h:276
void NotifyImageChanged()
Definition: history.cpp:21
#define __FUNCTION__
Definition: types.h:112
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Referenced by SelectionModel::CalculateBoundingBoxAndContents(), DeleteSelection(), LineTool::draw(), RectTool::draw(), EllipseTool::draw(), RRectTool::draw(), CSelectionWindow::ForceRefreshSelectionContents(), FreeSelTool::OnButtonUp(), RectSelTool::OnButtonUp(), BezierTool::OnButtonUp(), ShapeTool::OnButtonUp(), BezierTool::OnFinishDraw(), ShapeTool::OnFinishDraw(), CSelectionWindow::OnMouseMove(), FreeSelTool::OnMouseMove(), RectSelTool::OnMouseMove(), BezierTool::OnMouseMove(), ShapeTool::OnMouseMove(), and TextTool::UpdatePoint().

◆ RotateNTimes90Degrees()

void ImageModel::RotateNTimes90Degrees ( int  iN)

Definition at line 260 of file history.cpp.

261 {
262  switch (iN)
263  {
264  case 1:
265  case 3:
268  currInd = (currInd + 1) % HISTORYSIZE;
269  if (undoSteps < HISTORYSIZE - 1)
270  undoSteps++;
271  redoSteps = 0;
273  imageSaved = FALSE;
275  break;
276  case 2:
277  CopyPrevious();
279  0, 0, GetWidth(), GetHeight(), SRCCOPY);
280  break;
281  }
283 }
int redoSteps
Definition: history.h:25
void CopyPrevious(void)
Definition: history.cpp:47
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define FALSE
Definition: types.h:117
HDC GetDC()
Definition: history.cpp:239
int GetWidth() const
Definition: history.cpp:215
int undoSteps
Definition: history.h:24
HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight)
Definition: dib.cpp:213
BOOL imageSaved
Definition: main.cpp:54
int GetHeight() const
Definition: history.cpp:220
void NotifyDimensionsChanged()
Definition: history.cpp:15
void NotifyImageChanged()
Definition: history.cpp:21
#define SRCCOPY
Definition: wingdi.h:333
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Referenced by CMainWindow::OnCommand().

◆ SaveImage()

void ImageModel::SaveImage ( LPTSTR  lpFileName)

Definition at line 169 of file history.cpp.

170 {
172 }
int currInd
Definition: history.h:23
HDC hDrawingDC
Definition: history.h:19
BOOL SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC)
Definition: dib.cpp:69
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21
_In_ LPCSTR lpFileName
Definition: winbase.h:3058

Referenced by CMainWindow::saveImage().

◆ StretchSkew()

void ImageModel::StretchSkew ( int  nStretchPercentX,
int  nStretchPercentY,
int  nSkewDegX = 0,
int  nSkewDegY = 0 
)

Definition at line 189 of file history.cpp.

190 {
191  int oldWidth = GetWidth();
192  int oldHeight = GetHeight();
193  INT newWidth = oldWidth * nStretchPercentX / 100;
194  INT newHeight = oldHeight * nStretchPercentY / 100;
195  if (oldWidth != newWidth || oldHeight != newHeight)
196  {
197  HBITMAP hbm0 = CopyDIBImage(hBms[currInd], newWidth, newHeight);
198  Insert(hbm0);
199  }
200  if (nSkewDegX)
201  {
202  HBITMAP hbm1 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegX, FALSE);
203  Insert(hbm1);
204  }
205  if (nSkewDegY)
206  {
207  HBITMAP hbm2 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegY, TRUE);
208  Insert(hbm2);
209  }
210  if (GetWidth() != oldWidth || GetHeight() != oldHeight)
213 }
int currInd
Definition: history.h:23
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:14
#define TRUE
Definition: types.h:120
HDC hDrawingDC
Definition: history.h:19
int32_t INT
Definition: typedefs.h:58
HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical)
Definition: dib.cpp:252
#define FALSE
Definition: types.h:117
void Insert(HBITMAP hbm)
Definition: history.cpp:115
int GetWidth() const
Definition: history.cpp:215
int GetHeight() const
Definition: history.cpp:220
void NotifyDimensionsChanged()
Definition: history.cpp:15
void NotifyImageChanged()
Definition: history.cpp:21
static HBITMAP
Definition: button.c:44
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21

Referenced by CMainWindow::OnCommand().

◆ Undo()

void ImageModel::Undo ( BOOL  bClearRedo = FALSE)

Definition at line 60 of file history.cpp.

61 {
62  ATLTRACE("%s: %d\n", __FUNCTION__, undoSteps);
63  if (undoSteps > 0)
64  {
65  int oldWidth = GetWidth();
66  int oldHeight = GetHeight();
67  selectionWindow.ShowWindow(SW_HIDE);
70  undoSteps--;
71  if (bClearRedo)
72  redoSteps = 0;
73  else if (redoSteps < HISTORYSIZE - 1)
74  redoSteps++;
75  if (GetWidth() != oldWidth || GetHeight() != oldHeight)
78  }
79 }
int redoSteps
Definition: history.h:25
int currInd
Definition: history.h:23
#define HISTORYSIZE
Definition: history.h:12
#define SW_HIDE
Definition: winuser.h:762
HDC hDrawingDC
Definition: history.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define ATLTRACE(format,...)
Definition: atltrace.h:276
int GetWidth() const
Definition: history.cpp:215
int undoSteps
Definition: history.h:24
int GetHeight() const
Definition: history.cpp:220
void NotifyDimensionsChanged()
Definition: history.cpp:15
void NotifyImageChanged()
Definition: history.cpp:21
#define __FUNCTION__
Definition: types.h:112
HBITMAP hBms[HISTORYSIZE]
Definition: history.h:21
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by DeleteSelection(), FreeSelTool::OnButtonUp(), RectSelTool::OnButtonUp(), TextTool::OnButtonUp(), FreeSelTool::OnCancelDraw(), RectSelTool::OnCancelDraw(), GenericDrawTool::OnCancelDraw(), BezierTool::OnCancelDraw(), ShapeTool::OnCancelDraw(), CMainWindow::OnCommand(), ShapeTool::OnFinishDraw(), and CSelectionWindow::OnLButtonUp().

Member Data Documentation

◆ currInd

int ImageModel::currInd
private

◆ hBms

◆ hDrawingDC

◆ redoSteps

int ImageModel::redoSteps
private

◆ undoSteps

int ImageModel::undoSteps
private

The documentation for this class was generated from the following files: