Browse Source

Add bulk CieXyy transforms

pull/664/head
James Jackson-South 8 years ago
parent
commit
72b292abc7
  1. 276
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs

276
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);
}
/// <summary>
/// Performs the bulk conversion from <see cref="CieLab"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="CieLch"/> into a <see cref="CieXyy"/>
/// </summary>
@ -36,6 +60,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="CieLch"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="CieLchuv"/> into a <see cref="CieXyy"/>
/// </summary>
@ -48,6 +93,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="CieLchuv"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="CieLuv"/> into a <see cref="CieXyy"/>
/// </summary>
@ -60,6 +126,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="CieLuv"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="CieXyz"/> into a <see cref="CieXyy"/>
/// </summary>
@ -70,6 +157,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return CieXyzAndCieXyyConverter.Convert(color);
}
/// <summary>
/// Performs the bulk conversion from <see cref="CieXyz"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="Cmyk"/> into a <see cref="CieXyy"/>
/// </summary>
@ -82,6 +190,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="Cmyk"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="Hsl"/> into a <see cref="CieXyy"/>
/// </summary>
@ -94,6 +223,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="Hsl"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="Hsv"/> into a <see cref="CieXyy"/>
/// </summary>
@ -106,6 +256,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="Hsv"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="HunterLab"/> into a <see cref="CieXyy"/>
/// </summary>
@ -118,6 +289,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="HunterLab"/> into <see cref="CieXyy"/>
/// </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<HunterLab> source, Span<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="LinearRgb"/> into a <see cref="CieXyy"/>
/// </summary>
@ -130,6 +322,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="LinearRgb"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="Lms"/> into a <see cref="CieXyy"/>
/// </summary>
@ -142,6 +355,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="Lms"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="Rgb"/> into a <see cref="CieXyy"/>
/// </summary>
@ -154,6 +388,27 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="Rgb"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
/// <summary>
/// Converts a <see cref="YCbCr"/> into a <see cref="CieXyy"/>
/// </summary>
@ -165,5 +420,26 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
return this.ToCieXyy(xyzColor);
}
/// <summary>
/// Performs the bulk conversion from <see cref="YCbCr"/> into <see cref="CieXyy"/>
/// </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<CieXyy> 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);
}
}
}
}
Loading…
Cancel
Save