2010-12-14 107 views
0

我正在使用C#,我正在以編程方式繪製圖片(因爲圖片可能因我的應用程序中參數的運行時間值而異)。我最終得到非通用封閉輪廓(由直線和曲線組成)。現在我需要填充不同顏色的那些。 任何想法我怎麼能做到這一點?着色非通用輪廓

在此先感謝。

+0

出於好奇,在這種情況下,非泛型意味着什麼? – LarsH 2010-12-14 21:56:45

+0

非泛型意義與普通多邊形,圓形,省略號一樣... – Milena 2011-03-23 10:07:41

回答

0

看看flood fill algorithms。你可能最好是繪製到位圖,然後渲染到表單(我假設你使用WinForms)。

0

如果是Winforms我覺得最好的是FillRegion。或者試試Flood Fill。不幸的是,這並不容易,因爲沒有原生的Flood填充.net。但有免費的實施方式和從GDI導入它的方法

0

您可以使用PathGradientBrush這個。 Here's an 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.