X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fbase%2Fapplications%2Fpaint%2Fdrawing.c;h=bb8d24a40a51e834933e44c97d7192740ee6b3be;hp=d8e6031005c7ceef52c41ee094a25f3753fd94eb;hb=7aa73a611070fa91bb4e66b5d5956a28fe6438db;hpb=7bdc8391f9168fad7cd58803af99c7772dbc71cb diff --git a/reactos/base/applications/paint/drawing.c b/reactos/base/applications/paint/drawing.c index d8e6031005c..bb8d24a40a5 100644 --- a/reactos/base/applications/paint/drawing.c +++ b/reactos/base/applications/paint/drawing.c @@ -20,45 +20,78 @@ void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickn DeleteObject(SelectObject(hdc, oldPen)); } -void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) +void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + HBRUSH oldBrush; LOGBRUSH logbrush; - if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; - logbrush.lbColor = bg; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; + if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } -void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) +void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + HBRUSH oldBrush; LOGBRUSH logbrush; - if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; - logbrush.lbColor = bg; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; + if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Ellipse(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } -void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) +void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); LOGBRUSH logbrush; - if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; - logbrush.lbColor = bg; + HBRUSH oldBrush; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; + if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); RoundRect(hdc, x1, y1, x2, y2, 16, 16); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } +void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed) +{ + LOGBRUSH logbrush; + HBRUSH oldBrush; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); + if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; + if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; + logbrush.lbHatch = 0; + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + if (closed) + Polygon(hdc, lpPoints, nCount); + else + Polyline(hdc, lpPoints, nCount); + DeleteObject(SelectObject(hdc, oldBrush)); + DeleteObject(SelectObject(hdc, oldPen)); +} + +void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness) +{ + HPEN oldPen; + POINT fourPoints[4]; + fourPoints[0] = p1; + fourPoints[1] = p2; + fourPoints[2] = p3; + fourPoints[3] = p4; + oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, color)); + PolyBezier(hdc, fourPoints, 4); + DeleteObject(SelectObject(hdc, oldPen)); +} + void Fill(HDC hdc, int x, int y, int color) { HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); @@ -68,15 +101,25 @@ void Fill(HDC hdc, int x, int y, int color) void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); - HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); short a; + HPEN oldPen; + HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); + oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); for (a=0; a<=100; a++) Rectangle(hdc, (x1*(100-a)+x2*a)/100-radius+1, (y1*(100-a)+y2*a)/100-radius+1, (x1*(100-a)+x2*a)/100+radius+1, (y1*(100-a)+y2*a)/100+radius+1); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } +void Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius) +{ + short a, x, y; + for (a=0; a<=100; a++) + for (y=(y1*(100-a)+y2*a)/100-radius+1; y<(y1*(100-a)+y2*a)/100+radius+1; y++) + for (x=(x1*(100-a)+x2*a)/100-radius+1; x<(x1*(100-a)+x2*a)/100+radius+1; x++) + if (GetPixel(hdc, x, y)==fg) SetPixel(hdc, x, y, bg); +} + void Airbrush(HDC hdc, short x, short y, int color, int r) { short a; @@ -165,12 +208,13 @@ void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style void RectSel(HDC hdc, short x1, short y1, short x2, short y2) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); + HBRUSH oldBrush; LOGBRUSH logbrush; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = 0; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); @@ -178,12 +222,13 @@ void RectSel(HDC hdc, short x1, short y1, short x2, short y2) void SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); + HBRUSH oldBrush; LOGBRUSH logbrush; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = 0; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen));