Fix converting default colors

This commit is contained in:
Frank A. Krueger 2018-04-18 15:06:51 -07:00
parent d2f0dab01c
commit 573b3456bb
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
1 changed files with 9 additions and 1 deletions

View File

@ -6,7 +6,15 @@ namespace Ooui.Forms.Extensions
{
public static Color ToOouiColor (this Xamarin.Forms.Color color)
{
return new Color ((byte)(color.R * 255.0 + 0.5), (byte)(color.G * 255.0 + 0.5), (byte)(color.B * 255.0 + 0.5), (byte)(color.A * 255.0 + 0.5));
const byte defaultRed = 0;
const byte defaultGreen = 0;
const byte defaultBlue = 0;
const byte defaultAlpha = 255;
byte r = color.R < 0 ? defaultRed : (byte)(color.R * 255.0 + 0.5);
byte g = color.G < 0 ? defaultGreen : (byte)(color.G * 255.0 + 0.5);
byte b = color.B < 0 ? defaultBlue : (byte)(color.B * 255.0 + 0.5);
byte a = color.A < 0 ? defaultAlpha : (byte)(color.A * 255.0 + 0.5);
return new Color (r, g, b, a);
}
public static Color ToOouiColor (this Xamarin.Forms.Color color, Xamarin.Forms.Color defaultColor)