【问题标题】:Coloring non generic contours着色非通用轮廓
【发布时间】:2010-12-14 12:29:11
【问题描述】:

我正在使用 C# 并以编程方式绘制图片(因为图片可能会根据我的应用程序中参数的运行时值而有所不同)。我最终得到非通用闭合轮廓(由直线和曲线组成)。现在我需要用不同的颜色填充它们。 知道我该怎么做吗?

提前致谢。

【问题讨论】:

  • 出于好奇,在这种情况下非泛型是什么意思?
  • 非泛型意味着与普通的多边形、圆形、省略号...

标签: c# graphics


【解决方案1】:

看看flood fill algorithms。您最好先绘制位图,然后渲染到表单(我假设您使用的是 WinForms)。

【讨论】:

    【解决方案2】:

    如果是 Winforms,我认为最好的是 FillRegion。或者试试Flood Fill。不幸的是,这并不容易,因为 .net 中没有本地 Flood 填充。但是有免费的实现和从 GDI 导入它的方法

    【讨论】:

      【解决方案3】:

      您可以为此使用PathGradientBrushHere's a code example.

      Public NotInheritable Class PathGradientBrush
                Inherits System.Drawing.Brush
           Member of System.Drawing.Drawing2D
      Summary:
      Encapsulates a System.Drawing.Brush object that fills the interior of a System.Drawing.Drawing2D.GraphicsPath object with a gradient. This class cannot be inherited.
      

      【讨论】:

        猜你喜欢
        • 2018-03-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多