Fix converting default colors
This commit is contained in:
parent
d2f0dab01c
commit
573b3456bb
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue