diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
index 16121d62d..507c8cd3a 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
@@ -1,19 +1,19 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-
//
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+
namespace SixLabors.ImageSharp.PixelFormats
{
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
-
///
/// Provides optimized overrides for bulk operations.
///
public partial struct Argb32
{
-
///
/// Provides optimized overrides for bulk operations.
///
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
index f90384671..432421166 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
@@ -1,53 +1,13 @@
-<#
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-#>
-<#@ template debug="false" hostspecific="false" language="C#" #>
-<#@ assembly name="System.Core" #>
-<#@ import namespace="System.Linq" #>
-<#@ import namespace="System.Text" #>
-<#@ import namespace="System.Collections.Generic" #>
+<#@include file="RgbaCompatible.Common.ttinclude" #>
<#@ output extension=".cs" #>
-<#
- void GenerateConvertToMethod(string pixelType)
- {
- #>
-
- ///
- internal override void To<#=pixelType#>(ReadOnlySpan sourcePixels, Span<<#=pixelType#>> destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromArgb32(sp);
- }
- }
- <#
- }
-#>
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-//
namespace SixLabors.ImageSharp.PixelFormats
{
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
-
///
/// Provides optimized overrides for bulk operations.
///
public partial struct Argb32
{
-
///
/// Provides optimized overrides for bulk operations.
///
@@ -70,14 +30,14 @@ namespace SixLabors.ImageSharp.PixelFormats
}
<#
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateDefaultConvertToMethod("Argb32", "Bgr24");
+ GenerateDefaultConvertToMethod("Argb32", "Bgra32");
+ GenerateDefaultConvertToMethod("Argb32", "Gray8");
+ GenerateDefaultConvertToMethod("Argb32", "Gray16");
+ GenerateDefaultConvertToMethod("Argb32", "Rgb24");
+ GenerateDefaultConvertToMethod("Argb32", "Rgba32");
+ GenerateDefaultConvertToMethod("Argb32", "Rgb48");
+ GenerateDefaultConvertToMethod("Argb32", "Rgba64");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude
new file mode 100644
index 000000000..d433bd540
--- /dev/null
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude
@@ -0,0 +1,36 @@
+<#@ template debug="false" hostspecific="false" language="C#" #>
+<#@ assembly name="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+<#+
+ void GenerateDefaultConvertToMethod(string fromPixelType, string toPixelType)
+ {
+ #>
+
+ ///
+ internal override void To<#=toPixelType#>(ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destPixels, int count)
+ {
+ GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
+
+ ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
+ ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i);
+ ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, i);
+
+ dp.From<#=fromPixelType#>(sp);
+ }
+ }
+ <#+
+ }
+#>
\ No newline at end of file