diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 99458d58a1..3af3e04f07 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -3,6 +3,7 @@ using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp; @@ -124,7 +125,9 @@ public readonly partial struct Color : IEquatable { return new((L16)(object)pixel); } - else if (Unsafe.SizeOf() <= Unsafe.SizeOf()) + + PixelTypeInfo info = TPixel.GetPixelTypeInfo(); + if (info.ComponentPrecision <= PixelComponentPrecision.Byte) { Rgba32 p = default; pixel.ToRgba32(ref p);