diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs index 4b14f65bc8..464c5ff919 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.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 @@ -24,6 +27,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -36,6 +60,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -48,6 +93,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -60,6 +126,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -70,6 +157,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 CieXyz sourceRef = ref MemoryMarshal.GetReference(source); + ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -82,6 +190,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -94,6 +223,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -106,6 +256,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -118,6 +289,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -130,6 +322,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -142,6 +355,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref Lms sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -154,6 +388,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } + /// /// Converts a into a /// @@ -165,5 +420,26 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion return this.ToCieXyy(xyzColor); } + + /// + /// 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 CieXyy destRef = ref MemoryMarshal.GetReference(destination); + + for (int i = 0; i < count; i++) + { + ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); + ref CieXyy dp = ref Unsafe.Add(ref destRef, i); + dp = this.ToCieXyy(sp); + } + } } } \ No newline at end of file