Browse Source

T4 all the PixelOperations!

af/merge-core
Anton Firszov 9 years ago
parent
commit
1901b3fdc2
  1. 1
      src/ImageSharp/Common/Helpers/Guard.cs
  2. 2
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  3. 10
      src/ImageSharp/Image/PixelAccessor{TPixel}.cs
  4. 9
      src/ImageSharp/ImageSharp.csproj
  5. 297
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  6. 120
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  7. 229
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  8. 107
      src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs
  9. 11
      src/ImageSharp/PixelFormats/Rgba32.cs
  10. 5
      src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs
  11. 12
      src/Shared/stylecop.json
  12. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
  13. 10
      tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs

1
src/ImageSharp/Common/Helpers/Guard.cs

@ -242,7 +242,6 @@ namespace ImageSharp
/// <paramref name="target"/> is true
/// </exception>
public static void MustBeSizedAtLeast<T>(Span<T> target, int minLength, string parameterName)
where T : struct
{
if (target.Length < minLength)
{

2
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -338,7 +338,7 @@ namespace ImageSharp.Formats
{
if (this.bytesPerPixel == 4)
{
PixelOperations<TPixel>.Instance.ToXyzwBytes(rowSpan, this.rawScanline, this.width);
PixelOperations<TPixel>.Instance.ToRgba32Bytes(rowSpan, this.rawScanline, this.width);
}
else
{

10
src/ImageSharp/Image/PixelAccessor{TPixel}.cs

@ -275,7 +275,7 @@ namespace ImageSharp
Span<byte> source = area.GetRowSpan(y);
Span<TPixel> destination = this.GetRowSpan(targetX, targetY + y);
Operations.PackFromZyxBytes(source, destination, width);
Operations.PackFromBgr24Bytes(source, destination, width);
}
}
@ -295,7 +295,7 @@ namespace ImageSharp
Span<byte> source = area.GetRowSpan(y);
Span<TPixel> destination = this.GetRowSpan(targetX, targetY + y);
Operations.PackFromZyxwBytes(source, destination, width);
Operations.PackFromBgra32Bytes(source, destination, width);
}
}
@ -353,7 +353,7 @@ namespace ImageSharp
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
Span<byte> destination = area.GetRowSpan(y);
Operations.ToZyxBytes(source, destination, width);
Operations.ToBgr24Bytes(source, destination, width);
}
}
@ -372,7 +372,7 @@ namespace ImageSharp
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
Span<byte> destination = area.GetRowSpan(y);
Operations.ToZyxwBytes(source, destination, width);
Operations.ToBgra32Bytes(source, destination, width);
}
}
@ -410,7 +410,7 @@ namespace ImageSharp
{
Span<TPixel> source = this.GetRowSpan(sourceX, sourceY + y);
Span<byte> destination = area.GetRowSpan(y);
Operations.ToXyzwBytes(source, destination, width);
Operations.ToRgba32Bytes(source, destination, width);
}
}

9
src/ImageSharp/ImageSharp.csproj

@ -55,6 +55,10 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Block8x8F.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelOperations{TPixel}.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>PixelOperations{TPixel}.Generated.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
@ -65,5 +69,10 @@
<AutoGen>True</AutoGen>
<DependentUpon>Block8x8F.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelOperations{TPixel}.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>PixelOperations{TPixel}.Generated.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>

297
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs

@ -0,0 +1,297 @@
// <auto-generated />
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
public partial class PixelOperations<TPixel>
{
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="Rgba32"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgba32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromRgba32(Span<Rgba32> source, Span<TPixel> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref Rgba32 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A helper for <see cref="PackFromRgba32(Span{Rgba32}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromRgba32Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFromRgba32(sourceBytes.NonPortableCast<byte, Rgba32>(), destPixels, count);
}
/// <summary>
/// Converts 'count' pixels in 'sourcePixels` span to a span of <see cref="Rgba32"/>-s.
/// Bulk version of <see cref="IPixel.ToRgba32(ref Rgba32)"/>.
/// </summary>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="dest">The destination span of <see cref="Rgba32"/> data.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToRgba32(Span<TPixel> sourcePixels, Span<Rgba32> dest, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref Rgba32 destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destBaseRef, i);
sp.ToRgba32(ref dp);
}
}
/// <summary>
/// A helper for <see cref="ToRgba32(Span{TPixel}, Span{Rgba32}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.ToRgba32(sourceColors, destBytes.NonPortableCast<byte, Rgba32>(), count);
}
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="Bgra32"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgra32"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromBgra32(Span<Bgra32> source, Span<TPixel> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref Bgra32 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A helper for <see cref="PackFromBgra32(Span{Bgra32}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromBgra32Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFromBgra32(sourceBytes.NonPortableCast<byte, Bgra32>(), destPixels, count);
}
/// <summary>
/// Converts 'count' pixels in 'sourcePixels` span to a span of <see cref="Bgra32"/>-s.
/// Bulk version of <see cref="IPixel.ToBgra32(ref Bgra32)"/>.
/// </summary>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="dest">The destination span of <see cref="Bgra32"/> data.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToBgra32(Span<TPixel> sourcePixels, Span<Bgra32> dest, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref Bgra32 destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destBaseRef, i);
sp.ToBgra32(ref dp);
}
}
/// <summary>
/// A helper for <see cref="ToBgra32(Span{TPixel}, Span{Bgra32}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.ToBgra32(sourceColors, destBytes.NonPortableCast<byte, Bgra32>(), count);
}
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="Rgb24"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Rgb24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromRgb24(Span<Rgb24> source, Span<TPixel> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref Rgb24 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Rgb = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A helper for <see cref="PackFromRgb24(Span{Rgb24}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromRgb24Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFromRgb24(sourceBytes.NonPortableCast<byte, Rgb24>(), destPixels, count);
}
/// <summary>
/// Converts 'count' pixels in 'sourcePixels` span to a span of <see cref="Rgb24"/>-s.
/// Bulk version of <see cref="IPixel.ToRgb24(ref Rgb24)"/>.
/// </summary>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="dest">The destination span of <see cref="Rgb24"/> data.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToRgb24(Span<TPixel> sourcePixels, Span<Rgb24> dest, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref Rgb24 destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i);
sp.ToRgb24(ref dp);
}
}
/// <summary>
/// A helper for <see cref="ToRgb24(Span{TPixel}, Span{Rgb24}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.ToRgb24(sourceColors, destBytes.NonPortableCast<byte, Rgb24>(), count);
}
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="Bgr24"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Bgr24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromBgr24(Span<Bgr24> source, Span<TPixel> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref Bgr24 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Bgr = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A helper for <see cref="PackFromBgr24(Span{Bgr24}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgr24"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromBgr24Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFromBgr24(sourceBytes.NonPortableCast<byte, Bgr24>(), destPixels, count);
}
/// <summary>
/// Converts 'count' pixels in 'sourcePixels` span to a span of <see cref="Bgr24"/>-s.
/// Bulk version of <see cref="IPixel.ToBgr24(ref Bgr24)"/>.
/// </summary>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="dest">The destination span of <see cref="Bgr24"/> data.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToBgr24(Span<TPixel> sourcePixels, Span<Bgr24> dest, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref Bgr24 destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destBaseRef, i);
sp.ToBgr24(ref dp);
}
}
/// <summary>
/// A helper for <see cref="ToBgr24(Span{TPixel}, Span{Bgr24}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgr24"/> layout.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.ToBgr24(sourceColors, destBytes.NonPortableCast<byte, Bgr24>(), count);
}
}
}

120
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt

@ -0,0 +1,120 @@
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
<#
void GenerateToDestFormatMethods(string pixelType)
{
#>
/// <summary>
/// Converts 'count' pixels in 'sourcePixels` span to a span of <see cref="<#=pixelType#>"/>-s.
/// Bulk version of <see cref="IPixel.To<#=pixelType#>(ref <#=pixelType#>)"/>.
/// </summary>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="dest">The destination span of <see cref="<#=pixelType#>"/> data.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void To<#=pixelType#>(Span<TPixel> sourcePixels, Span<<#=pixelType#>> dest, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref <#=pixelType#> destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, i);
sp.To<#=pixelType#>(ref dp);
}
}
/// <summary>
/// A helper for <see cref="To<#=pixelType#>(Span{TPixel}, Span{<#=pixelType#>}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="<#=pixelType#>"/> layout.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void To<#=pixelType#>Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.To<#=pixelType#>(sourceColors, destBytes.NonPortableCast<byte, <#=pixelType#>>(), count);
}
<#
}
void GeneratePackFromMethodUsingPackFromRgba32(string pixelType, string rgbaOperationCode)
{
#>
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="<#=pixelType#>"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="<#=pixelType#>"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFrom<#=pixelType#>(Span<<#=pixelType#>> source, Span<TPixel> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref <#=pixelType#> sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
<#=rgbaOperationCode#>
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A helper for <see cref="PackFrom<#=pixelType#>(Span{<#=pixelType#>}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="<#=pixelType#>"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFrom<#=pixelType#>Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFrom<#=pixelType#>(sourceBytes.NonPortableCast<byte, <#=pixelType#>>(), destPixels, count);
}
<#
}
#>
// <auto-generated />
namespace ImageSharp.PixelFormats
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
public partial class PixelOperations<TPixel>
{
<#
GeneratePackFromMethodUsingPackFromRgba32("Rgba32", "rgba = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Rgba32");
GeneratePackFromMethodUsingPackFromRgba32("Bgra32", "rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();");
GenerateToDestFormatMethods("Bgra32");
GeneratePackFromMethodUsingPackFromRgba32("Rgb24", "rgba.Rgb = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Rgb24");
GeneratePackFromMethodUsingPackFromRgba32("Bgr24", "rgba.Bgr = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Bgr24");
#>
}
}

229
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

@ -30,8 +30,7 @@ namespace ImageSharp.PixelFormats
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromVector4(Span<Vector4> sourceVectors, Span<TPixel> destColors, int count)
{
Guard.MustBeSizedAtLeast(sourceVectors, count, nameof(sourceVectors));
Guard.MustBeSizedAtLeast(destColors, count, nameof(destColors));
GuardSpans(sourceVectors, nameof(sourceVectors), destColors, nameof(destColors), count);
ref Vector4 sourceRef = ref sourceVectors.DangerousGetPinnableReference();
ref TPixel destRef = ref destColors.DangerousGetPinnableReference();
@ -52,8 +51,7 @@ namespace ImageSharp.PixelFormats
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToVector4(Span<TPixel> sourceColors, Span<Vector4> destVectors, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destVectors, count, nameof(destVectors));
GuardSpans(sourceColors, nameof(sourceColors), destVectors, nameof(destVectors), count);
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref Vector4 destRef = ref destVectors.DangerousGetPinnableReference();
@ -65,216 +63,27 @@ namespace ImageSharp.PixelFormats
dp = sp.ToVector4();
}
}
/// <summary>
/// Converts 'count' elements in 'source` span of <see cref="Rgb24"/> data to a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="source">The source span of <see cref="Rgb24"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromRgb24(Span<Rgb24> source, Span<TPixel> destPixels, int count)
{
Guard.MustBeSizedAtLeast(source, count, nameof(source));
Guard.MustBeSizedAtLeast(destPixels, count, nameof(destPixels));
ref Rgb24 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Rgb = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// A version of <see cref="PackFromBgr24(Span{Bgr24}, Span{TPixel}, int)"/> that expects a byte span to be converted to
/// Bulk version of <see cref="IPixel.PackFromRgba32(Rgba32)"/>
/// that converts bytes expected in R->G->B order compatible to <see cref="Rgb24"/> layout.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromRgb24Bytes(Span<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.PackFromRgb24(sourceBytes.NonPortableCast<byte, Rgb24>(), destPixels, count);
}
internal virtual void ToRgb24(Span<TPixel> sourcePixels, Span<Rgb24> dest, int count)
{
Guard.MustBeSizedAtLeast(sourcePixels, count, nameof(sourcePixels));
Guard.MustBeSizedAtLeast(dest, count, nameof(dest));
ref TPixel sourceBaseRef = ref sourcePixels.DangerousGetPinnableReference();
ref Rgb24 destBaseRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i);
sp.ToRgb24(ref dp);
}
}
/// <summary>
/// Bulk version of <see cref="PixelConversionExtensions.ToRgb24Bytes{TPixel}(TPixel, Span{byte}, int)"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal void ToRgb24Bytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
this.ToRgb24(sourceColors, destBytes.NonPortableCast<byte, Rgb24>(), count);
}
/// <summary>
/// Bulk version of <see cref="IPixel.PackFromRgba32(Rgba32)"/> that converts data in <see cref="ComponentOrder.Xyzw"/>.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destColors">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromRgba32Bytes(Span<byte> sourceBytes, Span<TPixel> destColors, int count)
{
this.PackFromRgba32(sourceBytes.NonPortableCast<byte, Rgba32>(), destColors, count);
}
internal virtual void PackFromRgba32(Span<Rgba32> source, Span<TPixel> destPixels, int count)
{
Guard.MustBeSizedAtLeast(source, count, nameof(source));
Guard.MustBeSizedAtLeast(destPixels, count, nameof(destPixels));
ref Rgba32 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// Bulk version of <see cref="PixelConversionExtensions.ToXyzwBytes{TPixel}(TPixel, Span{byte}, int)"/>
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToXyzwBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 4, nameof(destBytes));
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToXyzwBytes(destBytes, i * 4);
}
}
/// <summary>
/// Bulk version of <see cref="IPixel.PackFromRgba32(Rgba32)"/> that converts data in <see cref="ComponentOrder.Zyx"/>.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destColors">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromZyxBytes(Span<byte> sourceBytes, Span<TPixel> destColors, int count)
{
this.PackFromBgr24(sourceBytes.NonPortableCast<byte, Bgr24>(), destColors, count);
}
internal virtual void PackFromBgr24(Span<Bgr24> source, Span<TPixel> destPixels, int count)
{
Guard.MustBeSizedAtLeast(source, count, nameof(source));
Guard.MustBeSizedAtLeast(destPixels, count, nameof(destPixels));
ref Bgr24 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Bgr = Unsafe.Add(ref sourceRef, i);
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// Bulk version of <see cref="PixelConversionExtensions.ToZyxBytes{TPixel}(TPixel, Span{byte}, int)"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToZyxBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 3, nameof(destBytes));
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxBytes(destBytes, i * 3);
}
}
/// <summary>
/// Bulk version of <see cref="IPixel.PackFromRgba32(Rgba32)"/> that converts data in <see cref="ComponentOrder.Zyxw"/>.
/// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
/// <param name="destColors">The <see cref="Span{T}"/> to the destination colors.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackFromZyxwBytes(Span<byte> sourceBytes, Span<TPixel> destColors, int count)
{
this.PackFromBgra32(sourceBytes.NonPortableCast<byte, Bgra32>(), destColors, count);
}
internal virtual void PackFromBgra32(Span<Bgra32> source, Span<TPixel> destPixels, int count)
{
Guard.MustBeSizedAtLeast(source, count, nameof(source));
Guard.MustBeSizedAtLeast(destPixels, count, nameof(destPixels));
ref Bgra32 sourceRef = ref source.DangerousGetPinnableReference();
ref TPixel destRef = ref destPixels.DangerousGetPinnableReference();
Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();
dp.PackFromRgba32(rgba);
}
}
/// <summary>
/// Bulk version of <see cref="PixelConversionExtensions.ToZyxwBytes{TPixel}(TPixel, Span{byte}, int)"/>.
/// Verifies that the given 'source' and 'dest' spans are at least of 'minLength' size.
/// Throwing an <see cref="ArgumentException"/> if the condition is not met.
/// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void ToZyxwBytes(Span<TPixel> sourceColors, Span<byte> destBytes, int count)
/// <typeparam name="TSource">The source element type</typeparam>
/// <typeparam name="TDest">The destination element type</typeparam>
/// <param name="source">The source span</param>
/// <param name="sourceParamName">The source parameter name</param>
/// <param name="dest">The destination span</param>
/// <param name="destParamName">The destination parameter name</param>
/// <param name="minLength">The minimum length</param>
protected internal static void GuardSpans<TSource, TDest>(
Span<TSource> source,
string sourceParamName,
Span<TDest> dest,
string destParamName,
int minLength)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 4, nameof(destBytes));
ref TPixel sourceRef = ref sourceColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
sp.ToZyxwBytes(destBytes, i * 4);
}
Guard.MustBeSizedAtLeast(source, minLength, sourceParamName);
Guard.MustBeSizedAtLeast(dest, minLength, destParamName);
}
}
}

107
src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs

@ -120,6 +120,7 @@ namespace ImageSharp
}
}
/// <inheritdoc />
internal override void PackFromRgb24(Span<Rgb24> source, Span<Rgba32> destPixels, int count)
{
Guard.MustBeSizedAtLeast(source, count, nameof(source));
@ -138,6 +139,7 @@ namespace ImageSharp
}
}
/// <inheritdoc />
internal override void ToRgb24(Span<Rgba32> sourcePixels, Span<Rgb24> dest, int count)
{
Guard.MustBeSizedAtLeast(sourcePixels, count, nameof(sourcePixels));
@ -156,129 +158,86 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void PackFromRgba32Bytes(Span<byte> sourceBytes, Span<Rgba32> destColors, int count)
internal override void PackFromRgba32(Span<Rgba32> source, Span<Rgba32> destPixels, int count)
{
Guard.MustBeSizedAtLeast(sourceBytes, count * 4, nameof(sourceBytes));
Guard.MustBeSizedAtLeast(destColors, count, nameof(destColors));
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
SpanHelper.Copy(sourceBytes, destColors.AsBytes(), count * sizeof(Rgba32));
SpanHelper.Copy(source, destPixels, count);
}
/// <inheritdoc />
internal override unsafe void ToXyzwBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
internal override void ToRgba32(Span<Rgba32> sourcePixels, Span<Rgba32> dest, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 4, nameof(destBytes));
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
SpanHelper.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Rgba32));
SpanHelper.Copy(sourcePixels, dest, count);
}
/// <inheritdoc />
internal override void PackFromZyxBytes(Span<byte> sourceBytes, Span<Rgba32> destColors, int count)
internal override void PackFromBgr24(Span<Bgr24> source, Span<Rgba32> destPixels, int count)
{
Guard.MustBeSizedAtLeast(sourceBytes, count * 3, nameof(sourceBytes));
Guard.MustBeSizedAtLeast(destColors, count, nameof(destColors));
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Rgba32 destRef = ref destColors.DangerousGetPinnableReference();
ref Bgr24 sourceRef = ref source.DangerousGetPinnableReference();
ref Rgba32 destRef = ref destPixels.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Rgba32, RGB24>(ref dp) = sp.ToZyx();
dp.Bgr = sp;
dp.A = 255;
}
}
/// <inheritdoc />
internal override void ToZyxBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
internal override void ToBgr24(Span<Rgba32> sourcePixels, Span<Bgr24> dest, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 3, nameof(destBytes));
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
ref Rgba32 sourceRef = ref sourcePixels.DangerousGetPinnableReference();
ref Bgr24 destRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Rgba32, RGB24>(ref sp).ToZyx();
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.Bgr;
}
}
/// <inheritdoc />
internal override void PackFromZyxwBytes(Span<byte> sourceBytes, Span<Rgba32> destColors, int count)
internal override void PackFromBgra32(Span<Bgra32> source, Span<Rgba32> destPixels, int count)
{
Guard.MustBeSizedAtLeast(sourceBytes, count * 4, nameof(sourceBytes));
Guard.MustBeSizedAtLeast(destColors, count, nameof(destColors));
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref RGBA32 sourceRef = ref Unsafe.As<byte, RGBA32>(ref sourceBytes.DangerousGetPinnableReference());
ref Rgba32 destRef = ref destColors.DangerousGetPinnableReference();
ref Bgra32 sourceRef = ref source.DangerousGetPinnableReference();
ref Rgba32 destRef = ref destPixels.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
RGBA32 zyxw = sp.ToZyxw();
dp = Unsafe.As<RGBA32, Rgba32>(ref zyxw);
dp = sp.ToRgba32();
}
}
/// <inheritdoc />
internal override void ToZyxwBytes(Span<Rgba32> sourceColors, Span<byte> destBytes, int count)
internal override void ToBgra32(Span<Rgba32> sourcePixels, Span<Bgra32> dest, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destBytes, count * 4, nameof(destBytes));
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference());
ref Rgba32 sourceRef = ref sourcePixels.DangerousGetPinnableReference();
ref Bgra32 destRef = ref dest.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.As<Rgba32, RGBA32>(ref Unsafe.Add(ref sourceRef, i));
ref RGBA32 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.ToZyxw();
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.ToBgra32();
}
}
/// <summary>
/// Helper struct to manipulate 3-byte RGB data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGB24
{
private byte x;
private byte y;
private byte z;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGB24 ToZyx() => new RGB24 { x = this.z, y = this.y, z = this.x };
}
/// <summary>
/// Helper struct to manipulate 4-byte RGBA data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGBA32
{
private byte x;
private byte y;
private byte z;
private byte w;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGBA32 ToZyxw() => new RGBA32 { x = this.z, y = this.y, z = this.x, w = this.w };
}
/// <summary>
/// Value type to store <see cref="Rgba32"/>-s unpacked into multiple <see cref="uint"/>-s.
/// </summary>

11
src/ImageSharp/PixelFormats/Rgba32.cs

@ -337,6 +337,17 @@ namespace ImageSharp
return new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
}
/// <summary>
/// Gets the value of this struct as <see cref="Bgra32"/>.
/// Useful for changing the component order.
/// </summary>
/// <returns>A <see cref="Bgra32"/> value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Bgra32 ToBgra32()
{
return new Bgra32(this.R, this.G, this.B, this.A);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{

5
src/ImageSharp/PixelFormats/RgbaVector.PixelOperations.cs

@ -23,10 +23,9 @@ namespace ImageSharp.PixelFormats
/// <inheritdoc />
internal override unsafe void ToVector4(Span<RgbaVector> sourceColors, Span<Vector4> destVectors, int count)
{
Guard.MustBeSizedAtLeast(sourceColors, count, nameof(sourceColors));
Guard.MustBeSizedAtLeast(destVectors, count, nameof(destVectors));
GuardSpans(sourceColors, nameof(sourceColors), destVectors, nameof(destVectors), count);
SpanHelper.Copy(sourceColors.AsBytes(), destVectors.AsBytes(), count * sizeof(Vector4));
SpanHelper.Copy(sourceColors.NonPortableCast<RgbaVector, Vector4>(), destVectors, count);
}
}
}

12
src/Shared/stylecop.json

@ -4,12 +4,12 @@
"documentationRules": {
"companyName": "James Jackson-South",
"copyrightText": "Copyright (c) James Jackson-South and contributors.\nLicensed under the Apache License, Version 2.0."
,
"documentInterfaces": false,
"documentInternalElements": false,
"documentExposedElements": false,
"documentPrivateElements": false,
"documentPrivateFields": false
//,
//"documentInterfaces": false,
//"documentInternalElements": false,
//"documentExposedElements": false,
//"documentPrivateElements": false,
//"documentPrivateFields": false
}
}
}

4
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs

@ -51,13 +51,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk
[Benchmark]
public void CommonBulk()
{
new PixelOperations<TPixel>().ToXyzwBytes(this.source, this.destination, this.Count);
new PixelOperations<TPixel>().ToRgba32Bytes(this.source, this.destination, this.Count);
}
[Benchmark]
public void OptimizedBulk()
{
PixelOperations<TPixel>.Instance.ToXyzwBytes(this.source, this.destination, this.Count);
PixelOperations<TPixel>.Instance.ToRgba32Bytes(this.source, this.destination, this.Count);
}
}

10
tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs

@ -226,7 +226,7 @@ namespace ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToXyzwBytes(s, d, count)
(s, d) => Operations.ToRgba32Bytes(s, d, count)
);
}
@ -247,7 +247,7 @@ namespace ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.PackFromZyxBytes(s, d, count)
(s, d) => Operations.PackFromBgr24Bytes(s, d, count)
);
}
@ -267,7 +267,7 @@ namespace ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToZyxBytes(s, d, count)
(s, d) => Operations.ToBgr24Bytes(s, d, count)
);
}
@ -288,7 +288,7 @@ namespace ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.PackFromZyxwBytes(s, d, count)
(s, d) => Operations.PackFromBgra32Bytes(s, d, count)
);
}
@ -308,7 +308,7 @@ namespace ImageSharp.Tests.PixelFormats
TestOperation(
source,
expected,
(s, d) => Operations.ToZyxwBytes(s, d, count)
(s, d) => Operations.ToBgra32Bytes(s, d, count)
);
}

Loading…
Cancel
Save