[MSPAINT] Prepare for debugging (#4257)

- Add #include <debug.h> and add link to ntdll.dll for debugging.
- Add CopyDIBImage helper function.
CORE-17969
This commit is contained in:
Katayama Hirofumi MZ 2022-01-10 08:50:37 +09:00 committed by GitHub
parent 48d1a7bf4d
commit b2f8d62cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 12 deletions

View file

@ -32,6 +32,6 @@ add_executable(mspaint ${SOURCE} rsrc.rc)
set_module_type(mspaint win32gui UNICODE)
target_link_libraries(mspaint uuid cpprt atl_classes)
set_target_cpp_properties(mspaint WITH_EXCEPTIONS)
add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 rpcrt4 shlwapi)
add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 rpcrt4 shlwapi ntdll)
add_pch(mspaint precomp.h SOURCE)
add_cd_file(TARGET mspaint DESTINATION reactos/system32 FOR all)

View file

@ -11,6 +11,11 @@
HBITMAP CreateDIBWithProperties(int width, int height);
HBITMAP CreateColorDIB(int width, int height, COLORREF rgb);
static inline HBITMAP CopyDIBImage(HBITMAP hbm, INT cx = 0, INT cy = 0)
{
return (HBITMAP)CopyImage(hbm, IMAGE_BITMAP, cx, cy, LR_COPYRETURNORG | LR_CREATEDIBSECTION);
}
int GetDIBWidth(HBITMAP hbm);
int GetDIBHeight(HBITMAP hbm);

View file

@ -44,8 +44,9 @@ ImageModel::ImageModel()
void ImageModel::CopyPrevious()
{
DPRINT("%s: %d\n", __FUNCTION__, currInd);
DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]);
hBms[(currInd + 1) % HISTORYSIZE] = (HBITMAP) CopyImage(hBms[currInd], IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
hBms[(currInd + 1) % HISTORYSIZE] = CopyDIBImage(hBms[currInd]);
currInd = (currInd + 1) % HISTORYSIZE;
if (undoSteps < HISTORYSIZE - 1)
undoSteps++;
@ -56,6 +57,7 @@ void ImageModel::CopyPrevious()
void ImageModel::Undo()
{
DPRINT("%s: %d\n", __FUNCTION__, undoSteps);
if (undoSteps > 0)
{
int oldWidth = GetWidth();
@ -74,6 +76,7 @@ void ImageModel::Undo()
void ImageModel::Redo()
{
DPRINT("%s: %d\n", __FUNCTION__, redoSteps);
if (redoSteps > 0)
{
int oldWidth = GetWidth();
@ -92,9 +95,9 @@ void ImageModel::Redo()
void ImageModel::ResetToPrevious()
{
DPRINT("%s: %d\n", __FUNCTION__, currInd);
DeleteObject(hBms[currInd]);
hBms[currInd] =
(HBITMAP) CopyImage(hBms[(currInd + HISTORYSIZE - 1) % HISTORYSIZE], IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
hBms[currInd] = CopyDIBImage(hBms[(currInd + HISTORYSIZE - 1) % HISTORYSIZE]);
SelectObject(hDrawingDC, hBms[currInd]);
NotifyImageChanged();
}
@ -183,9 +186,9 @@ void ImageModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSk
{
int oldWidth = GetWidth();
int oldHeight = GetHeight();
Insert((HBITMAP) CopyImage(hBms[currInd], IMAGE_BITMAP,
GetWidth() * nStretchPercentX / 100,
GetHeight() * nStretchPercentY / 100, 0));
INT newWidth = oldWidth * nStretchPercentX / 100;
INT newHeight = oldHeight * nStretchPercentY / 100;
Insert(CopyDIBImage(hBms[currInd], newWidth, newHeight));
if (GetWidth() != oldWidth || GetHeight() != oldHeight)
NotifyDimensionsChanged();
NotifyImageChanged();

View file

@ -21,6 +21,9 @@
#include <shellapi.h>
#include <htmlhelp.h>
#define NDEBUG
#include <debug.h>
#define WM_TOOLSMODELTOOLCHANGED (WM_APP + 0)
#define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
#define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)

View file

@ -170,9 +170,8 @@ void SelectionModel::InsertFromHBITMAP(HBITMAP hBm)
HDC hTempDC;
HBITMAP hTempMask;
DeleteObject(SelectObject(m_hDC, m_hBm = (HBITMAP) CopyImage(hBm,
IMAGE_BITMAP, 0, 0,
LR_COPYRETURNORG)));
m_hBm = CopyDIBImage(hBm);
DeleteObject(SelectObject(m_hDC, m_hBm));
SetRectEmpty(&m_rcSrc);
m_rcDest.left = m_rcDest.top = 0;

View file

@ -534,7 +534,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
case IDM_EDITCOPY:
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP, CopyImage(selectionModel.GetBitmap(), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
SetClipboardData(CF_BITMAP, CopyDIBImage(selectionModel.GetBitmap()));
CloseClipboard();
break;
case IDM_EDITCUT:
@ -653,7 +653,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
break;
case IDM_IMAGECROP:
imageModel.Insert((HBITMAP) CopyImage(selectionModel.GetBitmap(), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
imageModel.Insert(CopyDIBImage(selectionModel.GetBitmap()));
break;
case IDM_VIEWTOOLBOX: