2015-05-08 16:02:36 +00:00
|
|
|
/*
|
2023-06-23 11:04:32 +00:00
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
|
|
|
* PURPOSE: The drawing functions used by the tools
|
2023-06-27 18:22:21 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
2015-05-08 16:02:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *********************************************************/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ********************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
Line(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, int thickness)
|
|
|
|
{
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
|
2015-05-08 16:02:36 +00:00
|
|
|
MoveToEx(hdc, x1, y1, NULL);
|
|
|
|
LineTo(hdc, x2, y2);
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Rect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
|
|
|
|
{
|
|
|
|
HBRUSH oldBrush;
|
|
|
|
LOGBRUSH logbrush;
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
2015-05-08 16:02:36 +00:00
|
|
|
logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
|
|
|
|
logbrush.lbColor = (style == 2) ? fg : bg;
|
|
|
|
logbrush.lbHatch = 0;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
2015-05-08 16:02:36 +00:00
|
|
|
Rectangle(hdc, x1, y1, x2, y2);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Ellp(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
|
|
|
|
{
|
|
|
|
HBRUSH oldBrush;
|
|
|
|
LOGBRUSH logbrush;
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
2015-05-08 16:02:36 +00:00
|
|
|
logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
|
|
|
|
logbrush.lbColor = (style == 2) ? fg : bg;
|
|
|
|
logbrush.lbHatch = 0;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
2015-05-08 16:02:36 +00:00
|
|
|
Ellipse(hdc, x1, y1, x2, y2);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
|
|
|
|
{
|
|
|
|
LOGBRUSH logbrush;
|
|
|
|
HBRUSH oldBrush;
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
2015-05-08 16:02:36 +00:00
|
|
|
logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
|
|
|
|
logbrush.lbColor = (style == 2) ? fg : bg;
|
|
|
|
logbrush.lbHatch = 0;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
2015-05-08 16:02:36 +00:00
|
|
|
RoundRect(hdc, x1, y1, x2, y2, 16, 16);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Poly(HDC hdc, POINT * lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
|
|
|
|
{
|
|
|
|
LOGBRUSH logbrush;
|
|
|
|
HBRUSH oldBrush;
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg));
|
2015-05-08 16:02:36 +00:00
|
|
|
UINT oldRop = GetROP2(hdc);
|
|
|
|
|
|
|
|
if (inverted)
|
|
|
|
SetROP2(hdc, R2_NOTXORPEN);
|
|
|
|
|
|
|
|
logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID;
|
|
|
|
logbrush.lbColor = (style == 2) ? fg : bg;
|
|
|
|
logbrush.lbHatch = 0;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
2015-05-08 16:02:36 +00:00
|
|
|
if (closed)
|
|
|
|
Polygon(hdc, lpPoints, nCount);
|
|
|
|
else
|
|
|
|
Polyline(hdc, lpPoints, nCount);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
|
|
|
|
SetROP2(hdc, oldRop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
|
|
|
|
{
|
|
|
|
HPEN oldPen;
|
|
|
|
POINT fourPoints[4];
|
|
|
|
fourPoints[0] = p1;
|
|
|
|
fourPoints[1] = p2;
|
|
|
|
fourPoints[2] = p3;
|
|
|
|
fourPoints[3] = p4;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
|
2015-05-08 16:02:36 +00:00
|
|
|
PolyBezier(hdc, fourPoints, 4);
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Fill(HDC hdc, LONG x, LONG y, COLORREF color)
|
|
|
|
{
|
2015-05-08 16:27:46 +00:00
|
|
|
HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
|
2015-05-08 16:02:36 +00:00
|
|
|
ExtFloodFill(hdc, x, y, GetPixel(hdc, x, y), FLOODFILLSURFACE);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
|
|
|
|
{
|
2023-06-14 08:03:22 +00:00
|
|
|
LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1)));
|
2023-06-14 07:44:54 +00:00
|
|
|
HBRUSH hbr = ::CreateSolidBrush(color);
|
2023-06-14 08:03:22 +00:00
|
|
|
|
|
|
|
for (LONG a = 0; a <= b; a++)
|
|
|
|
{
|
2023-06-14 08:14:41 +00:00
|
|
|
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 };
|
2023-06-14 08:03:22 +00:00
|
|
|
::FillRect(hdc, &rc, hbr);
|
|
|
|
}
|
|
|
|
|
2023-06-14 07:44:54 +00:00
|
|
|
::DeleteObject(hbr);
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius)
|
|
|
|
{
|
2023-06-14 08:03:22 +00:00
|
|
|
LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1)));
|
2015-05-08 16:02:36 +00:00
|
|
|
|
2023-06-14 08:03:22 +00:00
|
|
|
for (LONG a = 0; a <= b; a++)
|
2023-06-14 07:44:54 +00:00
|
|
|
{
|
2023-06-14 08:14:41 +00:00
|
|
|
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 };
|
2023-06-14 08:03:22 +00:00
|
|
|
for (LONG y = rc.top; y < rc.bottom; ++y)
|
2023-06-14 07:44:54 +00:00
|
|
|
{
|
2023-06-14 08:03:22 +00:00
|
|
|
for (LONG x = rc.left; x < rc.right; ++x)
|
|
|
|
{
|
|
|
|
if (::GetPixel(hdc, x, y) == fg)
|
|
|
|
::SetPixelV(hdc, x, y, bg);
|
|
|
|
}
|
2023-06-14 07:44:54 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Airbrush(HDC hdc, LONG x, LONG y, COLORREF color, LONG r)
|
|
|
|
{
|
2023-06-14 07:44:54 +00:00
|
|
|
for (LONG dy = -r; dy <= r; dy++)
|
|
|
|
{
|
|
|
|
for (LONG dx = -r; dx <= r; dx++)
|
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
if ((dx * dx + dy * dy <= r * r) && (rand() % r == 0))
|
2023-06-14 07:44:54 +00:00
|
|
|
::SetPixelV(hdc, x + dx, y + dy, color);
|
|
|
|
}
|
|
|
|
}
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style)
|
|
|
|
{
|
2015-05-08 16:27:46 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, color));
|
|
|
|
HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(color));
|
2015-05-08 16:02:36 +00:00
|
|
|
LONG a, b;
|
|
|
|
b = max(1, max(abs(x2 - x1), abs(y2 - y1)));
|
|
|
|
switch (style)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for(a = 0; a <= b; a++)
|
|
|
|
Ellipse(hdc, (x1 * (b - a) + x2 * a) / b - 3, (y1 * (b - a) + y2 * a) / b - 3,
|
|
|
|
(x1 * (b - a) + x2 * a) / b + 4, (y1 * (b - a) + y2 * a) / b + 4);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
for(a = 0; a <= b; a++)
|
2023-03-21 04:13:53 +00:00
|
|
|
Ellipse(hdc,
|
|
|
|
(x1 * (b - a) + x2 * a) / b - 2,
|
|
|
|
(y1 * (b - a) + y2 * a) / b - 2,
|
|
|
|
(x1 * (b - a) + x2 * a) / b + 2,
|
|
|
|
(y1 * (b - a) + y2 * a) / b + 2);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
MoveToEx(hdc, x1, y1, NULL);
|
|
|
|
LineTo(hdc, x2, y2);
|
2023-06-14 08:42:21 +00:00
|
|
|
::SetPixelV(hdc, x2, y2, color);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
for(a = 0; a <= b; a++)
|
2023-03-21 04:13:53 +00:00
|
|
|
Rectangle(hdc,
|
|
|
|
(x1 * (b - a) + x2 * a) / b - 4,
|
|
|
|
(y1 * (b - a) + y2 * a) / b - 4,
|
|
|
|
(x1 * (b - a) + x2 * a) / b + 4,
|
|
|
|
(y1 * (b - a) + y2 * a) / b + 4);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
for(a = 0; a <= b; a++)
|
|
|
|
Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - 2, (y1 * (b - a) + y2 * a) / b - 2,
|
|
|
|
(x1 * (b - a) + x2 * a) / b + 3, (y1 * (b - a) + y2 * a) / b + 3);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
for(a = 0; a <= b; a++)
|
|
|
|
Rectangle(hdc, (x1 * (b - a) + x2 * a) / b - 1, (y1 * (b - a) + y2 * a) / b - 1,
|
|
|
|
(x1 * (b - a) + x2 * a) / b + 1, (y1 * (b - a) + y2 * a) / b + 1);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
{
|
2023-03-21 04:13:53 +00:00
|
|
|
POINT offsTop[] = {{3, -3}, {2, -2}, {0, 0},
|
|
|
|
{-4, -4}, {-2, -2}, {-1, 0}};
|
|
|
|
POINT offsBtm[] = {{-3, 3}, {-2, 2}, {-1, 1},
|
|
|
|
{3, 3}, {2, 2}, {0, 1}};
|
2015-05-08 16:02:36 +00:00
|
|
|
LONG idx = style - 6;
|
|
|
|
POINT pts[4];
|
|
|
|
pts[0].x = x1 + offsTop[idx].x;
|
|
|
|
pts[0].y = y1 + offsTop[idx].y;
|
|
|
|
pts[1].x = x1 + offsBtm[idx].x;
|
|
|
|
pts[1].y = y1 + offsBtm[idx].y;
|
|
|
|
pts[2].x = x2 + offsBtm[idx].x;
|
|
|
|
pts[2].y = y2 + offsBtm[idx].y;
|
|
|
|
pts[3].x = x2 + offsTop[idx].x;
|
|
|
|
pts[3].y = y2 + offsTop[idx].y;
|
|
|
|
Polygon(hdc, pts, 4);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
|
|
|
|
{
|
|
|
|
HBRUSH oldBrush;
|
|
|
|
LOGBRUSH logbrush;
|
2022-01-05 07:26:05 +00:00
|
|
|
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_DOT, 1, GetSysColor(COLOR_HIGHLIGHT)));
|
2015-05-08 16:02:36 +00:00
|
|
|
UINT oldRop = GetROP2(hdc);
|
|
|
|
|
|
|
|
SetROP2(hdc, R2_NOTXORPEN);
|
|
|
|
|
|
|
|
logbrush.lbStyle = BS_HOLLOW;
|
|
|
|
logbrush.lbColor = 0;
|
|
|
|
logbrush.lbHatch = 0;
|
2015-05-08 16:27:46 +00:00
|
|
|
oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
2015-05-08 16:02:36 +00:00
|
|
|
Rectangle(hdc, x1, y1, x2, y2);
|
|
|
|
DeleteObject(SelectObject(hdc, oldBrush));
|
|
|
|
DeleteObject(SelectObject(hdc, oldPen));
|
|
|
|
|
|
|
|
SetROP2(hdc, oldRop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style)
|
|
|
|
{
|
2022-01-05 07:26:05 +00:00
|
|
|
INT iSaveDC = SaveDC(hdc); // We will modify the clipping region. Save now.
|
|
|
|
|
|
|
|
RECT rc;
|
|
|
|
SetRect(&rc, x1, y1, x2, y2);
|
|
|
|
|
|
|
|
if (style == 0) // Transparent
|
|
|
|
{
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
GetBkColor(hdc);
|
|
|
|
}
|
|
|
|
else // Opaque
|
|
|
|
{
|
|
|
|
SetBkMode(hdc, OPAQUE);
|
|
|
|
SetBkColor(hdc, bg);
|
|
|
|
|
|
|
|
HBRUSH hbr = CreateSolidBrush(bg);
|
|
|
|
FillRect(hdc, &rc, hbr); // Fill the background
|
|
|
|
DeleteObject(hbr);
|
|
|
|
}
|
|
|
|
|
|
|
|
IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
HGDIOBJ hFontOld = SelectObject(hdc, font);
|
|
|
|
SetTextColor(hdc, fg);
|
|
|
|
const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
|
|
|
|
DT_EXPANDTABS | DT_WORDBREAK;
|
|
|
|
DrawText(hdc, lpchText, -1, &rc, uFormat);
|
|
|
|
SelectObject(hdc, hFontOld);
|
|
|
|
|
|
|
|
RestoreDC(hdc, iSaveDC); // Restore
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2022-02-14 07:18:18 +00:00
|
|
|
|
|
|
|
BOOL
|
|
|
|
ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
|
2023-04-01 13:01:04 +00:00
|
|
|
HDC hdcSrc, int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight,
|
|
|
|
HBITMAP hbmMask, COLORREF keyColor)
|
2022-02-14 07:18:18 +00:00
|
|
|
{
|
2023-04-01 13:01:04 +00:00
|
|
|
HDC hTempDC1, hTempDC2;
|
|
|
|
HBITMAP hbmTempColor, hbmTempMask;
|
|
|
|
HGDIOBJ hbmOld1, hbmOld2;
|
|
|
|
|
|
|
|
if (hbmMask == NULL)
|
|
|
|
{
|
|
|
|
if (keyColor == CLR_INVALID)
|
|
|
|
{
|
|
|
|
::StretchBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
|
|
|
|
hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::GdiTransparentBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
|
|
|
|
hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (nWidth == nSrcWidth && nHeight == nSrcHeight && keyColor == CLR_INVALID)
|
|
|
|
{
|
|
|
|
::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
|
|
|
|
hdcSrc, nXSrc, nYSrc, hbmMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hTempDC1 = ::CreateCompatibleDC(hdcDest);
|
|
|
|
hTempDC2 = ::CreateCompatibleDC(hdcDest);
|
|
|
|
hbmTempMask = ::CreateBitmap(nWidth, nHeight, 1, 1, NULL);
|
|
|
|
hbmTempColor = CreateColorDIB(nWidth, nHeight, RGB(255, 255, 255));
|
|
|
|
|
|
|
|
// hbmTempMask <-- hbmMask (stretched)
|
|
|
|
hbmOld1 = ::SelectObject(hTempDC1, hbmMask);
|
|
|
|
hbmOld2 = ::SelectObject(hTempDC2, hbmTempMask);
|
|
|
|
::StretchBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC1, 0, 0, nSrcWidth, nSrcHeight, SRCCOPY);
|
|
|
|
::SelectObject(hTempDC2, hbmOld2);
|
|
|
|
::SelectObject(hTempDC1, hbmOld1);
|
|
|
|
|
|
|
|
hbmOld1 = ::SelectObject(hTempDC1, hbmTempColor);
|
|
|
|
if (keyColor == CLR_INVALID)
|
|
|
|
{
|
|
|
|
// hbmTempColor <-- hdcSrc (stretched)
|
|
|
|
::StretchBlt(hTempDC1, 0, 0, nWidth, nHeight,
|
|
|
|
hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, SRCCOPY);
|
|
|
|
|
|
|
|
// hdcDest <-- hbmTempColor (masked)
|
|
|
|
::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
|
|
|
|
hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// hbmTempColor <-- hdcDest
|
|
|
|
::BitBlt(hTempDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
|
|
|
|
|
|
|
|
// hbmTempColor <-- hdcSrc (color key)
|
|
|
|
::GdiTransparentBlt(hTempDC1, 0, 0, nWidth, nHeight,
|
|
|
|
hdcSrc, nXSrc, nYSrc, nSrcWidth, nSrcHeight, keyColor);
|
|
|
|
|
|
|
|
// hdcDest <-- hbmTempColor (masked)
|
|
|
|
::MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hTempDC1, 0, 0,
|
|
|
|
hbmTempMask, 0, 0, MAKEROP4(SRCCOPY, 0xAA0029));
|
|
|
|
}
|
|
|
|
::SelectObject(hTempDC1, hbmOld1);
|
|
|
|
|
|
|
|
::DeleteObject(hbmTempColor);
|
|
|
|
::DeleteObject(hbmTempMask);
|
|
|
|
::DeleteDC(hTempDC2);
|
|
|
|
::DeleteDC(hTempDC1);
|
|
|
|
|
2022-02-14 07:18:18 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2023-04-08 13:25:27 +00:00
|
|
|
|
|
|
|
void DrawXorRect(HDC hdc, const RECT *prc)
|
|
|
|
{
|
2023-05-31 08:00:05 +00:00
|
|
|
HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 0, RGB(0, 0, 0)));
|
2023-04-08 13:25:27 +00:00
|
|
|
HGDIOBJ oldBrush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH));
|
2023-05-31 08:00:05 +00:00
|
|
|
INT oldRop2 = SetROP2(hdc, R2_NOTXORPEN);
|
2023-04-08 13:25:27 +00:00
|
|
|
::Rectangle(hdc, prc->left, prc->top, prc->right, prc->bottom);
|
|
|
|
::SetROP2(hdc, oldRop2);
|
|
|
|
::SelectObject(hdc, oldBrush);
|
|
|
|
::DeleteObject(::SelectObject(hdc, oldPen));
|
|
|
|
}
|