diff --git a/Directory.Build.props b/Directory.Build.props index 14c9da79d..0f9c5bdde 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,17 +30,17 @@ @@ -52,6 +52,7 @@ $(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS $(DefineConstants);SUPPORTS_CODECOVERAGE $(DefineConstants);SUPPORTS_HOTPATH + $(DefineConstants);SUPPORTS_CREATESPAN $(DefineConstants);SUPPORTS_MATHF @@ -60,10 +61,12 @@ $(DefineConstants);SUPPORTS_SPAN_STREAM $(DefineConstants);SUPPORTS_ENCODING_STRING $(DefineConstants);SUPPORTS_CODECOVERAGE + $(DefineConstants);SUPPORTS_CREATESPAN $(DefineConstants);SUPPORTS_MATHF $(DefineConstants);SUPPORTS_CODECOVERAGE + $(DefineConstants);SUPPORTS_CREATESPAN $(DefineConstants);SUPPORTS_MATHF @@ -71,6 +74,7 @@ $(DefineConstants);SUPPORTS_SPAN_STREAM $(DefineConstants);SUPPORTS_ENCODING_STRING $(DefineConstants);SUPPORTS_CODECOVERAGE + $(DefineConstants);SUPPORTS_CREATESPAN $(DefineConstants);SUPPORTS_CODECOVERAGE diff --git a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs index 38b902b88..92ba1afd3 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs @@ -109,6 +109,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components /// /// Only for on-stack instances! /// - public Span AsSpanUnsafe() => new Span(Unsafe.AsPointer(ref this), Size); + public Span AsSpanUnsafe() + { +#if SUPPORTS_CREATESPAN + Span> s = MemoryMarshal.CreateSpan(ref this, 1); + return MemoryMarshal.Cast, T>(s); +#else + return new Span(Unsafe.AsPointer(ref this), Size); +#endif + } } }