|
|
|
@ -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 |
|
|
|
@ -21,6 +24,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieLab"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieLab> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="CieLch"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -32,6 +56,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieLch"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieLch> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="CieLchuv"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -43,6 +88,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieLchuv"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieLchuv> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="CieLuv"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -54,6 +120,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieLuv"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieLuv> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="CieXyy"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -65,6 +152,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieXyy"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieXyy> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="CieXyz"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -81,6 +189,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return new CieXyzToHunterLabConverter(this.TargetHunterLabWhitePoint).Convert(adapted); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="CieXyz"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<CieXyz> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Cmyk"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -92,6 +221,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="Cmyk"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<Cmyk> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Hsl"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -103,6 +253,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="Hsl"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<Hsl> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Hsv"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -114,6 +285,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="Hsl"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<Hsv> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="LinearRgb"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -125,6 +317,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="LinearRgb"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<LinearRgb> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Lms"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -136,6 +349,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="Lms"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<Lms> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref Lms sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref Lms sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="Rgb"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -147,6 +381,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="Rgb"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<Rgb> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Converts a <see cref="YCbCr"/> into a <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
@ -157,5 +412,26 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion |
|
|
|
var xyzColor = this.ToCieXyz(color); |
|
|
|
return this.ToHunterLab(xyzColor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Performs the bulk conversion from <see cref="YCbCr"/> into <see cref="HunterLab"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The span to the source colors</param>
|
|
|
|
/// <param name="destination">The span to the destination colors</param>
|
|
|
|
/// <param name="count">The number of colors to convert.</param>
|
|
|
|
public void Convert(Span<YCbCr> source, Span<HunterLab> destination, int count) |
|
|
|
{ |
|
|
|
Guard.SpansMustBeSizedAtLeast(source, nameof(source), destination, nameof(destination), count); |
|
|
|
|
|
|
|
ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); |
|
|
|
ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); |
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref HunterLab dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
dp = this.ToHunterLab(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |