diff --git a/Samples/Samples.Mac/Samples.Mac.csproj b/Samples/Samples.Mac/Samples.Mac.csproj index 88774546a..0418848b8 100644 --- a/Samples/Samples.Mac/Samples.Mac.csproj +++ b/Samples/Samples.Mac/Samples.Mac.csproj @@ -54,6 +54,7 @@ + diff --git a/Xamarin.Essentials/Types/PlatformExtensions/ColorExtensions.macos.cs b/Xamarin.Essentials/Types/PlatformExtensions/ColorExtensions.macos.cs index cd3b01020..ec39fbdb5 100644 --- a/Xamarin.Essentials/Types/PlatformExtensions/ColorExtensions.macos.cs +++ b/Xamarin.Essentials/Types/PlatformExtensions/ColorExtensions.macos.cs @@ -11,6 +11,10 @@ public static Color ToSystemColor(this NSColor color) if (color == null) throw new ArgumentNullException(nameof(color)); + // make sure the colorspace is valid for RGBA + // we can't check as the check will throw if it is invalid + color = color.UsingColorSpace(NSColorSpace.SRGBColorSpace); + color.GetRgba(out var red, out var green, out var blue, out var alpha); return Color.FromArgb((int)(alpha * 255), (int)(red * 255), (int)(green * 255), (int)(blue * 255)); }