如何转换System.Windows.Media.SolidcolorBrush到的System.Drawing.Color?Media、Windows、System、Color

2023-09-05 00:28:20 作者:一剑飙血

我需要一个System.Windows.Media.SolidcolorBrush转换为C#一个System.Drawing.Color任何线索将是巨大的。

I need to convert a System.Windows.Media.SolidcolorBrush to a System.Drawing.Color in C# any clues would be great.

推荐答案

您可以使用SolidColorBrush.Color要获取或设置的颜色。这是一个System.Windows.Media.Color其中有A,R,G,B的属性。

You can use SolidColorBrush.Color to get or set the colour. This is a System.Windows.Media.Color which has A, R, G, B properties.

在创建时,您就可以使用这些值的System.Drawing.Color

You can then use those values when creating your System.Drawing.Color

System.Drawing.Color myColor = System.Drawing.Color.FromArgb(mediaColor.Color.A,
                                                             mediaColor.Color.R,
                                                             mediaColor.Color.G,
                                                             mediaColor.Color.B);