1. 程式人生 > >WinForm和WPF顏色對象的轉換

WinForm和WPF顏色對象的轉換

name pub public winform wpf dia ring edit -c

原文:WinForm和WPF顏色對象的轉換

版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/huangli321456/article/details/52956846 ?? /// <summary>
??????? /// 將wpf的顏色對象轉換為整型的Winform顏色值
??????? /// </summary>
??????? /// <param name="brush"></param>
??????? /// <returns></returns>
??????? public static String ConvertWpfBrushToWFColorArgb(media.SolidColorBrush brush)
??????? {
??????????? return (brush.Color.A << 24 | brush.Color.R << 16 | brush.Color.G << 8 | brush.Color.B).ToString();
??????? }
??????? /// <summary>
??????? /// 將來自winform的argb整型顏色值轉換為wpf顏色對象
??????? /// </summary>
??????? /// <param name="wfargb"></param>
??????? /// <returns></returns>
??????? public static System.Windows.Media.SolidColorBrush ConvertWFColorToWfpBrush(int wfargb)
??????? {
??????????? return new System.Windows.Media.SolidColorBrush()
??????????? {
??????????????? Color = new media.Color()
??????????????? {
??????????????????? A = (byte)((wfargb >> 24) & 0xFF),
??????????????????? R = (byte)((wfargb >> 16) & 0xFF),
??????????????????? G = (byte)((wfargb >> 8) & 0xFF),
??????????????????? B = (byte)(wfargb & 0xFF)
??????????????? }
??????????? };
??????? }

WinForm和WPF顏色對象的轉換