ReactOS 0.4.15-dev-6703-g6528ab8
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, LPCTSTR 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 155 of file drawing.cpp.

156{
157 for (LONG dy = -r; dy <= r; dy++)
158 {
159 for (LONG dx = -r; dx <= r; dx++)
160 {
161 if ((dx * dx + dy * dy <= r * r) && (rand() % r == 0))
162 ::SetPixelV(hdc, x + dx, y + dy, color);
163 }
164 }
165}
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 AirBrushTool::draw(), and CToolSettingsWindow::drawAirBrush().

◆ Bezier()

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

Definition at line 95 of file drawing.cpp.

96{
97 HPEN oldPen;
98 POINT fourPoints[4];
99 fourPoints[0] = p1;
100 fourPoints[1] = p2;
101 fourPoints[2] = p3;
102 fourPoints[3] = p4;
103 oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
104 PolyBezier(hdc, fourPoints, 4);
105 DeleteObject(SelectObject(hdc, oldPen));
106}
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:1539
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 168 of file drawing.cpp.

169{
170 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, color));
171 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
172
173 if (thickness <= 1)
174 {
175 Line(hdc, x1, y1, x2, y2, color, thickness);
176 }
177 else
178 {
179 LONG a, b = max(1, max(labs(x2 - x1), labs(y2 - y1)));
180 switch ((BrushStyle)style)
181 {
182 case BrushStyleRound:
183 for (a = 0; a <= b; a++)
184 {
185 Ellipse(hdc,
186 (x1 * (b - a) + x2 * a) / b - (thickness / 2),
187 (y1 * (b - a) + y2 * a) / b - (thickness / 2),
188 (x1 * (b - a) + x2 * a) / b + (thickness / 2),
189 (y1 * (b - a) + y2 * a) / b + (thickness / 2));
190 }
191 break;
192
193 case BrushStyleSquare:
194 for (a = 0; a <= b; a++)
195 {
197 (x1 * (b - a) + x2 * a) / b - (thickness / 2),
198 (y1 * (b - a) + y2 * a) / b - (thickness / 2),
199 (x1 * (b - a) + x2 * a) / b + (thickness / 2),
200 (y1 * (b - a) + y2 * a) / b + (thickness / 2));
201 }
202 break;
203
206 {
207 POINT offsetTop, offsetBottom;
209 {
210 offsetTop = { (thickness - 1) / 2, -(thickness - 1) / 2 };
211 offsetBottom = { -thickness / 2, thickness / 2 };
212 }
213 else
214 {
215 offsetTop = { -thickness / 2, -thickness / 2 };
216 offsetBottom = { (thickness - 1) / 2, (thickness - 1) / 2 };
217 }
218 POINT points[4] =
219 {
220 { x1 + offsetTop.x, y1 + offsetTop.y },
221 { x1 + offsetBottom.x, y1 + offsetBottom.y },
222 { x2 + offsetBottom.x, y2 + offsetBottom.y },
223 { x2 + offsetTop.x, y2 + offsetTop.y },
224 };
226 break;
227 }
228 }
229 }
230 DeleteObject(SelectObject(hdc, oldBrush));
231 DeleteObject(SelectObject(hdc, oldPen));
232}
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:68
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 291 of file drawing.cpp.

294{
295 HDC hTempDC1, hTempDC2;
296 HBITMAP hbmTempColor, hbmTempMask;
297 HGDIOBJ hbmOld1, hbmOld2;
298
299 if (hbmMask == NULL)
300 {
301 if (keyColor == CLR_INVALID)
302 {
303 ::StretchBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
304 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
305 }
306 else
307 {
308 ::GdiTransparentBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
309 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
310 }
311 return TRUE;
312 }
313 else if (nWidth == nSrcWidth && nHeight == nSrcHeight && keyColor == CLR_INVALID)
314 {
315 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
316 hdcSrc, nXSrc, nYSrc, hbmMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
317 return TRUE;
318 }
319
320 hTempDC1 = ::CreateCompatibleDC(hdcDest);
321 hTempDC2 = ::CreateCompatibleDC(hdcDest);
322 hbmTempMask = ::CreateBitmap(nWidth, nHeight, 1, 1, NULL);
323 hbmTempColor = CreateColorDIB(nWidth, nHeight, RGB(255, 255, 255));
324
325 // hbmTempMask <-- hbmMask (stretched)
326 hbmOld1 = ::SelectObject(hTempDC1, hbmMask);
327 hbmOld2 = ::SelectObject(hTempDC2, hbmTempMask);
328 ::StretchBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC1, 0, 0, nSrcWidth, nSrcHeight, SRCCOPY);
329 ::SelectObject(hTempDC2, hbmOld2);
330 ::SelectObject(hTempDC1, hbmOld1);
331
332 hbmOld1 = ::SelectObject(hTempDC1, hbmTempColor);
333 if (keyColor == CLR_INVALID)
334 {
335 // hbmTempColor <-- hdcSrc (stretched)
336 ::StretchBlt(hTempDC1, 0, 0, nWidth, nHeight,
337 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
338
339 // hdcDest <-- hbmTempColor (masked)
340 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
341 hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
342 }
343 else
344 {
345 // hbmTempColor <-- hdcDest
346 ::BitBlt(hTempDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
347
348 // hbmTempColor <-- hdcSrc (color key)
349 ::GdiTransparentBlt(hTempDC1, 0, 0, nWidth, nHeight,
350 hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
351
352 // hdcDest <-- hbmTempColor (masked)
353 ::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
354 hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
355 }
356 ::SelectObject(hTempDC1, hbmOld1);
357
358 ::DeleteObject(hbmTempColor);
359 ::DeleteObject(hbmTempMask);
360 ::DeleteDC(hTempDC2);
361 ::DeleteDC(hTempDC1);
362
363 return TRUE;
364}
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 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
#define RGB(r, g, b)
Definition: precomp.h:62
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
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 366 of file drawing.cpp.

367{
368 HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 0, RGB(0, 0, 0)));
370 INT oldRop2 = SetROP2(hdc, R2_NOTXORPEN);
372 ::SetROP2(hdc, oldRop2);
373 ::SelectObject(hdc, oldBrush);
375}
_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:1107

Referenced by CCanvasWindow::DoDraw(), and CCanvasWindow::drawZoomFrame().

◆ Ellp()

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

Definition at line 40 of file drawing.cpp.

41{
42 HBRUSH oldBrush;
43 LOGBRUSH logbrush;
44 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
45 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
46 logbrush.lbColor = (style == 2) ? fg : bg;
47 logbrush.lbHatch = 0;
48 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
49 Ellipse(hdc, x1, y1, x2, y2);
50 DeleteObject(SelectObject(hdc, oldBrush));
52}
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 117 of file drawing.cpp.

118{
119 LONG b = max(1, max(labs(x2 - x1), labs(y2 - y1)));
120 HBRUSH hbr = ::CreateSolidBrush(color);
121
122 for (LONG a = 0; a <= b; a++)
123 {
124 LONG cx = (x1 * (b - a) + x2 * a) / b;
125 LONG cy = (y1 * (b - a) + y2 * a) / b;
126 RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius };
127 ::FillRect(hdc, &rc, hbr);
128 }
129
130 ::DeleteObject(hbr);
131}
_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 RubberTool::draw(), GetUpdateRect(), and IntBeginPaint().

◆ Fill()

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

Definition at line 109 of file drawing.cpp.

110{
111 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
113 DeleteObject(SelectObject(hdc, oldBrush));
114}
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 15 of file drawing.cpp.

16{
17 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
18 MoveToEx(hdc, x1, y1, NULL);
19 LineTo(hdc, x2, y2);
22}
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 70 of file drawing.cpp.

71{
72 LOGBRUSH logbrush;
73 HBRUSH oldBrush;
74 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
75 UINT oldRop = GetROP2(hdc);
76
77 if (inverted)
79
80 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
81 logbrush.lbColor = (style == 2) ? fg : bg;
82 logbrush.lbHatch = 0;
83 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
84 if (closed)
85 Polygon(hdc, lpPoints, nCount);
86 else
87 Polyline(hdc, lpPoints, nCount);
88 DeleteObject(SelectObject(hdc, oldBrush));
90
91 SetROP2(hdc, oldRop);
92}
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:1086

Referenced by SelectionModel::DrawFramePoly(), and ShapeTool::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 25 of file drawing.cpp.

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

◆ RectSel()

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

Definition at line 235 of file drawing.cpp.

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

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 134 of file drawing.cpp.

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

Referenced by COMDLG32_FR_CheckPartial(), COMDLG32_FR_HandleWMCommand(), RubberTool::draw(), 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 55 of file drawing.cpp.

56{
57 LOGBRUSH logbrush;
58 HBRUSH oldBrush;
59 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
60 logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
61 logbrush.lbColor = (style == 2) ? fg : bg;
62 logbrush.lbHatch = 0;
63 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
64 RoundRect(hdc, x1, y1, x2, y2, 16, 16);
65 DeleteObject(SelectObject(hdc, oldBrush));
67}
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,
LPCTSTR  lpchText,
HFONT  font,
LONG  style 
)

Definition at line 256 of file drawing.cpp.

257{
258 INT iSaveDC = SaveDC(hdc); // We will modify the clipping region. Save now.
259
260 RECT rc;
261 SetRect(&rc, x1, y1, x2, y2);
262
263 if (style == 0) // Transparent
264 {
267 }
268 else // Opaque
269 {
271 SetBkColor(hdc, bg);
272
273 HBRUSH hbr = CreateSolidBrush(bg);
274 FillRect(hdc, &rc, hbr); // Fill the background
275 DeleteObject(hbr);
276 }
277
278 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
279
280 HGDIOBJ hFontOld = SelectObject(hdc, font);
281 SetTextColor(hdc, fg);
282 const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
284 DrawText(hdc, lpchText, -1, &rc, uFormat);
285 SelectObject(hdc, hFontOld);
286
287 RestoreDC(hdc, iSaveDC); // Restore
288}
Definition: mk_font.cpp:20
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)
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
#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 DrawText
Definition: winuser.h:5761
#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
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)