diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index d55dfced7..f669a7ad9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components { GuardBlockIndex(idx); ref float selfRef = ref Unsafe.As(ref this); - return Unsafe.Add(ref selfRef, idx); + return Unsafe.Add(ref selfRef, (nint)(uint)idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components { GuardBlockIndex(idx); ref float selfRef = ref Unsafe.As(ref this); - Unsafe.Add(ref selfRef, idx) = value; + Unsafe.Add(ref selfRef, (nint)(uint)idx) = value; } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbForwardConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbForwardConverter{TPixel}.cs index 7fad63e11..0be1076e2 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbForwardConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbForwardConverter{TPixel}.cs @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder for (int i = 0; i < Block8x8F.Size; i++) { - Rgb24 c = Unsafe.Add(ref rgbStart, i); + Rgb24 c = Unsafe.Add(ref rgbStart, (nint)(uint)i); redBlock[i] = c.R; greenBlock[i] = c.G; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 14e7cc677..270a11ed6 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -567,14 +567,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg // This uses a C#'s compiler optimization that refers to the static data segment of the assembly, // and doesn't incur any allocation at all. // "default" to 4:2:0 - ReadOnlySpan subsamples = stackalloc byte[] + ReadOnlySpan subsamples = new byte[] { 0x22, 0x11, 0x11 }; - ReadOnlySpan chroma = stackalloc byte[] + ReadOnlySpan chroma = new byte[] { 0x00, 0x01, @@ -583,7 +583,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg if (this.colorType == JpegColorType.Luminance) { - subsamples = stackalloc byte[] + subsamples = new byte[] { 0x11, 0x00, @@ -596,7 +596,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg { case JpegColorType.YCbCrRatio444: case JpegColorType.Rgb: - subsamples = stackalloc byte[] + subsamples = new byte[] { 0x11, 0x11, @@ -605,7 +605,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg if (this.colorType == JpegColorType.Rgb) { - chroma = stackalloc byte[] + chroma = new byte[] { 0x00, 0x00, @@ -615,7 +615,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg break; case JpegColorType.YCbCrRatio420: - subsamples = stackalloc byte[] + subsamples = new byte[] { 0x22, 0x11, @@ -658,7 +658,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg { // This uses a C#'s compiler optimization that refers to the static data segment of the assembly, // and doesn't incur any allocation at all. - ReadOnlySpan huffmanId = stackalloc byte[] + ReadOnlySpan huffmanId = new byte[] { 0x00, 0x11, @@ -668,7 +668,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg // Use the same DC/AC tables for all channels for RGB. if (this.colorType == JpegColorType.Rgb) { - huffmanId = stackalloc byte[] + huffmanId = new byte[] { 0x00, 0x00,