ReactOS 0.4.16-dev-258-g81860b4
drawing.cpp File Reference
#include "precomp.h"
Include dependency graph for drawing.cpp:

Go to the source code of this file.

Functions

void Line (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, int thickness)
 
void Rect (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
 
void Ellp (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
 
void RRect (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
 
void Poly (HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
 
void Bezier (HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
 
void Fill (HDC hdc, LONG x, LONG y, COLORREF color)
 
void Erase (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
 
void Replace (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius)
 
void Airbrush (HDC hdc, LONG x, LONG y, COLORREF color, LONG r)
 
void Brush (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style, INT thickness)
 
void RectSel (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
 
void Text (HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCWSTR lpchText, HFONT font, LONG style)
 
BOOL ColorKeyedMaskBlt (HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight, HBITMAP hbmMask, COLORREF keyColor)
 
void DrawXorRect (HDC hdc, const RECT *prc)
 

Function Documentation

◆ Airbrush()

void Airbrush ( HDC  hdc,
LONG  x,
LONG  y,
COLORREF  color,
LONG  r 
)

Definition at line 153 of file drawing.cpp.

154{
155 for (LONG dy = -r; dy <= r; dy++)
156 {
157 for (LONG dx = -r; dx <= r; dx++)
158 {
159 if ((dx * dx + dy * dy <= r * r) && (rand() % r == 0))
160 ::SetPixelV(hdc, x + dx, y + dy, color);
161 }
162 }
163}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint color
Definition: glext.h:6243
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
HDC hdc
Definition: main.c:9
long LONG
Definition: pedump.c:60
BOOL WINAPI SetPixelV(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)

Referenced by CToolSettingsWindow::drawAirBrush(), and AirBrushTool::OnDraw().

◆ Bezier()

void Bezier ( HDC  hdc,
POINT  p1,
POINT  p2,
POINT  p3,
POINT  p4,
COLORREF  color,
int  thickness 
)

Definition at line 93 of file drawing.cpp.

94{
95 HPEN oldPen;
96 POINT fourPoints[4];
97 fourPoints[0] = p1;
98 fourPoints[1] = p2;
99 fourPoints[2] = p3;
100 fourPoints[3] = p4;
101 oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
102 PolyBezier(hdc, fourPoints, 4);
103 DeleteObject(SelectObject(hdc, oldPen));
104}
pKey DeleteObject()
BOOL WINAPI PolyBezier(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:263
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586

Referenced by GDI_Bezier(), and BezierTool::OnDrawOverlayOnImage().

◆ Brush()

void Brush ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  color,
LONG  style,
INT  thickness 
)

Definition at line 166 of file drawing.cpp.

167{
168 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, color));
169 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
170
171 if (thickness <= 1)
172 {
173 Line(hdc, x1, y1, x2, y2, color, thickness);
174 }
175 else
176 {
177 LONG a, b = max(1, max(labs(x2 - x1), labs(y2 - y1)));
178 switch ((BrushStyle)style)
179 {
180 case BrushStyleRound:
181 for (a = 0; a <= b; a++)
182 {
183 Ellipse(hdc,
184 (x1 * (b - a) + x2 * a) / b - (thickness / 2),
185 (y1 * (b - a) + y2 * a) / b - (thickness / 2),
186 (x1 * (b - a) + x2 * a) / b + (thickness / 2),
187 (y1 * (b - a) + y2 * a) / b + (thickness / 2));
188 }
189 break;
190
191 case BrushStyleSquare:
192 for (a = 0; a <= b; a++)
193 {
195 (x1 * (b - a) + x2 * a) / b - (thickness / 2),
196 (y1 * (b - a) + y2 * a) / b - (thickness / 2),
197 (x1 * (b - a) + x2 * a) / b + (thickness / 2),
198 (y1 * (b - a) + y2 * a) / b + (thickness / 2));
199 }
200 break;
201
204 {
205 POINT offsetTop, offsetBottom;
207 {
208 offsetTop = { (thickness - 1) / 2, -(thickness - 1) / 2 };
209 offsetBottom = { -thickness / 2, thickness / 2 };
210 }
211 else
212 {
213 offsetTop = { -thickness / 2, -thickness / 2 };
214 offsetBottom = { (thickness - 1) / 2, (thickness - 1) / 2 };
215 }
216 POINT points[4] =
217 {
218 { x1 + offsetTop.x, y1 + offsetTop.y },
219 { x1 + offsetBottom.x, y1 + offsetBottom.y },
220 { x2 + offsetBottom.x, y2 + offsetBottom.y },
221 { x2 + offsetTop.x, y2 + offsetTop.y },
222 };
224 break;
225 }
226 }
227 }
228 DeleteObject(SelectObject(hdc, oldBrush));
229 DeleteObject(SelectObject(hdc, oldPen));
230}
Arabic default style
Definition: afstyles.h:94
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei const GLfloat * points
Definition: glext.h:8112
_Check_return_ long __cdecl labs(_In_ long x)
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define _countof(array)
Definition: sndvol32.h:70
Definition: ncftp.h:79
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define max(a, b)
Definition: svc.c:63
BrushStyle
Definition: toolsmodel.h:32
@ BrushStyleForeSlash
Definition: toolsmodel.h:35
@ BrushStyleRound
Definition: toolsmodel.h:33
@ BrushStyleBackSlash
Definition: toolsmodel.h:36
@ BrushStyleSquare
Definition: toolsmodel.h:34
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

◆ ColorKeyedMaskBlt()

BOOL ColorKeyedMaskBlt ( HDC  hdcDest,
int  nXDest,
int  nYDest,
int  nWidth,
int  nHeight,
HDC  hdcSrc,
int  nXSrc,
int  nYSrc,
int  nSrcWidth,
int  nSrcHeight,
HBITMAP  hbmMask,
COLORREF  keyColor 
)

Definition at line 287 of file drawing.cpp.

290{
291 HDC hTempDC1, hTempDC2;
292 HBITMAP hbmTempColor, hbmTempMask;
293 HGDIOBJ hbmOld1, hbmOld2;
294
295 if (hbmMask == NULL)
296 {
297 if (keyColor == CLR_INVALID)
298 {
299 ::StretchBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
300 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
301 }
302 else
303 {
304 ::GdiTransparentBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
305 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
306 }
307 return TRUE;
308 }
309 else if (nWidth == nSrcWidth && nHeight == nSrcHeight && keyColor == CLR_INVALID)
310 {
311 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
312 hdcSrc, nXSrc, nYSrc, hbmMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
313 return TRUE;
314 }
315
316 hTempDC1 = ::CreateCompatibleDC(hdcDest);
317 hTempDC2 = ::CreateCompatibleDC(hdcDest);
318 hbmTempMask = ::CreateBitmap(nWidth, nHeight, 1, 1, NULL);
319 hbmTempColor = CreateColorDIB(nWidth, nHeight, RGB(255, 255, 255));
320
321 // hbmTempMask <-- hbmMask (stretched)
322 hbmOld1 = ::SelectObject(hTempDC1, hbmMask);
323 hbmOld2 = ::SelectObject(hTempDC2, hbmTempMask);
324 ::StretchBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC1, 0, 0, nSrcWidth, nSrcHeight, SRCCOPY);
325 ::SelectObject(hTempDC2, hbmOld2);
326 ::SelectObject(hTempDC1, hbmOld1);
327
328 hbmOld1 = ::SelectObject(hTempDC1, hbmTempColor);
329 if (keyColor == CLR_INVALID)
330 {
331 // hbmTempColor <-- hdcSrc (stretched)
332 ::StretchBlt(hTempDC1, 0, 0, nWidth, nHeight,
333 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
334
335 // hdcDest <-- hbmTempColor (masked)
336 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
337 hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
338 }
339 else
340 {
341 // hbmTempColor <-- hdcDest
342 ::BitBlt(hTempDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
343
344 // hbmTempColor <-- hdcSrc (color key)
345 ::GdiTransparentBlt(hTempDC1, 0, 0, nWidth, nHeight,
346 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
347
348 // hdcDest <-- hbmTempColor (masked)
349 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
350 hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
351 }
352 ::SelectObject(hTempDC1, hbmOld1);
353
354 ::DeleteObject(hbmTempColor);
355 ::DeleteObject(hbmTempMask);
356 ::DeleteDC(hTempDC2);
357 ::DeleteDC(hTempDC1);
358
359 return TRUE;
360}
HBITMAP CreateColorDIB(int width, int height, COLORREF rgb)
Definition: dib.cpp:65
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static VOID 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:57
#define RGB(r, g, b)
Definition: precomp.h:71
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
BOOL WINAPI GdiTransparentBlt(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
BOOL WINAPI MaskBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ HDC, _In_ int, _In_ int, _In_ HBITMAP, _In_ int, _In_ int, _In_ DWORD)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
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 CLR_INVALID
Definition: wingdi.h:883
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
#define MAKEROP4(f, b)
Definition: wingdi.h:2946
static HDC hdcSrc
Definition: xlate.c:32

Referenced by SelectionModel::DrawSelection().

◆ DrawXorRect()

void DrawXorRect ( HDC  hdc,
const RECT prc 
)

Definition at line 362 of file drawing.cpp.

363{
364 HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 0, RGB(0, 0, 0)));
366 INT oldRop2 = SetROP2(hdc, R2_NOTXORPEN);
368 ::SetROP2(hdc, oldRop2);
369 ::SelectObject(hdc, oldBrush);
371}
_Out_ LPRECT prc
Definition: ntgdi.h:1658
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define R2_NOTXORPEN
Definition: wingdi.h:351
#define NULL_BRUSH
Definition: wingdi.h:901
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1114

Referenced by CCanvasWindow::DoDraw(), and ZoomTool::OnDrawOverlayOnCanvas().

◆ Ellp()

void Ellp ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  fg,
COLORREF  bg,
int  thickness,
int  style 
)

Definition at line 38 of file drawing.cpp.

39{
40 HBRUSH oldBrush;
41 LOGBRUSH logbrush;
42 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
43 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
44 logbrush.lbColor = (style == 2) ? fg : bg;
45 logbrush.lbHatch = 0;
46 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
47 Ellipse(hdc, x1, y1, x2, y2);
48 DeleteObject(SelectObject(hdc, oldBrush));
50}
UINT lbStyle
Definition: wingdi.h:1747
ULONG_PTR lbHatch
Definition: wingdi.h:1749
COLORREF lbColor
Definition: wingdi.h:1748
HBRUSH WINAPI CreateBrushIndirect(_In_ const LOGBRUSH *plb)
#define BS_HOLLOW
Definition: wingdi.h:1088
#define BS_SOLID
Definition: wingdi.h:1086

Referenced by EllipseTool::OnDrawOverlayOnImage().

◆ Erase()

void Erase ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  color,
LONG  radius 
)

Definition at line 115 of file drawing.cpp.

116{
117 LONG b = max(1, max(labs(x2 - x1), labs(y2 - y1)));
118 HBRUSH hbr = ::CreateSolidBrush(color);
119
120 for (LONG a = 0; a <= b; a++)
121 {
122 LONG cx = (x1 * (b - a) + x2 * a) / b;
123 LONG cy = (y1 * (b - a) + y2 * a) / b;
124 RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius };
125 ::FillRect(hdc, &rc, hbr);
126 }
127
128 ::DeleteObject(hbr);
129}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by GetUpdateRect(), IntBeginPaint(), and RubberTool::OnDraw().

◆ Fill()

void Fill ( HDC  hdc,
LONG  x,
LONG  y,
COLORREF  color 
)

Definition at line 107 of file drawing.cpp.

108{
109 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
111 DeleteObject(SelectObject(hdc, oldBrush));
112}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define FLOODFILLSURFACE
Definition: wingdi.h:645
BOOL WINAPI ExtFloodFill(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF, _In_ UINT)

Referenced by CheckStringBuffer(), CheckStringBufferA(), CheckStringBufferW(), DIB_24BPP_HLine(), FillTool::OnButtonDown(), RtlFillMemory(), RtlFillMemoryUlong(), TuiDrawBox(), and UiDrawBox().

◆ Line()

void Line ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  color,
int  thickness 
)

Definition at line 13 of file drawing.cpp.

14{
15 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
16 MoveToEx(hdc, x1, y1, NULL);
17 LineTo(hdc, x2, y2);
20}
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)

◆ Poly()

void Poly ( HDC  hdc,
POINT lpPoints,
int  nCount,
COLORREF  fg,
COLORREF  bg,
int  thickness,
int  style,
BOOL  closed,
BOOL  inverted 
)

Definition at line 68 of file drawing.cpp.

69{
70 LOGBRUSH logbrush;
71 HBRUSH oldBrush;
72 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
73 UINT oldRop = GetROP2(hdc);
74
75 if (inverted)
77
78 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
79 logbrush.lbColor = (style == 2) ? fg : bg;
80 logbrush.lbHatch = 0;
81 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
82 if (closed)
83 Polygon(hdc, lpPoints, nCount);
84 else
85 Polyline(hdc, lpPoints, nCount);
86 DeleteObject(SelectObject(hdc, oldBrush));
88
89 SetROP2(hdc, oldRop);
90}
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
int WINAPI GetROP2(_In_ HDC)
Definition: dc.c:1093

Referenced by ShapeTool::OnDrawOverlayOnImage(), and FreeSelTool::OnDrawOverlayOnImage().

◆ Rect()

void Rect ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  fg,
COLORREF  bg,
int  thickness,
int  style 
)

Definition at line 23 of file drawing.cpp.

24{
25 HBRUSH oldBrush;
26 LOGBRUSH logbrush;
27 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
28 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
29 logbrush.lbColor = (style == 2) ? fg : bg;
30 logbrush.lbHatch = 0;
31 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
32 Rectangle(hdc, x1, y1, x2, y2);
33 DeleteObject(SelectObject(hdc, oldBrush));
35}

◆ RectSel()

void RectSel ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2 
)

Definition at line 233 of file drawing.cpp.

234{
235 HBRUSH oldBrush;
236 LOGBRUSH logbrush;
237 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_DOT, 1, GetSysColor(COLOR_HIGHLIGHT)));
238 UINT oldRop = GetROP2(hdc);
239
241
242 logbrush.lbStyle = BS_HOLLOW;
243 logbrush.lbColor = 0;
244 logbrush.lbHatch = 0;
245 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
246 Rectangle(hdc, x1, y1, x2, y2);
247 DeleteObject(SelectObject(hdc, oldBrush));
248 DeleteObject(SelectObject(hdc, oldPen));
249
250 SetROP2(hdc, oldRop);
251}
#define PS_DOT
Definition: wingdi.h:588
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_HIGHLIGHT
Definition: winuser.h:929

Referenced by RectSelTool::OnDrawOverlayOnImage(), and TextTool::OnDrawOverlayOnImage().

◆ Replace()

void Replace ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  fg,
COLORREF  bg,
LONG  radius 
)

Definition at line 132 of file drawing.cpp.

133{
134 LONG b = max(1, max(labs(x2 - x1), labs(y2 - y1)));
135
136 for (LONG a = 0; a <= b; a++)
137 {
138 LONG cx = (x1 * (b - a) + x2 * a) / b;
139 LONG cy = (y1 * (b - a) + y2 * a) / b;
140 RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius };
141 for (LONG y = rc.top; y < rc.bottom; ++y)
142 {
143 for (LONG x = rc.left; x < rc.right; ++x)
144 {
145 if (::GetPixel(hdc, x, y) == fg)
146 ::SetPixelV(hdc, x, y, bg);
147 }
148 }
149 }
150}

Referenced by COMDLG32_FR_CheckPartial(), COMDLG32_FR_HandleWMCommand(), RubberTool::OnDraw(), UDFHardLink(), UDFHardLinkFile__(), UDFRename(), and UDFRenameMoveFile__().

◆ RRect()

void RRect ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  fg,
COLORREF  bg,
int  thickness,
int  style 
)

Definition at line 53 of file drawing.cpp.

54{
55 LOGBRUSH logbrush;
56 HBRUSH oldBrush;
57 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
58 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
59 logbrush.lbColor = (style == 2) ? fg : bg;
60 logbrush.lbHatch = 0;
61 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
62 RoundRect(hdc, x1, y1, x2, y2, 16, 16);
63 DeleteObject(SelectObject(hdc, oldBrush));
65}
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by RRectTool::OnDrawOverlayOnImage().

◆ Text()

void Text ( HDC  hdc,
LONG  x1,
LONG  y1,
LONG  x2,
LONG  y2,
COLORREF  fg,
COLORREF  bg,
LPCWSTR  lpchText,
HFONT  font,
LONG  style 
)

Definition at line 254 of file drawing.cpp.

255{
256 INT iSaveDC = ::SaveDC(hdc); // We will modify the clipping region. Save now.
257
258 CRect rc = { x1, y1, x2, y2 };
259
260 if (style == 0) // Transparent
261 {
263 }
264 else // Opaque
265 {
267 ::SetBkColor(hdc, bg);
268
269 HBRUSH hbr = ::CreateSolidBrush(bg);
270 ::FillRect(hdc, &rc, hbr); // Fill the background
271 ::DeleteObject(hbr);
272 }
273
274 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
275
276 HGDIOBJ hFontOld = ::SelectObject(hdc, font);
277 ::SetTextColor(hdc, fg);
278 const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
280 ::DrawTextW(hdc, lpchText, -1, &rc, uFormat);
281 ::SelectObject(hdc, hFontOld);
282
283 ::RestoreDC(hdc, iSaveDC); // Restore
284}
Definition: mk_font.cpp:20
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
#define OPAQUE
Definition: wingdi.h:949
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
int WINAPI SaveDC(_In_ HDC)
#define DT_NOPREFIX
Definition: winuser.h:537
#define DT_NOCLIP
Definition: winuser.h:536
#define DT_LEFT
Definition: winuser.h:534
#define DT_TOP
Definition: winuser.h:542
#define DT_WORDBREAK
Definition: winuser.h:544
#define DT_EXPANDTABS
Definition: winuser.h:532
#define DT_EDITCONTROL
Definition: winuser.h:528