diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 49c18db34..0482b2691 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -346,11 +346,11 @@ namespace ImageSharp.Formats if (this.bytesPerPixel == 4) { - PixelOperations.Instance.ToXyzwBytes(rowSpan, this.rawScanline, 0, this.width); + PixelOperations.Instance.ToXyzwBytes(rowSpan, this.rawScanline, this.width); } else { - PixelOperations.Instance.ToXyzBytes(rowSpan, this.rawScanline, 0, this.width); + PixelOperations.Instance.ToXyzBytes(rowSpan, this.rawScanline, this.width); } } diff --git a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs index f4c7c7642..a54c03b63 100644 --- a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs @@ -348,10 +348,8 @@ namespace ImageSharp for (int y = 0; y < height; y++) { Span source = this.GetRowSpan(sourceX, sourceY + y); - using (Buffer destination = new Buffer(area.Bytes)) - { - Operations.ToZyxBytes(source, destination, y * area.RowStride, width); - } + Span destination = area.GetRowSpan(y); + Operations.ToZyxBytes(source, destination, width); } } @@ -369,10 +367,8 @@ namespace ImageSharp for (int y = 0; y < height; y++) { Span source = this.GetRowSpan(sourceX, sourceY + y); - using (Buffer destination = new Buffer(area.Bytes)) - { - Operations.ToZyxwBytes(source, destination, y * area.RowStride, width); - } + Span destination = area.GetRowSpan(y); + Operations.ToZyxwBytes(source, destination, width); } } @@ -390,10 +386,8 @@ namespace ImageSharp for (int y = 0; y < height; y++) { Span source = this.GetRowSpan(sourceX, sourceY + y); - using (Buffer destination = new Buffer(area.Bytes)) - { - Operations.ToXyzBytes(source, destination, y * area.RowStride, width); - } + Span destination = area.GetRowSpan(y); + Operations.ToXyzBytes(source, destination, width); } } @@ -411,10 +405,8 @@ namespace ImageSharp for (int y = 0; y < height; y++) { Span source = this.GetRowSpan(sourceX, sourceY + y); - using (Buffer destination = new Buffer(area.Bytes)) - { - Operations.ToXyzwBytes(source, destination, y * area.RowStride, width); - } + Span destination = area.GetRowSpan(y); + Operations.ToXyzwBytes(source, destination, width); } } diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs index ac2627701..c184ed9cf 100644 --- a/src/ImageSharp/PixelFormats/Alpha8.cs +++ b/src/ImageSharp/PixelFormats/Alpha8.cs @@ -87,7 +87,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { bytes[startIndex] = 0; bytes[startIndex + 1] = 0; @@ -96,7 +96,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { bytes[startIndex] = 0; bytes[startIndex + 1] = 0; @@ -106,7 +106,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { bytes[startIndex] = 0; bytes[startIndex + 1] = 0; @@ -115,7 +115,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { bytes[startIndex] = 0; bytes[startIndex + 1] = 0; diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs index 61e860aee..bd47f72f9 100644 --- a/src/ImageSharp/PixelFormats/Argb32.cs +++ b/src/ImageSharp/PixelFormats/Argb32.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -241,7 +242,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { bytes[startIndex] = this.R; bytes[startIndex + 1] = this.G; @@ -250,7 +251,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { bytes[startIndex] = this.R; bytes[startIndex + 1] = this.G; @@ -260,7 +261,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { bytes[startIndex] = this.B; bytes[startIndex + 1] = this.G; @@ -269,7 +270,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { bytes[startIndex] = this.B; bytes[startIndex + 1] = this.G; diff --git a/src/ImageSharp/PixelFormats/Bgr565.cs b/src/ImageSharp/PixelFormats/Bgr565.cs index 813b6fe85..92bbac14c 100644 --- a/src/ImageSharp/PixelFormats/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/Bgr565.cs @@ -110,7 +110,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)MathF.Round(vector.X); @@ -120,7 +120,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)MathF.Round(vector.X); @@ -131,7 +131,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)MathF.Round(vector.Z); @@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)MathF.Round(vector.Z); diff --git a/src/ImageSharp/PixelFormats/Bgra4444.cs b/src/ImageSharp/PixelFormats/Bgra4444.cs index 8fb2d0c26..0bac00dfe 100644 --- a/src/ImageSharp/PixelFormats/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/Bgra4444.cs @@ -101,7 +101,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.X; @@ -111,7 +111,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.X; @@ -122,7 +122,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.Z; @@ -132,7 +132,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.Z; diff --git a/src/ImageSharp/PixelFormats/Bgra5551.cs b/src/ImageSharp/PixelFormats/Bgra5551.cs index 26cfa6b8c..f151db644 100644 --- a/src/ImageSharp/PixelFormats/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/Bgra5551.cs @@ -101,7 +101,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.X; @@ -111,7 +111,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.X; @@ -122,7 +122,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.Z; @@ -132,7 +132,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; bytes[startIndex] = (byte)vector.Z; diff --git a/src/ImageSharp/PixelFormats/Byte4.cs b/src/ImageSharp/PixelFormats/Byte4.cs index 951b7c3cb..264bc7497 100644 --- a/src/ImageSharp/PixelFormats/Byte4.cs +++ b/src/ImageSharp/PixelFormats/Byte4.cs @@ -102,7 +102,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); bytes[startIndex] = (byte)vector.X; @@ -112,7 +112,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); bytes[startIndex] = (byte)vector.X; @@ -123,7 +123,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); bytes[startIndex] = (byte)vector.Z; @@ -133,7 +133,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); bytes[startIndex] = (byte)vector.Z; diff --git a/src/ImageSharp/PixelFormats/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs index e9f02d34e..4cc9acc22 100644 --- a/src/ImageSharp/PixelFormats/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/HalfSingle.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -110,7 +111,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -124,7 +125,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -139,7 +140,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; diff --git a/src/ImageSharp/PixelFormats/HalfVector2.cs b/src/ImageSharp/PixelFormats/HalfVector2.cs index 8813fd455..f490f7169 100644 --- a/src/ImageSharp/PixelFormats/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/HalfVector2.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -124,7 +125,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -138,7 +139,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -167,7 +168,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; diff --git a/src/ImageSharp/PixelFormats/HalfVector4.cs b/src/ImageSharp/PixelFormats/HalfVector4.cs index e8c78047e..7c496c161 100644 --- a/src/ImageSharp/PixelFormats/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/HalfVector4.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -117,7 +118,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -131,7 +132,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -146,7 +147,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; @@ -160,7 +161,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= MaxBytes; diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs index 9a8d9730a..030cb93f4 100644 --- a/src/ImageSharp/PixelFormats/IPixel.cs +++ b/src/ImageSharp/PixelFormats/IPixel.cs @@ -56,7 +56,7 @@ namespace ImageSharp.PixelFormats /// /// The bytes to set the color in. /// The starting index of the . - void ToXyzBytes(byte[] bytes, int startIndex); + void ToXyzBytes(Span bytes, int startIndex); /// /// Expands the packed representation into a given byte array. @@ -64,7 +64,7 @@ namespace ImageSharp.PixelFormats /// /// The bytes to set the color in. /// The starting index of the . - void ToXyzwBytes(byte[] bytes, int startIndex); + void ToXyzwBytes(Span bytes, int startIndex); /// /// Expands the packed representation into a given byte array. @@ -72,7 +72,7 @@ namespace ImageSharp.PixelFormats /// /// The bytes to set the color in. /// The starting index of the . - void ToZyxBytes(byte[] bytes, int startIndex); + void ToZyxBytes(Span bytes, int startIndex); /// /// Expands the packed representation into a given byte array. @@ -80,6 +80,6 @@ namespace ImageSharp.PixelFormats /// /// The bytes to set the color in. /// The starting index of the . - void ToZyxwBytes(byte[] bytes, int startIndex); + void ToZyxwBytes(Span bytes, int startIndex); } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/NormalizedByte2.cs index 93226342e..47a4f3005 100644 --- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs @@ -134,7 +134,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -150,7 +150,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -167,7 +167,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -183,7 +183,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; diff --git a/src/ImageSharp/PixelFormats/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/NormalizedByte4.cs index 66a79fefc..4559bd082 100644 --- a/src/ImageSharp/PixelFormats/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/NormalizedByte4.cs @@ -127,7 +127,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -143,7 +143,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -160,7 +160,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -176,7 +176,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; diff --git a/src/ImageSharp/PixelFormats/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/NormalizedShort2.cs index 99e5a98c0..648b68905 100644 --- a/src/ImageSharp/PixelFormats/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/NormalizedShort2.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -120,7 +121,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -136,7 +137,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -153,7 +154,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -169,7 +170,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; diff --git a/src/ImageSharp/PixelFormats/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/NormalizedShort4.cs index 932ab97cf..7b520aace 100644 --- a/src/ImageSharp/PixelFormats/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/NormalizedShort4.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -128,7 +129,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -144,7 +145,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -161,7 +162,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; @@ -177,7 +178,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector *= Half; diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index fc1817a89..b92b86b41 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -9,8 +9,6 @@ namespace ImageSharp.PixelFormats using System.Numerics; using System.Runtime.CompilerServices; - using ImageSharp.Memory; - /// /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations /// for pixel buffers of type . @@ -86,21 +84,19 @@ namespace ImageSharp.PixelFormats } /// - /// Bulk version of . + /// Bulk version of . /// /// The to the source colors. - /// The to the destination bytes. - /// The starting index of the . + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToXyzBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal virtual void ToXyzBytes(Span sourceColors, Span destBytes, int count) { ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); - byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); - sp.ToXyzBytes(dest, startIndex + (i * 3)); + sp.ToXyzBytes(destBytes, i * 3); } } @@ -128,21 +124,19 @@ namespace ImageSharp.PixelFormats } /// - /// Bulk version of . + /// Bulk version of /// /// The to the source colors. - /// The to the destination bytes. - /// The starting index of the . + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToXyzwBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal virtual void ToXyzwBytes(Span sourceColors, Span destBytes, int count) { ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); - byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); - sp.ToXyzwBytes(dest, startIndex + (i * 4)); + sp.ToXyzwBytes(destBytes, i * 4); } } @@ -170,21 +164,19 @@ namespace ImageSharp.PixelFormats } /// - /// Bulk version of . + /// Bulk version of . /// /// The to the source colors. - /// The to the destination bytes. - /// The starting index of the . + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToZyxBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal virtual void ToZyxBytes(Span sourceColors, Span destBytes, int count) { ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); - byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); - sp.ToZyxBytes(dest, startIndex + (i * 3)); + sp.ToZyxBytes(destBytes, i * 3); } } @@ -212,21 +204,19 @@ namespace ImageSharp.PixelFormats } /// - /// Bulk version of . + /// Bulk version of . /// /// The to the source colors. - /// The to the destination bytes. - /// The starting index of the . + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToZyxwBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal virtual void ToZyxwBytes(Span sourceColors, Span destBytes, int count) { ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference(); - byte[] dest = destBytes.Array; for (int i = 0; i < count; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceRef, i); - sp.ToZyxwBytes(dest, startIndex + (i * 4)); + sp.ToZyxwBytes(destBytes, i * 4); } } } diff --git a/src/ImageSharp/PixelFormats/Rg32.cs b/src/ImageSharp/PixelFormats/Rg32.cs index 3e23777f6..ea7d8729b 100644 --- a/src/ImageSharp/PixelFormats/Rg32.cs +++ b/src/ImageSharp/PixelFormats/Rg32.cs @@ -114,7 +114,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -125,7 +125,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -137,7 +137,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -148,7 +148,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; diff --git a/src/ImageSharp/PixelFormats/Rgba1010102.cs b/src/ImageSharp/PixelFormats/Rgba1010102.cs index 747112fd8..ca7b74fbb 100644 --- a/src/ImageSharp/PixelFormats/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/Rgba1010102.cs @@ -108,7 +108,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -119,7 +119,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -131,7 +131,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -142,7 +142,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; diff --git a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs index c9dca89a3..168787ba7 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs @@ -134,10 +134,10 @@ namespace ImageSharp } /// - internal override void ToXyzBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal override void ToXyzBytes(Span sourceColors, Span destBytes, int count) { ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference(); - ref RGB24 destRef = ref Unsafe.As(ref new Span(destBytes.Array, startIndex).DangerousGetPinnableReference()); + ref RGB24 destRef = ref Unsafe.As(ref destBytes.DangerousGetPinnableReference()); for (int i = 0; i < count; i++) { @@ -155,9 +155,9 @@ namespace ImageSharp } /// - internal override unsafe void ToXyzwBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal override unsafe void ToXyzwBytes(Span sourceColors, Span destBytes, int count) { - SpanHelper.Copy(sourceColors.AsBytes(), new Span(destBytes.Array, startIndex), count * sizeof(Rgba32)); + SpanHelper.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Rgba32)); } /// @@ -177,10 +177,10 @@ namespace ImageSharp } /// - internal override void ToZyxBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal override void ToZyxBytes(Span sourceColors, Span destBytes, int count) { ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference(); - ref RGB24 destRef = ref Unsafe.As(ref new Span(destBytes.Array, startIndex).DangerousGetPinnableReference()); + ref RGB24 destRef = ref Unsafe.As(ref destBytes.DangerousGetPinnableReference()); for (int i = 0; i < count; i++) { @@ -207,10 +207,10 @@ namespace ImageSharp } /// - internal override void ToZyxwBytes(Span sourceColors, Buffer destBytes, int startIndex, int count) + internal override void ToZyxwBytes(Span sourceColors, Span destBytes, int count) { ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference(); - ref RGBA32 destRef = ref Unsafe.As(ref new Span(destBytes.Array, startIndex).DangerousGetPinnableReference()); + ref RGBA32 destRef = ref Unsafe.As(ref destBytes.DangerousGetPinnableReference()); for (int i = 0; i < count; i++) { diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index 15a9ed0fd..9b82a3701 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -5,6 +5,7 @@ namespace ImageSharp { + using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -230,7 +231,7 @@ namespace ImageSharp /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { bytes[startIndex] = this.R; bytes[startIndex + 1] = this.G; @@ -239,7 +240,7 @@ namespace ImageSharp /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { bytes[startIndex] = this.R; bytes[startIndex + 1] = this.G; @@ -249,7 +250,7 @@ namespace ImageSharp /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { bytes[startIndex] = this.B; bytes[startIndex + 1] = this.G; @@ -258,7 +259,7 @@ namespace ImageSharp /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { bytes[startIndex] = this.B; bytes[startIndex + 1] = this.G; diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs index 296c17a4e..417828368 100644 --- a/src/ImageSharp/PixelFormats/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/Rgba64.cs @@ -107,7 +107,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -118,7 +118,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -130,7 +130,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; @@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4() * 255F; diff --git a/src/ImageSharp/PixelFormats/RgbaVector.cs b/src/ImageSharp/PixelFormats/RgbaVector.cs index a92b794ef..5332f4a8e 100644 --- a/src/ImageSharp/PixelFormats/RgbaVector.cs +++ b/src/ImageSharp/PixelFormats/RgbaVector.cs @@ -5,6 +5,7 @@ namespace ImageSharp.PixelFormats { + using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -234,7 +235,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; vector += Half; @@ -245,7 +246,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; vector += Half; @@ -257,7 +258,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; vector += Half; @@ -268,7 +269,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; vector += Half; diff --git a/src/ImageSharp/PixelFormats/Short2.cs b/src/ImageSharp/PixelFormats/Short2.cs index 6c871ecb6..b848b5505 100644 --- a/src/ImageSharp/PixelFormats/Short2.cs +++ b/src/ImageSharp/PixelFormats/Short2.cs @@ -119,7 +119,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector2 vector = this.ToVector2(); vector /= 65534; @@ -135,7 +135,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector2 vector = this.ToVector2(); vector /= 65534; @@ -152,7 +152,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector2 vector = this.ToVector2(); vector /= 65534; @@ -168,7 +168,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector2 vector = this.ToVector2(); vector /= 65534; diff --git a/src/ImageSharp/PixelFormats/Short4.cs b/src/ImageSharp/PixelFormats/Short4.cs index de110c7d3..763de19bc 100644 --- a/src/ImageSharp/PixelFormats/Short4.cs +++ b/src/ImageSharp/PixelFormats/Short4.cs @@ -125,7 +125,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzBytes(byte[] bytes, int startIndex) + public void ToXyzBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector /= 65534; @@ -141,7 +141,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToXyzwBytes(byte[] bytes, int startIndex) + public void ToXyzwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector /= 65534; @@ -158,7 +158,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxBytes(byte[] bytes, int startIndex) + public void ToZyxBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector /= 65534; @@ -174,7 +174,7 @@ namespace ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void ToZyxwBytes(byte[] bytes, int startIndex) + public void ToZyxwBytes(Span bytes, int startIndex) { Vector4 vector = this.ToVector4(); vector /= 65534; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs index af76434a5..3c75fc2d1 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs @@ -46,13 +46,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new PixelOperations().ToXyzBytes(this.source, this.destination, 0, this.Count); + new PixelOperations().ToXyzBytes(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - PixelOperations.Instance.ToXyzBytes(this.source, this.destination, 0, this.Count); + PixelOperations.Instance.ToXyzBytes(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs index 01e7ef371..f64bf561b 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs @@ -51,13 +51,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk [Benchmark] public void CommonBulk() { - new PixelOperations().ToXyzwBytes(this.source, this.destination, 0, this.Count); + new PixelOperations().ToXyzwBytes(this.source, this.destination, this.Count); } [Benchmark] public void OptimizedBulk() { - PixelOperations.Instance.ToXyzwBytes(this.source, this.destination, 0, this.Count); + PixelOperations.Instance.ToXyzwBytes(this.source, this.destination, this.Count); } } diff --git a/tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs index e6d23dfc5..c91218ccc 100644 --- a/tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/PixelOperationsTests.cs @@ -181,7 +181,7 @@ namespace ImageSharp.Tests.Colors TestOperation( source, expected, - (s, d) => Operations.ToXyzBytes(s, d, 0, count) + (s, d) => Operations.ToXyzBytes(s, d, count) ); } @@ -222,7 +222,7 @@ namespace ImageSharp.Tests.Colors TestOperation( source, expected, - (s, d) => Operations.ToXyzwBytes(s, d, 0, count) + (s, d) => Operations.ToXyzwBytes(s, d, count) ); } @@ -263,7 +263,7 @@ namespace ImageSharp.Tests.Colors TestOperation( source, expected, - (s, d) => Operations.ToZyxBytes(s, d, 0, count) + (s, d) => Operations.ToZyxBytes(s, d, count) ); } @@ -304,7 +304,7 @@ namespace ImageSharp.Tests.Colors TestOperation( source, expected, - (s, d) => Operations.ToZyxwBytes(s, d, 0, count) + (s, d) => Operations.ToZyxwBytes(s, d, count) ); }