如何使用GDI +绘制具有填充颜色的(贝塞尔)路径?
问题描述:
我正在使用Windows API和GDI +为Windows制作SVG渲染器。 SVG允许在Path上设置'fill'和'stroke'样式属性。我在实现'fill'属性时遇到了一些困难。如何使用GDI +绘制具有填充颜色的(贝塞尔)路径?
以下路径表示螺旋:
<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" />
填充颜色是黄色,它应该填充整个形状,这可是我得到什么:
我的GDI +看起来像这样的电话:
Gdiplus::GraphicsPath bezierPath;
bezierPath.AddBeziers(&gdiplusPoints[0], gdiplusPoints.size());
g.FillPath(&solidBrush, &bezierPath);
g.DrawPath(&pen, &bezierPath);
Appa代码是正确的绘制形状,但不填充它。任何人都可以帮助我弄清楚发生了什么问题吗?
答
尝试将GraphicsPath的FillMode属性设置为FillMode :: Winding,这是一种适合您需要的替代填充方法。
我刚刚发现自己,典型的:S 但谢谢! – StackedCrooked