How to draw a path (bezier) with fill color using GDI +?

I am doing SVG rendering for Windows using the Windows API and GDI +. SVG allows you to set the style attributes "fill" and "stroke" on the path. I'm having difficulty implementing the fill attribute.

The following path is a spiral:

    <svg:path style="fill:yellow;stroke:blue;stroke-width:2"
              d="M153 334
                C153 334 151 334 151 334
                C151 339 153 344 156 344
                C164 344 171 339 171 334
                C171 322 164 314 156 314
                C142 314 131 322 131 334
                C131 350 142 364 156 364
                C175 364 191 350 191 334
                C191 311 175 294 156 294
                C131 294 111 311 111 334
                C111 361 131 384 156 384
                C186 384 211 361 211 334
                C211 300 186 274 156 274" />

The fill color is yellow and it should fill the whole form, but this is what I get:

enter image description here

My GDI + calls are as follows:

Gdiplus::GraphicsPath bezierPath;
bezierPath.AddBeziers(&gdiplusPoints[0], gdiplusPoints.size());
g.FillPath(&solidBrush, &bezierPath);
g.DrawPath(&pen, &bezierPath);

Apparently, the code is correct for drawing a figure, but not for filling it. Can someone help me figure out what is going wrong?

+3
source share
1 answer

FillMode GraphicsPath FillMode:: Winding, , .

+5

Source: https://habr.com/ru/post/1719233/


All Articles