Browse Source

Fix pixel conversion tests

pull/1886/head
Ynse Hoornenborg 4 years ago
parent
commit
98e4417429
  1. 4
      src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs
  2. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  3. 27
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs
  4. 27
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs
  5. 27
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs
  6. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs
  7. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs
  8. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs
  9. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs
  10. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs
  11. 27
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs
  12. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs
  13. 27
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs
  14. 20
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs

4
src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs

@ -219,8 +219,8 @@ namespace SixLabors.ImageSharp
// tmp2 = [W 0 Y 0]
// tmp3=ROTL(16, tmp2) = [Y 0 W 0]
// tmp1 + tmp3 = [Y Z W X]
uint tmp1 = packed & 0xFF00FF00;
uint tmp2 = packed & 0x00FF00FF;
uint tmp1 = packed & 0x00FF00FF;
uint tmp2 = packed & 0xFF00FF00;
uint tmp3 = (tmp2 << 16) | (tmp2 >> 16);
Unsafe.Add(ref dBase, i) = tmp1 + tmp3;

2
src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

@ -204,7 +204,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromAbgr32(Abgr32 source) => this.PackedValue = source.PackedValue;
public void FromAbgr32(Abgr32 source) => this = source;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

27
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs

@ -85,6 +85,33 @@ namespace SixLabors.ImageSharp.PixelFormats
PixelConverter.FromRgba32.ToArgb32(source, dest);
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToAbgr32(source, dest);
}
/// <inheritdoc />
public override void FromAbgr32(
Configuration configuration,
ReadOnlySpan<Abgr32> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToArgb32(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,

27
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs

@ -112,6 +112,33 @@ namespace SixLabors.ImageSharp.PixelFormats
PixelConverter.FromArgb32.ToBgr24(source, dest);
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgr24.ToAbgr32(source, dest);
}
/// <inheritdoc />
public override void FromAbgr32(
Configuration configuration,
ReadOnlySpan<Abgr32> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgr24(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,

27
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs

@ -112,6 +112,33 @@ namespace SixLabors.ImageSharp.PixelFormats
PixelConverter.FromArgb32.ToBgra32(source, dest);
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToAbgr32(source, dest);
}
/// <inheritdoc />
public override void FromAbgr32(
Configuration configuration,
ReadOnlySpan<Abgr32> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToBgra32(source, dest);
}
/// <inheritdoc />
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromBgra5551(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromL16(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromL8(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref La16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromLa16(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref La32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromLa32(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,

27
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs

@ -112,6 +112,33 @@ namespace SixLabors.ImageSharp.PixelFormats
PixelConverter.FromArgb32.ToRgb24(source, dest);
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToAbgr32(source, dest);
}
/// <inheritdoc />
public override void FromAbgr32(
Configuration configuration,
ReadOnlySpan<Abgr32> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgb24(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgb48(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,

27
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs

@ -66,6 +66,33 @@ namespace SixLabors.ImageSharp.PixelFormats
PixelConverter.FromArgb32.ToRgba32(source, dest);
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Abgr32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToAbgr32(source, dest);
}
/// <inheritdoc />
public override void FromAbgr32(
Configuration configuration,
ReadOnlySpan<Abgr32> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Abgr32, byte>(sourcePixels);
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromAbgr32.ToRgba32(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,

20
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs

@ -59,6 +59,26 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
/// <inheritdoc />
public override void ToAbgr32(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Abgr32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Abgr32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba64(sp);
}
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,

Loading…
Cancel
Save