diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
index e5a2ffc2a..655c4c318 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
@@ -1,5 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+
//
using System;
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
index a3e944f98..8c4c6b58a 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
@@ -1,4 +1,4 @@
-<#@include file="RgbaCompatible.Common.ttinclude" #>
+<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
@@ -14,15 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations
{
<#
- GenerateDefaultSelfConversionMethods("Argb32");
- GenerateDefaultConvertToMethod("Argb32", "Bgr24");
- GenerateDefaultConvertToMethod("Argb32", "Bgra32");
- GenerateDefaultConvertToMethod("Argb32", "Gray8");
- GenerateDefaultConvertToMethod("Argb32", "Gray16");
- GenerateDefaultConvertToMethod("Argb32", "Rgb24");
- GenerateDefaultConvertToMethod("Argb32", "Rgba32");
- GenerateDefaultConvertToMethod("Argb32", "Rgb48");
- GenerateDefaultConvertToMethod("Argb32", "Rgba64");
+ GenerateAllDefaultConversionMethods("Argb32");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
index cbfbe7099..5d2ca335e 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Bgr24
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromBgr24(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
@@ -43,7 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -60,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -77,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -94,7 +96,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -111,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -128,7 +130,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -145,7 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@@ -162,7 +164,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
-
+
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt
index 0f7bd838f..56e3bf9ba 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
-
- for (int i = 0; i < count; i++)
- {
- ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
- dp.FromBgr24(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 Bgr24
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromBgr24(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToBgr24(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Bgr24");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
index edd702e0e..1121f4343 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Bgra32
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromBgra32(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt
index 4c4e10fad..6563ff907 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromBgra32(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 Bgra32
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromBgra32(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToBgra32(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Bgra32");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
index ca0e1fe32..e27f8bc58 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Gray16
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromGray16(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt
index 1e500dac5..3db96d70a 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromGray16(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 Gray16
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromGray16(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToGray16(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Gray16");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
index 6950c337d..26ed91cff 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Gray8
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromGray8(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt
index 7c6e2f767..a65d8f263 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromGray8(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 Gray8
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromGray8(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToGray8(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Gray8");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
index 53234cd66..8a6c6bddc 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Rgb24
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromRgb24(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt
index b98e1e4c7..796cdeb66 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromRgb24(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 Rgb24
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromRgb24(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToRgb24(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Rgb24");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
index 61d13978a..1701109ed 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Rgb48
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromRgb48(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt
index 2ff3125b4..b8ee99fce 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromRgb48(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 Rgb48
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromRgb48(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToRgb48(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Rgb48");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
index ae2ffd688..fb817a29a 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Rgba32
{
-
- ///
+ ///
/// Provides optimized overrides for bulk operations.
- ///
- internal partial class PixelOperations
+ ///
+ internal partial class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromRgba32(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt
index fb8d6db34..0c4a4c0c0 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromRgba32(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 Rgba32
{
-
- ///
+ ///
/// Provides optimized overrides for bulk operations.
- ///
- internal partial class PixelOperations
+ ///
+ internal partial class PixelOperations : PixelOperations
{
- ///
- internal override void FromRgba32(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToRgba32(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgb48");
- GenerateConvertToMethod("Rgba64");
+ GenerateAllDefaultConversionMethods("Rgba32");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
index 252068828..d49fb7ae5 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
@@ -2,24 +2,26 @@
// 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 Rgba64
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
+
+ ///
internal override void FromRgba64(ReadOnlySpan source, Span destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
-
+
///
internal override void ToArgb32(ReadOnlySpan sourcePixels, Span destPixels, int count)
{
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt
index 626f2316d..9409e1573 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt
@@ -1,83 +1,20 @@
-<#
-// 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="_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 Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
- ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
- for (int i = 0; i < count; i++)
- {
- ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
- ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
-
- dp.FromRgba64(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 Rgba64
{
-
///
/// Provides optimized overrides for bulk operations.
///
internal class PixelOperations : PixelOperations
{
- ///
- internal override void FromRgba64(ReadOnlySpan source, Span destPixels, int count)
- {
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
- source.Slice(0, count).CopyTo(destPixels);
- }
-
- ///
- internal override void ToRgba64(ReadOnlySpan sourcePixels, Span destPixels, int count)
- {
- GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
-
- sourcePixels.Slice(0, count).CopyTo(destPixels);
- }
-
<#
- GenerateConvertToMethod("Argb32");
- GenerateConvertToMethod("Bgr24");
- GenerateConvertToMethod("Bgra32");
- GenerateConvertToMethod("Gray8");
- GenerateConvertToMethod("Gray16");
- GenerateConvertToMethod("Rgb24");
- GenerateConvertToMethod("Rgba32");
- GenerateConvertToMethod("Rgb48");
+ GenerateAllDefaultConversionMethods("Rgba64");
#>
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
similarity index 81%
rename from src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude
rename to src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
index 150607538..af8c42357 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
@@ -5,12 +5,15 @@
<#@ 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;
<#+
+ static readonly string[] CommonPixelTypeNames = { "Argb32", "Bgr24", "Bgra32", "Gray8", "Gray16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
+
void GenerateDefaultSelfConversionMethods(string pixelType)
{
#>
@@ -56,4 +59,16 @@ using System.Runtime.InteropServices;
}
<#+
}
+
+ void GenerateAllDefaultConversionMethods(string pixelType)
+ {
+ GenerateDefaultSelfConversionMethods(pixelType);
+
+ var allOtherPixelTypes = CommonPixelTypeNames.Where(p => p != pixelType);
+
+ foreach (string destPixelType in allOtherPixelTypes)
+ {
+ GenerateDefaultConvertToMethod(pixelType, destPixelType);
+ }
+ }
#>
\ No newline at end of file