[英]Convert System.Windows.Media.Brush to System.Drawing.Brush
How can I convert a System.Windows.Media.Brush to System.Drawing.Brush? 如何将System.Windows.Media.Brush转换为System.Drawing.Brush?
I'm trying to get the color of a system.windows.media.brush formatted to a System.Drawing.Color object. 我正在尝试将system.windows.media.brush的颜色格式化为System.Drawing.Color对象。
The below solution doesn't work because it requires a solidcolorbrush object, whereas the object i need converting from is a system.windows.media.brush object: 下面的解决方案不起作用,因为它需要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 );
}
I believe you can just cast it as a SolidColorBrush to get the color. 我相信你可以把它作为SolidColorBrush投射来获得颜色。
Try something like: 尝试类似的东西:
MyColor = ((SolidColorBrush)MyMediaBrush).Color;
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.