02-03-2021, 02:14 PM
Hi,
I have a question regarding color spaces in WPF and DXEngine. We've run into some weird issues with converting colors from WPF into SharpDX and during debugging we found these methods (decompiled).
/// <summary>Converts WPF Color to SharpDX Color3</summary>
/// <param name="color">WPF Color</param>
/// <returns>SharpDX Color3</returns>
public static Color3 ToColor3(this System.Windows.Media.Color color) => new Color3((float) color.R 0.003921569f, (float) color.G 0.003921569f, (float) color.B * 0.003921569f);
/// <summary>Converts WPF Color to SharpDX Color4</summary>
/// <param name="color">WPF Color</param>
/// <returns>SharpDX Color4</returns>
public static Color4 ToColor4(this System.Windows.Media.Color color) => new Color4((float) color.R 0.003921569f, (float) color.G 0.003921569f, (float) color.B 0.003921569f, (float) color.A 0.003921569f);
WPF allows creation of colors in 2 color spaces - sRGB and scRGB. I can safely assume that these extension methods take into account only sRGB, but why is there that additional multiplication? From the values it uses we could guess that it might be a PhotoYCC<->RGB conversion, but why it's there?
Best regards,
Janovsky Roman
I have a question regarding color spaces in WPF and DXEngine. We've run into some weird issues with converting colors from WPF into SharpDX and during debugging we found these methods (decompiled).
/// <summary>Converts WPF Color to SharpDX Color3</summary>
/// <param name="color">WPF Color</param>
/// <returns>SharpDX Color3</returns>
public static Color3 ToColor3(this System.Windows.Media.Color color) => new Color3((float) color.R 0.003921569f, (float) color.G 0.003921569f, (float) color.B * 0.003921569f);
/// <summary>Converts WPF Color to SharpDX Color4</summary>
/// <param name="color">WPF Color</param>
/// <returns>SharpDX Color4</returns>
public static Color4 ToColor4(this System.Windows.Media.Color color) => new Color4((float) color.R 0.003921569f, (float) color.G 0.003921569f, (float) color.B 0.003921569f, (float) color.A 0.003921569f);
WPF allows creation of colors in 2 color spaces - sRGB and scRGB. I can safely assume that these extension methods take into account only sRGB, but why is there that additional multiplication? From the values it uses we could guess that it might be a PhotoYCC<->RGB conversion, but why it's there?
Best regards,
Janovsky Roman