views:

80

answers:

3

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

+3  A: 

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.

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);
ChrisF
Nice one thanks!!
Kaya
A: 
    private System.Drawing.Color WpfBrushToDrawingColor(System.Windows.Media.SolidColorBrush br)
    {
        return System.Drawing.Color.FromArgb(
            br.Color.A,
            br.Color.R,
            br.Color.G,
            br.Color.B);
    }
Nir