ReactOS 0.4.15-dev-6656-gbbb33a6
drawing.h File Reference
This graph shows which files directly or indirectly include this file:

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

155{
156 for (LONG dy = -r; dy <= r; dy++)
157 {
158 for (LONG dx = -r; dx <= r; dx++)
159 {
160 if ((dx * dx + dy * dy <= r * r) && (rand() % r == 0))
161 ::SetPixelV(hdc, x + dx, y + dy, color);
162 }
163 }
164}
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 94 of file drawing.cpp.

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

Definition at line 167 of file drawing.cpp.

168{
169 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, color));
170 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
171 LONG a, b;
172 b = max(1, max(abs(x2 - x1), abs(y2 - y1)));
173 switch (style)
174 {
175 case 0:
176 for(a = 0; a <= b; a++)
177 Ellipse(hdc, (x1 * (b - a) + x2 * a) / b - 3, (y1 * (b - a) + y2 * a) / b - 3,
178 (x1 * (b - a) + x2 * a) / b + 4, (y1 * (b - a) + y2 * a) / b + 4);
179 break;
180 case 1:
181 for(a = 0; a <= b; a++)
182 Ellipse(hdc,
183 (x1 * (b - a) + x2 * a) / b - 2,
184 (y1 * (b - a) + y2 * a) / b - 2,
185 (x1 * (b - a) + x2 * a) / b + 2,
186 (y1 * (b - a) + y2 * a) / b + 2);
187 break;
188 case 2:
189 MoveToEx(hdc, x1, y1, NULL);
190 LineTo(hdc, x2, y2);
192 break;
193 case 3:
194 for(a = 0; a <= b; a++)
196 (x1 * (b - a) + x2 * a) / b - 4,
197 (y1 * (b - a) + y2 * a) / b - 4,
198 (x1 * (b - a) + x2 * a) / b + 4,
199 (y1 * (b - a) + y2 * a) / b + 4);
200 break;
201 case 4:
202 for(a = 0; a <= b; a++)
203 Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - 2, (y1 * (b - a) + y2 * a) / b - 2,
204 (x1 * (b - a) + x2 * a) / b + 3, (y1 * (b - a) + y2 * a) / b + 3);
205 break;
206 case 5:
207 for(a = 0; a <= b; a++)
208 Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - 1, (y1 * (b - a) + y2 * a) / b - 1,
209 (x1 * (b - a) + x2 * a) / b + 1, (y1 * (b - a) + y2 * a) / b + 1);
210 break;
211 case 6:
212 case 7:
213 case 8:
214 case 9:
215 case 10:
216 case 11:
217 {
218 POINT offsTop[] = {{3, -3}, {2, -2}, {0, 0},
219 {-4, -4}, {-2, -2}, {-1, 0}};
220 POINT offsBtm[] = {{-3, 3}, {-2, 2}, {-1, 1},
221 {3, 3}, {2, 2}, {0, 1}};
222 LONG idx = style - 6;
223 POINT pts[4];
224 pts[0].x = x1 + offsTop[idx].x;
225 pts[0].y = y1 + offsTop[idx].y;
226 pts[1].x = x1 + offsBtm[idx].x;
227 pts[1].y = y1 + offsBtm[idx].y;
228 pts[2].x = x2 + offsBtm[idx].x;
229 pts[2].y = y2 + offsBtm[idx].y;
230 pts[3].x = x2 + offsTop[idx].x;
231 pts[3].y = y2 + offsTop[idx].y;
232 Polygon(hdc, pts, 4);
233 break;
234 }
235 }
236 DeleteObject(SelectObject(hdc, oldBrush));
237 DeleteObject(SelectObject(hdc, oldPen));
238}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
#define abs(i)
Definition: fconv.c:206
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#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
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define max(a, b)
Definition: svc.c:63
_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 MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)

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

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

373{
374 HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 0, RGB(0, 0, 0)));
376 INT oldRop2 = SetROP2(hdc, R2_NOTXORPEN);
378 ::SetROP2(hdc, oldRop2);
379 ::SelectObject(hdc, oldBrush);
381}
_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 39 of file drawing.cpp.

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

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

109{
110 HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
112 DeleteObject(SelectObject(hdc, oldBrush));
113}
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);
21}

◆ Poly()

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

Definition at line 69 of file drawing.cpp.

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

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

◆ RectSel()

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

Definition at line 241 of file drawing.cpp.

242{
243 HBRUSH oldBrush;
244 LOGBRUSH logbrush;
245 HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_DOT, 1, GetSysColor(COLOR_HIGHLIGHT)));
246 UINT oldRop = GetROP2(hdc);
247
249
250 logbrush.lbStyle = BS_HOLLOW;
251 logbrush.lbColor = 0;
252 logbrush.lbHatch = 0;
253 oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
254 Rectangle(hdc, x1, y1, x2, y2);
255 DeleteObject(SelectObject(hdc, oldBrush));
256 DeleteObject(SelectObject(hdc, oldPen));
257
258 SetROP2(hdc, oldRop);
259}
#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 133 of file drawing.cpp.

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

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

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

263{
264 INT iSaveDC = SaveDC(hdc); // We will modify the clipping region. Save now.
265
266 RECT rc;
267 SetRect(&rc, x1, y1, x2, y2);
268
269 if (style == 0) // Transparent
270 {
273 }
274 else // Opaque
275 {
277 SetBkColor(hdc, bg);
278
279 HBRUSH hbr = CreateSolidBrush(bg);
280 FillRect(hdc, &rc, hbr); // Fill the background
281 DeleteObject(hbr);
282 }
283
284 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
285
286 HGDIOBJ hFontOld = SelectObject(hdc, font);
287 SetTextColor(hdc, fg);
288 const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
290 DrawText(hdc, lpchText, -1, &rc, uFormat);
291 SelectObject(hdc, hFontOld);
292
293 RestoreDC(hdc, iSaveDC); // Restore
294}
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)