diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
index 80d084ae6c..6ecb33ffc9 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
@@ -1,6 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@@ -36,6 +39,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return adapted;
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref CieLab sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref CieLab sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -50,6 +74,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(labColor);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref CieLch sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref CieLch sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -64,6 +109,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(luvColor);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -82,6 +148,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return adapted;
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -93,6 +180,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return CieXyzAndCieXyyConverter.Convert(color);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -106,6 +214,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(rgb);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -119,6 +248,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(rgb);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref Hsl sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Hsl sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -132,6 +282,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(rgb);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref Hsv sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Hsv sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -150,6 +321,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return adapted;
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -167,6 +359,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
: this.Adapt(unadapted, color.WorkingSpace.WhitePoint);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -178,6 +391,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.cachedCieXyzAndLmsConverter.Convert(color);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref Lms sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Lms sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -190,6 +424,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(linear);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref Rgb sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Rgb sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Converts a into a
///
@@ -203,6 +458,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyz(rgb);
}
+ ///
+ /// Performs the bulk conversion from into
+ ///
+ /// The span to the source colors
+ /// The span to the destination colors
+ /// The number of colors to convert.
+ public void Convert(Span source, Span destination, int count)
+ {
+ Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count);
+
+ ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source);
+ ref CieXyz destRef = ref MemoryMarshal.GetReference(destination);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i);
+ ref CieXyz dp = ref Unsafe.Add(ref destRef, i);
+ dp = this.ToCieXyz(sp);
+ }
+ }
+
///
/// Gets the correct converter for the given rgb working space.
///