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

前端 未结 2 544
死守一世寂寞
死守一世寂寞 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条回答
  • 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);
    
    0 讨论(0)
  • 2021-01-18 01:53
        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);
        }
    
    0 讨论(0)
提交回复
热议问题