Convert DrawingImage into Geometry

时间:2015-07-29 00:38:58

标签: wpf xaml geometry resourcedictionary pathgeometry

I have several DrawingImages that were created in a ResourceDictionary (in a .xaml file).
I also have a 'Path', that I want to set its 'Data' property. So, I want to 1) Get access to a Resource 2) Cast it to DrawingImage 3) Manipulate it to the point where I can get access to the Geometry that draws it. 4) Store that Geometry in Path.Data

2 个答案:

答案 0 :(得分:1)

IF DrawingImage.Drawing是GeometryDrawing类型,那么你可以尝试获取GeometryDrawing.Geometry并从中获取数据。

IF Geometry的类型为PathGeometry,您可以获取Numbers属性并尝试使用它。 PathGeometry.Figures和Path.Data几乎是一回事。

你提出的问题是巨大的。有许多不同的可能性,需要编写大量代码来解决问题。

答案 1 :(得分:0)

您可以非常轻松地从资源中加载"true"

(1)和(2)在你的帖子中:

DrawingImage

我列出了var dImage = Application.Current.Resources["someImage"] as DrawimgImage; var dBrush = Application.Current.Resources["someBrush"] as DrawimgBrush; DrawingImage,因为有些工具以单向保存,有些保存,但内部DrawingBrush在此对话中是相同的。

您可以使用Drawing开始访问下降,但是从那里开始挖掘,您所做的更改取决于您。您可能会发现更容易创建新的dImage.Drawing并将路径数据设置到其中,然后使用此新GeometryDrawing替换Drawing的内容。