diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
index 09f10716e..e6b8922e9 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromArgb32(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,109 +35,167 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
}
-
+
///
- internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void FromVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
- ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
- ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromArgb32(sp);
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToRgba32(sp);
}
}
-
+
///
- internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void FromRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
- ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToArgb32(sp);
+ }
+ }
+ ///
+ internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
- ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToBgra32(sp);
+ }
+ }
- dp.FromArgb32(sp);
+ ///
+ internal override void FromBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
+
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToArgb32(sp);
}
}
///
- internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Gray8 dp = ref Unsafe.Add(ref destRef, i);
+ ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
dp.FromArgb32(sp);
}
}
///
- internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
+ ref Gray8 dp = ref Unsafe.Add(ref destRef, i);
dp.FromArgb32(sp);
}
}
///
- internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
+ ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromArgb32(sp);
}
}
///
- internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
+ ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
dp.FromArgb32(sp);
}
@@ -143,6 +204,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +222,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
index f8c61e4fa..9b1740013 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromBgr24(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,15 +35,42 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
}
+
+ ///
+ internal override void FromVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -58,6 +88,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +106,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +142,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +160,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +178,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +196,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
index 9bddd18e9..37d6b72d7 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromBgra32(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,32 +35,104 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
}
-
+
+ ///
+ internal override void FromVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
///
- internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
- ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
- ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToRgba32(sp);
+ }
+ }
- dp.FromBgra32(sp);
+ ///
+ internal override void FromRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
+
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToBgra32(sp);
+ }
+ }
+ ///
+ internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
+
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToArgb32(sp);
+ }
+ }
+
+ ///
+ internal override void FromArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
+
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToBgra32(sp);
}
}
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +150,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +168,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +186,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -119,23 +197,6 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
- dp.FromBgra32(sp);
- }
- }
-
- ///
- internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
- {
- Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
-
- ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
-
- for (int i = 0; i < sourcePixels.Length; i++)
- {
- ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
-
dp.FromBgra32(sp);
}
}
@@ -143,6 +204,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +222,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
index 31c575534..638db1d0d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromGray16(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,6 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
@@ -41,6 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -58,6 +63,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +99,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +117,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +135,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +153,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +171,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
index 14a2c858c..6bf0693c2 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromGray8(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,6 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
@@ -41,6 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -58,6 +63,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +99,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +117,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +135,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +153,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +171,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
index f8b80020e..6ff87eb38 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromRgb24(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,15 +35,42 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
}
+
+ ///
+ internal override void FromVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
+ ///
+ internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan sourceVectors, Span destPixels)
+ {
+ this.RunRgba32CompatibleFromVector4Conversion(configuration, sourceVectors, destPixels);
+ }
+
+ ///
+ internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan sourcePixels, Span destVectors)
+ {
+ this.RunRgba32CompatibleToVector4Conversion(configuration, sourcePixels, destVectors);
+ }
+
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -58,6 +88,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +106,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +142,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +160,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +178,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +196,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
index 5741b1070..9b4584d76 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromRgb48(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,6 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
@@ -41,6 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -58,6 +63,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -75,6 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -92,6 +99,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +117,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +135,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +153,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +171,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
index 9f7b624c0..8e15ca1f4 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromRgba32(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,58 +35,88 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
}
-
- ///
- internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ ///
+ internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
- ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
- ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromRgba32(sp);
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToArgb32(sp);
}
}
-
+
///
- internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void FromArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
- ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToRgba32(sp);
+ }
+ }
+ ///
+ internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
for (int i = 0; i < sourcePixels.Length; i++)
{
- ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToBgra32(sp);
+ }
+ }
- dp.FromRgba32(sp);
+ ///
+ internal override void FromBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
+
+ ref uint sourceRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels));
+ ref uint destRef = ref Unsafe.As(ref MemoryMarshal.GetReference(destPixels));
+
+ for (int i = 0; i < sourcePixels.Length; i++)
+ {
+ uint sp = Unsafe.Add(ref sourceRef, i);
+ Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToRgba32(sp);
}
}
///
- internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
+ internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
+ ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
+ ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba32(sp);
}
@@ -92,6 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -109,6 +143,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -126,6 +161,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -143,6 +179,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
@@ -160,6 +197,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
index 411178b82..caaba7809 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
@@ -4,6 +4,8 @@
//
using System;
+using System.Buffers;
+using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -24,6 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void FromRgba64(Configuration configuration, ReadOnlySpan source, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
source.CopyTo(destPixels);
@@ -32,6 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///
internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels)
{
+ Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
sourcePixels.CopyTo(destPixels);
@@ -41,6 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
///