https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b4422b41b93bc6b96562b...
commit 3b4422b41b93bc6b96562b2ea4d2af826a04d49b Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Wed Jun 14 17:14:41 2023 +0900 Commit: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com CommitDate: Wed Jun 14 17:14:41 2023 +0900
[MSPAINT] drawing.cpp: Refactor Erase, Replace and Airbrush 3
CORE-18867 --- base/applications/mspaint/drawing.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/base/applications/mspaint/drawing.cpp b/base/applications/mspaint/drawing.cpp index de9c925f396..600e7addd7a 100644 --- a/base/applications/mspaint/drawing.cpp +++ b/base/applications/mspaint/drawing.cpp @@ -117,16 +117,13 @@ void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius) { LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1))); - RECT rc; HBRUSH hbr = ::CreateSolidBrush(color);
for (LONG a = 0; a <= b; a++) { - ::SetRect(&rc, (x1 * (b - a) + x2 * a) / b - radius, - (y1 * (b - a) + y2 * a) / b - radius, - (x1 * (b - a) + x2 * a) / b + radius, - (y1 * (b - a) + y2 * a) / b + radius); - + LONG cx = (x1 * (b - a) + x2 * a) / b; + LONG cy = (y1 * (b - a) + y2 * a) / b; + RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius }; ::FillRect(hdc, &rc, hbr); }
@@ -137,14 +134,12 @@ void Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius) { LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1))); - RECT rc;
for (LONG a = 0; a <= b; a++) { - ::SetRect(&rc, (x1 * (b - a) + x2 * a) / b - radius, - (y1 * (b - a) + y2 * a) / b - radius, - (x1 * (b - a) + x2 * a) / b + radius, - (y1 * (b - a) + y2 * a) / b + radius); + LONG cx = (x1 * (b - a) + x2 * a) / b; + LONG cy = (y1 * (b - a) + y2 * a) / b; + RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius }; for (LONG y = rc.top; y < rc.bottom; ++y) { for (LONG x = rc.left; x < rc.right; ++x)