Should these two expressions result in colors which are roughly the same?
Color.FromArgb(255, 255, 255, (byte)0.25 * 255))
Color.FromScRgb(1.0f, 1.0f, 1.0f, 0.25f))
This test program demonstrates that they show up with seemingly different alpha values:
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace Test_FromArgb_FromScRbg
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var panel = new StackPanel();
Content = panel;
panel.Children.Add(
new Rectangle()
{
Width = 100,
Height = 100,
Fill = new SolidColorBrush(
Color.FromArgb(
255,
255,
255,
(byte)0.25 * 255))
});
panel.Children.Add(
new Rectangle()
{
Width = 100,
Height = 100,
Fill = new SolidColorBrush(
Color.FromScRgb(
1.0f,
1.0f,
1.0f,
0.25f))
});
}
}
}
Here's what the demo program looks like on my system:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…