How do I convert System.Windows.Media.SolidcolorBrush to System.Drawing.Color?

前端 未结 2 545
死守一世寂寞
死守一世寂寞 2021-01-18 01:04

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

2条回答
  •  梦毁少年i
    2021-01-18 01:47

    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);
    

提交回复
热议问题