如何将System.Windows.Media.Brush转换为System.Drawing.Brush?
我正在尝试将system.windows.media.brush的颜色格式化为System.Drawing.Color对象。
以下解决方案不起作用,因为它需要solidcolorbrush对象,而我需要转换的对象是system.windows.media.brush对象:
public System.Drawing.Color GetColor( System.Windows.Media.SolidColorBrush oBrush )
{
return System.Drawing.Color.FromArgb( oBrush.Color.A,
oBrush.Color.R,
oBrush.Color.G,
oBrush.Color.B );
}
答案 0 :(得分:13)
我相信你可以把它作为SolidColorBrush投射来获得颜色。
尝试类似:
MyColor = ((SolidColorBrush)MyMediaBrush).Color;
答案 1 :(得分:0)
System.Drawing.Color c1 = new System.Drawing.Color();
c1 = System.Drawing.Color.FromName(Properties.Settings.Default.myColor);
System.Windows.Media.Color c2 = new Color();
c2 = Color.FromArgb(c1.A, c1.R, c1.G, c1.B);