【问题标题】:How to draw a (bezier) path with a fill color using GDI+?如何使用 GDI+ 绘制带有填充颜色的(贝塞尔)路径?
【发布时间】:2010-12-03 19:19:54
【问题描述】:

我正在使用 Windows API 和 GDI+ 为 Windows 制作 SVG 渲染器。 SVG 允许在路径上设置“填充”和“描边”样式属性。我在实现“填充”属性时遇到了一些困难。

以下路径代表一个螺旋:

    <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);

显然代码对于绘制形状是正确的,但对于填充它是不正确的。谁能帮我找出问题所在?

【问题讨论】:

    标签: c++ graphics gdi+ svg


    【解决方案1】:

    尝试将 GraphicsPath 的 FillMode 属性设置为 FillMode::Winding,这是一种适合您需要的替代填充方法。

    【讨论】:

      猜你喜欢
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      • 2015-08-19
      • 1970-01-01
      • 2018-11-26
      • 1970-01-01
      • 2011-02-26
      相关资源
      最近更新 更多