這兩個表達式應該導致顏色大致相同嗎?FromArgb vs FromScRgb
Color.FromArgb(255, 255, 255, (byte)0.25 * 255))
Color.FromScRgb(1.0f, 1.0f, 1.0f, 0.25f))
這個測試程序表明,他們表現出了看似不同的α值:
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))
});
}
}
}
這裏的演示程序是什麼樣子我的系統上:
什麼是像那樣的映射 - 某種伽馬曲線? –