Browse Source

Add new property and implement for TPixel types

js/color-alpha-handling
James Jackson-South 5 years ago
parent
commit
6a3411ed6b
  1. 19
      src/ImageSharp/Formats/PixelTypeInfo.cs
  2. 88
      src/ImageSharp/ImageSharp.csproj
  3. 32
      src/ImageSharp/PixelFormats/PixelAlphaRepresentation.cs
  4. 4
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  5. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  6. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  7. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  8. 4
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  9. 6
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  10. 4
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  11. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  12. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  13. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  14. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  15. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/A8.PixelOperations.cs
  16. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr565.PixelOperations.cs
  17. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra4444.PixelOperations.cs
  18. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Byte4.PixelOperations.cs
  19. 64
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs
  20. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.tt
  21. 64
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs
  22. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.tt
  23. 64
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs
  24. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.tt
  25. 66
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs
  26. 2
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.tt
  27. 68
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs
  28. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.tt
  29. 68
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs
  30. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.tt
  31. 66
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs
  32. 2
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.tt
  33. 66
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs
  34. 2
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.tt
  35. 63
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs
  36. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.tt
  37. 68
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs
  38. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.tt
  39. 52
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs
  40. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.tt
  41. 68
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs
  42. 4
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.tt
  43. 101
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude
  44. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfSingle.PixelOperations.cs
  45. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector2.PixelOperations.cs
  46. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector4.PixelOperations.cs
  47. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte2.PixelOperations.cs
  48. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte4.PixelOperations.cs
  49. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort2.PixelOperations.cs
  50. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort4.PixelOperations.cs
  51. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rg32.PixelOperations.cs
  52. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba1010102.PixelOperations.cs
  53. 0
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba32.PixelOperations.cs
  54. 15
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs
  55. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short2.PixelOperations.cs
  56. 22
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short4.PixelOperations.cs
  57. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  58. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  59. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  60. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs
  61. 47
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  62. 2
      tests/ImageSharp.Tests.ProfilingSandbox/Program.cs
  63. 24
      tests/ImageSharp.Tests/ImageSharp.Tests.csproj
  64. 718
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs
  65. 11
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.tt
  66. 117
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude
  67. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Argb32OperationsTests.cs
  68. 25
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgr24OperationsTests.cs
  69. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgra32OperationsTests.cs
  70. 20
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgra5551OperationsTests.cs
  71. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L16OperationsTests.cs
  72. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L8OperationsTests.cs
  73. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La16OperationsTests.cs
  74. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La32OperationsTests.cs
  75. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgb24OperationsTests.cs
  76. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgb48OperationsTests.cs
  77. 17
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgba32OperationsTests.cs
  78. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgba64OperationsTests.cs
  79. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.RgbaVectorOperationsTests.cs
  80. 2
      tests/Images/External

19
src/ImageSharp/Formats/PixelTypeInfo.cs

@ -1,8 +1,7 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats
@ -16,9 +15,11 @@ namespace SixLabors.ImageSharp.Formats
/// Initializes a new instance of the <see cref="PixelTypeInfo"/> class.
/// </summary>
/// <param name="bitsPerPixel">Color depth, in number of bits per pixel.</param>
internal PixelTypeInfo(int bitsPerPixel)
/// <param name="alpha">Tthe pixel alpha transparency behavior.</param>
internal PixelTypeInfo(int bitsPerPixel, PixelAlphaRepresentation? alpha = null)
{
this.BitsPerPixel = bitsPerPixel;
this.AlphaRepresentation = alpha;
}
/// <summary>
@ -26,8 +27,20 @@ namespace SixLabors.ImageSharp.Formats
/// </summary>
public int BitsPerPixel { get; }
/// <summary>
/// Gets the pixel alpha transparency behavior.
/// <see langword="null"/> means unknown, unspecified.
/// </summary>
public PixelAlphaRepresentation? AlphaRepresentation { get; }
internal static PixelTypeInfo Create<TPixel>()
where TPixel : unmanaged, IPixel<TPixel> =>
new PixelTypeInfo(Unsafe.SizeOf<TPixel>() * 8);
internal static PixelTypeInfo Create<TPixel>(PixelAlphaRepresentation alpha)
where TPixel : unmanaged, IPixel<TPixel>
{
return new PixelTypeInfo(Unsafe.SizeOf<TPixel>() * 8, alpha);
}
}
}

88
src/ImageSharp/ImageSharp.csproj

@ -62,62 +62,102 @@
<AutoGen>True</AutoGen>
<DependentUpon>PixelOperations{TPixel}.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Argb32.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\A8.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>A8.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Argb32.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Argb32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Bgr24.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgr24.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Bgr24.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Bgra32.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgr565.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Bgr565.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgra32.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Bgra32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Bgra5551.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgra4444.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Bgra4444.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgra5551.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Bgra5551.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\L8.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Byte4.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Byte4.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\HalfSingle.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>HalfSingle.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\HalfVector2.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>HalfVector2.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\HalfVector4.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>HalfVector4.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\L8.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>L8.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\L16.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\L16.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>L16.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\La16.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\La16.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>La16.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\La32.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\La32.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>La32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Rgb24.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgb24.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Rgb24.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Rgba32.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rg32.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Rg32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgba32.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Rgba32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Rgb48.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgb48.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Rgb48.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Rgba64.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgba64.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Rgba64.PixelOperations.Generated.tt</DependentUpon>
@ -156,51 +196,51 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>PixelOperations{TPixel}.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Argb32.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Argb32.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Argb32.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Bgr24.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgr24.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Bgr24.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Bgra32.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgra32.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Bgra32.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Bgra5551.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Bgra5551.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Bgra5551.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\L8.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\L8.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>L8.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\L16.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\L16.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>L16.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\La16.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\La16.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>La16.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\La32.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\La32.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>La32.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Rgb24.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgb24.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Rgb24.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Rgba32.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgba32.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Rgba32.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Rgb48.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgb48.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Rgb48.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Rgba64.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\PixelOperations\Generated\Rgba64.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Rgba64.PixelOperations.Generated.cs</LastGenOutput>
</None>

32
src/ImageSharp/PixelFormats/PixelAlphaRepresentation.cs

@ -0,0 +1,32 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.PixelFormats
{
/// <summary>
/// Provides enumeration of the alpha value transparency behavior of a pixel format.
/// </summary>
public enum PixelAlphaRepresentation
{
/// <summary>
/// Indicates that the pixel format does not contain an alpha channel.
/// </summary>
None,
/// <summary>
/// Indicates that the transparency behavior is premultiplied.
/// Each color is first scaled by the alpha value. The alpha value itself is the same
/// in both straight and premultiplied alpha. Typically, no color channel value is
/// greater than the alpha channel value.
/// If a color channel value in a premultiplied format is greater than the alpha
/// channel, the standard source-over blending math results in an additive blend.
/// </summary>
Associated,
/// <summary>
/// Indicates that the transparency behavior is not premultiplied.
/// The alpha channel indicates the transparency of the color.
/// </summary>
Unassociated
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 0] to [0, 0, 0, 1] in vector form.
/// </para>
/// </summary>
public struct A8 : IPixel<A8>, IPackedVector<byte>
public partial struct A8 : IPixel<A8>, IPackedVector<byte>
{
/// <summary>
/// Initializes a new instance of the <see cref="A8"/> struct.
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(A8 left, A8 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<A8> CreatePixelOperations() => new PixelOperations<A8>();
public readonly PixelOperations<A8> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct Bgr565 : IPixel<Bgr565>, IPackedVector<ushort>
public partial struct Bgr565 : IPixel<Bgr565>, IPackedVector<ushort>
{
/// <summary>
/// Initializes a new instance of the <see cref="Bgr565"/> struct.
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgr565 left, Bgr565 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations<Bgr565>();
public readonly PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct Bgra4444 : IPixel<Bgra4444>, IPackedVector<ushort>
public partial struct Bgra4444 : IPixel<Bgra4444>, IPackedVector<ushort>
{
/// <summary>
/// Initializes a new instance of the <see cref="Bgra4444"/> struct.
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Bgra4444 left, Bgra4444 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations<Bgra4444>();
public readonly PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 0] to [255, 255, 255, 255] in vector form.
/// </para>
/// </summary>
public struct Byte4 : IPixel<Byte4>, IPackedVector<uint>
public partial struct Byte4 : IPixel<Byte4>, IPackedVector<uint>
{
/// <summary>
/// Initializes a new instance of the <see cref="Byte4"/> struct.
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Byte4 left, Byte4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations<Byte4>();
public readonly PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, 0, 0, 1] to [1, 0, 0, 1] in vector form.
/// </para>
/// </summary>
public struct HalfSingle : IPixel<HalfSingle>, IPackedVector<ushort>
public partial struct HalfSingle : IPixel<HalfSingle>, IPackedVector<ushort>
{
/// <summary>
/// Initializes a new instance of the <see cref="HalfSingle"/> struct.
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(HalfSingle left, HalfSingle right) => !left.Equals(right);
/// <inheritdoc />
public PixelOperations<HalfSingle> CreatePixelOperations() => new PixelOperations<HalfSingle>();
public PixelOperations<HalfSingle> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

6
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, 0, 1] to [1, 1, 0, 1] in vector form.
/// </para>
/// </summary>
public struct HalfVector2 : IPixel<HalfVector2>, IPackedVector<uint>
public partial struct HalfVector2 : IPixel<HalfVector2>, IPackedVector<uint>
{
/// <summary>
/// Initializes a new instance of the <see cref="HalfVector2"/> struct.
@ -54,13 +54,13 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(HalfVector2 left, HalfVector2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations<HalfVector2>();
public readonly PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector)
{
var scaled = new Vector2(vector.X, vector.Y) * 2F;
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One;
this.PackedValue = Pack(scaled.X, scaled.Y);
}

4
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, -1, -1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct HalfVector4 : IPixel<HalfVector4>, IPackedVector<ulong>
public partial struct HalfVector4 : IPixel<HalfVector4>, IPackedVector<ulong>
{
/// <summary>
/// Initializes a new instance of the <see cref="HalfVector4"/> struct.
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(HalfVector4 left, HalfVector4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations<HalfVector4>();
public readonly PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, 0, 1] to [1, 1, 0, 1] in vector form.
/// </para>
/// </summary>
public struct NormalizedByte2 : IPixel<NormalizedByte2>, IPackedVector<ushort>
public partial struct NormalizedByte2 : IPixel<NormalizedByte2>, IPackedVector<ushort>
{
private static readonly Vector2 Half = new Vector2(127);
private static readonly Vector2 MinusOne = new Vector2(-1F);
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedByte2 left, NormalizedByte2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations<NormalizedByte2>();
public readonly PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, -1, -1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct NormalizedByte4 : IPixel<NormalizedByte4>, IPackedVector<uint>
public partial struct NormalizedByte4 : IPixel<NormalizedByte4>, IPackedVector<uint>
{
private static readonly Vector4 Half = new Vector4(127);
private static readonly Vector4 MinusOne = new Vector4(-1F);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedByte4 left, NormalizedByte4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations<NormalizedByte4>();
public readonly PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, 0, 1] to [1, 1, 0, 1] in vector form.
/// </para>
/// </summary>
public struct NormalizedShort2 : IPixel<NormalizedShort2>, IPackedVector<uint>
public partial struct NormalizedShort2 : IPixel<NormalizedShort2>, IPackedVector<uint>
{
private static readonly Vector2 Max = new Vector2(0x7FFF);
private static readonly Vector2 Min = Vector2.Negate(Max);
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedShort2 left, NormalizedShort2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations<NormalizedShort2>();
public readonly PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-1, -1, -1, -1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct NormalizedShort4 : IPixel<NormalizedShort4>, IPackedVector<ulong>
public partial struct NormalizedShort4 : IPixel<NormalizedShort4>, IPackedVector<ulong>
{
private static readonly Vector4 Max = new Vector4(0x7FFF);
private static readonly Vector4 Min = Vector4.Negate(Max);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(NormalizedShort4 left, NormalizedShort4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations<NormalizedShort4>();
public readonly PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/A8.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct A8
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<A8>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<A8>(PixelAlphaRepresentation.Unassociated);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr565.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgr565
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgr565>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgr565>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra4444.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgra4444
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgra4444>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra4444>(PixelAlphaRepresentation.Unassociated);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Byte4.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Byte4
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Byte4>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Byte4>(PixelAlphaRepresentation.Unassociated);
}
}
}

64
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Argb32>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Argb32>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<Argb32> destinationPixels)
{
@ -42,16 +45,25 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Argb32> destinationPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<Argb32> destinationPixels,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
public override void ToVector4(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Vector4> destVectors, PixelConversionModifiers modifiers)
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<Vector4> destVectors,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
public override void ToRgba32(
Configuration configuration,
@ -79,6 +91,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToArgb32(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
@ -106,6 +119,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToArgb32(source, dest);
}
/// <inheritdoc />
public override void ToRgb24(
Configuration configuration,
@ -133,6 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToArgb32(source, dest);
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
@ -162,7 +177,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -180,7 +198,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -198,7 +219,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -216,7 +240,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -234,7 +261,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -252,7 +282,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -270,7 +303,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Argb32> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -286,6 +322,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromArgb32(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -294,6 +331,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToArgb32(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Argb32>
{
<# GeneratePixelTypeInfo("Argb32"); #>
<# GenerateAllDefaultConversionMethods("Argb32"); #>
}
}

64
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgr24>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgr24>(PixelAlphaRepresentation.None);
/// <inheritdoc />
public override void FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<Bgr24> destinationPixels)
{
@ -42,16 +45,25 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgr24> destinationPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<Bgr24> destinationPixels,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
public override void ToVector4(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Vector4> destVectors, PixelConversionModifiers modifiers)
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<Vector4> destVectors,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
public override void ToRgba32(
Configuration configuration,
@ -79,6 +91,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgr24(source, dest);
}
/// <inheritdoc />
public override void ToArgb32(
Configuration configuration,
@ -106,6 +119,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgr24(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
@ -133,6 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToBgr24(source, dest);
}
/// <inheritdoc />
public override void ToRgb24(
Configuration configuration,
@ -162,7 +177,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -180,7 +198,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -198,7 +219,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -216,7 +240,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -234,7 +261,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -252,7 +282,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -270,7 +303,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Bgr24> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -286,6 +322,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromBgr24(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -294,6 +331,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToBgr24(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgr24>
{
<# GeneratePixelTypeInfo("Bgr24"); #>
<# GenerateAllDefaultConversionMethods("Bgr24"); #>
}
}

64
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgra32>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra32>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<Bgra32> destinationPixels)
{
@ -42,16 +45,25 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Bgra32> destinationPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<Bgra32> destinationPixels,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
public override void ToVector4(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Vector4> destVectors, PixelConversionModifiers modifiers)
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<Vector4> destVectors,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale));
}
/// <inheritdoc />
public override void ToRgba32(
Configuration configuration,
@ -79,6 +91,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgba32.ToBgra32(source, dest);
}
/// <inheritdoc />
public override void ToArgb32(
Configuration configuration,
@ -106,6 +119,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToBgra32(source, dest);
}
/// <inheritdoc />
public override void ToRgb24(
Configuration configuration,
@ -133,6 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToBgra32(source, dest);
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
@ -162,7 +177,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -180,7 +198,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -198,7 +219,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -216,7 +240,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -234,7 +261,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -252,7 +282,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -270,7 +303,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Bgra32> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -286,6 +322,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromBgra32(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -294,6 +331,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToBgra32(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgra32>
{
<# GeneratePixelTypeInfo("Bgra32"); #>
<# GenerateAllDefaultConversionMethods("Bgra32"); #>
}
}

66
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs

@ -3,13 +3,12 @@
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgra5551>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra5551>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromBgra5551(Configuration configuration, ReadOnlySpan<Bgra5551> source, Span<Bgra5551> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra5551> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Bgra5551> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromBgra5551(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToBgra5551(configuration, sourcePixels, destinationPixels);
}
}
}
}

2
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Bgra5551>
{
<# GeneratePixelTypeInfo("Bgra5551"); #>
<# GenerateAllDefaultConversionMethods("Bgra5551"); #>
}
}

68
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<L16>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<L16>(PixelAlphaRepresentation.None);
/// <inheritdoc />
public override void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<L16> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<L16> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromL16(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToL16(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<L16>
{
<# GeneratePixelTypeInfo("L16"); #>
<# GenerateAllDefaultConversionMethods("L16"); #>
}
}

68
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<L8>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<L8>(PixelAlphaRepresentation.None);
/// <inheritdoc />
public override void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<L8> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<L8> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromL8(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToL8(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<L8>
{
<# GeneratePixelTypeInfo("L8"); #>
<# GenerateAllDefaultConversionMethods("L8"); #>
}
}

66
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs

@ -3,13 +3,12 @@
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<La16>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<La16>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromLa16(Configuration configuration, ReadOnlySpan<La16> source, Span<La16> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<La16> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<La16> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromLa16(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToLa16(configuration, sourcePixels, destinationPixels);
}
}
}
}

2
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<La16>
{
<# GeneratePixelTypeInfo("La16"); #>
<# GenerateAllDefaultConversionMethods("La16"); #>
}
}

66
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs

@ -3,13 +3,12 @@
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<La32>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<La32>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromLa32(Configuration configuration, ReadOnlySpan<La32> source, Span<La32> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<La32> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<La32> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromLa32(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToLa32(configuration, sourcePixels, destinationPixels);
}
}
}
}

2
src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<La32>
{
<# GeneratePixelTypeInfo("La32"); #>
<# GenerateAllDefaultConversionMethods("La32"); #>
}
}

63
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgb24>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgb24>(PixelAlphaRepresentation.None);
/// <inheritdoc />
public override void FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<Rgb24> destinationPixels)
{
@ -42,16 +45,25 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<Rgb24> destinationPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<Rgb24> destinationPixels,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
public override void ToVector4(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Vector4> destVectors, PixelConversionModifiers modifiers)
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<Vector4> destVectors,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply));
}
/// <inheritdoc />
public override void ToRgba32(
Configuration configuration,
@ -107,6 +119,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgb24(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
@ -134,6 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgb24(source, dest);
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
@ -163,7 +177,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -181,7 +198,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -199,7 +219,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -217,7 +240,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -235,7 +261,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -253,7 +282,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -271,7 +303,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Rgb24> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -287,6 +322,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromRgb24(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -295,6 +331,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToRgb24(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgb24>
{
<# GeneratePixelTypeInfo("Rgb24"); #>
<# GenerateAllDefaultConversionMethods("Rgb24"); #>
}
}

68
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgb48>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgb48>(PixelAlphaRepresentation.None);
/// <inheritdoc />
public override void FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<Rgb48> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Rgb48> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromRgb48(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToRgb48(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgb48>
{
<# GeneratePixelTypeInfo("Rgb48"); #>
<# GenerateAllDefaultConversionMethods("Rgb48"); #>
}
}

52
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal partial class PixelOperations : PixelOperations<Rgba32>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgba32>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<Rgba32> destinationPixels)
{
@ -41,6 +44,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.CopyTo(destinationPixels);
}
/// <inheritdoc />
public override void ToArgb32(
Configuration configuration,
@ -68,6 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromArgb32.ToRgba32(source, dest);
}
/// <inheritdoc />
public override void ToBgra32(
Configuration configuration,
@ -95,6 +100,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromBgra32.ToRgba32(source, dest);
}
/// <inheritdoc />
public override void ToRgb24(
Configuration configuration,
@ -122,6 +128,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels);
PixelConverter.FromRgb24.ToRgba32(source, dest);
}
/// <inheritdoc />
public override void ToBgr24(
Configuration configuration,
@ -151,7 +158,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +179,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +200,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +221,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +242,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -241,7 +263,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destinationPixels)
public override void ToRgba64(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<Rgba64> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -259,7 +284,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Rgba32> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -275,6 +303,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromRgba32(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -283,6 +312,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToRgba32(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal partial class PixelOperations : PixelOperations<Rgba32>
{
<# GeneratePixelTypeInfo("Rgba32"); #>
<# GenerateAllDefaultConversionMethods("Rgba32"); #>
}
}

68
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs

@ -1,15 +1,14 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
{
@ -23,6 +22,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgba64>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgba64>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromRgba64(Configuration configuration, ReadOnlySpan<Rgba64> source, Span<Rgba64> destinationPixels)
{
@ -43,7 +46,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destinationPixels)
public override void ToArgb32(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Argb32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -61,7 +67,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destinationPixels)
public override void ToBgr24(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Bgr24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -79,7 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destinationPixels)
public override void ToBgra32(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Bgra32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -97,7 +109,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<L8> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -115,7 +130,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToL16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<L16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -133,7 +151,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La16> destinationPixels)
public override void ToLa16(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<La16> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -151,7 +172,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToLa32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<La32> destinationPixels)
public override void ToLa32(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<La32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -169,7 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destinationPixels)
public override void ToRgb24(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Rgb24> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -187,7 +214,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destinationPixels)
public override void ToRgba32(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Rgba32> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -205,7 +235,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destinationPixels)
public override void ToRgb48(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Rgb48> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -223,7 +256,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
public override void ToBgra5551(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra5551> destinationPixels)
public override void ToBgra5551(
Configuration configuration,
ReadOnlySpan<Rgba64> sourcePixels,
Span<Bgra5551> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -239,6 +275,7 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.FromRgba64(sp);
}
}
/// <inheritdoc />
public override void From<TSourcePixel>(
Configuration configuration,
@ -247,6 +284,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
PixelOperations<TSourcePixel>.Instance.ToRgba64(configuration, sourcePixels, destinationPixels);
}
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.tt

@ -1,6 +1,5 @@
<#@include file="_Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
@ -13,6 +12,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<Rgba64>
{
<# GeneratePixelTypeInfo("Rgba64"); #>
<# GenerateAllDefaultConversionMethods("Rgba64"); #>
}
}

101
src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude

@ -8,19 +8,85 @@
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats.Utils;
using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
<#+
static readonly string[] CommonPixelTypes = { "Argb32", "Bgr24", "Bgra32", "L8", "L16", "La16", "La32", "Rgb24", "Rgba32", "Rgb48", "Rgba64", "Bgra5551" };
static readonly string[] OptimizedPixelTypes = { "Rgba32", "Argb32", "Bgra32", "Rgb24", "Bgr24" };
private static readonly string[] UnassociatedAlphaPixelTypes =
{
"A8",
"Argb32",
"Bgra32",
"Bgra4444",
"Bgra5551",
"Byte4",
"HalfVector4",
"La16",
"La32",
"NormalizedByte4",
"NormalizedShort4",
"Rgba1010102",
"Rgba32",
"Rgba64",
"RgbaVector",
"Short4"
};
private static readonly string[] AssociatedAlphaPixelTypes = Array.Empty<string>();
private static readonly string[] CommonPixelTypes =
{
"Argb32",
"Bgr24",
"Bgra32",
"L8",
"L16",
"La16",
"La32",
"Rgb24",
"Rgba32",
"Rgb48",
"Rgba64",
"Bgra5551"
};
private static readonly string[] OptimizedPixelTypes =
{
"Rgba32",
"Argb32",
"Bgra32",
"Rgb24",
"Bgr24"
};
// Types with Rgba32-combatable to/from Vector4 conversion
private static readonly string[] Rgba32CompatibleTypes =
{
"Argb32",
"Bgra32",
"Rgb24",
"Bgr24"
};
// Types with Rgba32-combatible to/from Vector4 conversion
static readonly string[] Rgba32CompatibleTypes = { "Argb32", "Bgra32", "Rgb24", "Bgr24" };
void GeneratePixelTypeInfo(string pixelType)
{
string alpha = "PixelAlphaRepresentation.None";
if (AssociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Associated";
}
else if (UnassociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Unassociated";
}
#>
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<<#=pixelType#>>(<#=alpha#>);
<#+
}
void GenerateGenericConverterMethods(string pixelType)
{
@ -33,13 +99,14 @@ using System.Runtime.InteropServices;
{
PixelOperations<TSourcePixel>.Instance.To<#=pixelType#>(configuration, sourcePixels, destinationPixels);
}
<#+
}
void GenerateDefaultSelfConversionMethods(string pixelType)
{
#>
/// <inheritdoc />
/// <inheritdoc />
public override void From<#=pixelType#>(Configuration configuration, ReadOnlySpan<<#=pixelType#>> source, Span<<#=pixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
@ -63,9 +130,11 @@ using System.Runtime.InteropServices;
void GenerateDefaultConvertToMethod(string fromPixelType, string toPixelType)
{
#>
/// <inheritdoc />
public override void To<#=toPixelType#>(Configuration configuration, ReadOnlySpan<<#=fromPixelType#>> sourcePixels, Span<<#=toPixelType#>> destinationPixels)
public override void To<#=toPixelType#>(
Configuration configuration,
ReadOnlySpan<<#=fromPixelType#>> sourcePixels,
Span<<#=toPixelType#>> destinationPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -126,13 +195,21 @@ using System.Runtime.InteropServices;
}
#>
/// <inheritdoc />
public override void FromVector4Destructive(Configuration configuration, Span<Vector4> sourceVectors, Span<<#=pixelType#>> destinationPixels, PixelConversionModifiers modifiers)
public override void FromVector4Destructive(
Configuration configuration,
Span<Vector4> sourceVectors,
Span<<#=pixelType#>> destinationPixels,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destinationPixels, modifiers.Remove(<#=removeTheseModifiers#>));
}
/// <inheritdoc />
public override void ToVector4(Configuration configuration, ReadOnlySpan<<#=pixelType#>> sourcePixels, Span<Vector4> destVectors, PixelConversionModifiers modifiers)
public override void ToVector4(
Configuration configuration,
ReadOnlySpan<<#=pixelType#>> sourcePixels,
Span<Vector4> destVectors,
PixelConversionModifiers modifiers)
{
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(<#=removeTheseModifiers#>));
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfSingle.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct HalfSingle
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<HalfSingle>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfSingle>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector2.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct HalfVector2
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<HalfVector2>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfVector2>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector4.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct HalfVector4
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<HalfVector4>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfVector4>(PixelAlphaRepresentation.Unassociated);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte2.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct NormalizedByte2
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<NormalizedByte2>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedByte2>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte4.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct NormalizedByte4
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<NormalizedByte4>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedByte4>(PixelAlphaRepresentation.Unassociated);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort2.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct NormalizedShort2
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<NormalizedShort2>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedShort2>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort4.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct NormalizedShort4
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<NormalizedShort4>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedShort4>(PixelAlphaRepresentation.Unassociated);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rg32.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rg32
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rg32>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rg32>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba1010102.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgba1010102
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgba1010102>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgba1010102>(PixelAlphaRepresentation.Unassociated);
}
}
}

0
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.PixelOperations.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba32.PixelOperations.cs

15
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs → src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs

@ -5,7 +5,7 @@ using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats.Utils;
namespace SixLabors.ImageSharp.PixelFormats
@ -20,6 +20,9 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
internal class PixelOperations : PixelOperations<RgbaVector>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedShort4>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public override void FromVector4Destructive(
Configuration configuration,
@ -46,7 +49,10 @@ namespace SixLabors.ImageSharp.PixelFormats
Vector4Converters.ApplyForwardConversionModifiers(destinationVectors, modifiers);
}
public override void ToL8(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L8> destinationPixels)
public override void ToL8(
Configuration configuration,
ReadOnlySpan<RgbaVector> sourcePixels,
Span<L8> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));
@ -62,7 +68,10 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
public override void ToL16(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L16> destinationPixels)
public override void ToL16(
Configuration configuration,
ReadOnlySpan<RgbaVector> sourcePixels,
Span<L16> destinationPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short2.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Short2
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Short2>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Short2>(PixelAlphaRepresentation.None);
}
}
}

22
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short4.PixelOperations.cs

@ -0,0 +1,22 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Short4
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Short4>
{
/// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Short4>(PixelAlphaRepresentation.Unassociated);
}
}
}

4
src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 0, 1] in vector form.
/// </para>
/// </summary>
public struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
public partial struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
{
private static readonly Vector2 Max = new Vector2(ushort.MaxValue);
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rg32 left, Rg32 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations<Rg32>();
public readonly PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
public partial struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
{
private static readonly Vector4 Multiplier = new Vector4(1023F, 1023F, 1023F, 3F);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Rgba1010102 left, Rgba1010102 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations<Rgba1010102>();
public readonly PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-32767, -32767, 0, 1] to [32767, 32767, 0, 1] in vector form.
/// </para>
/// </summary>
public struct Short2 : IPixel<Short2>, IPackedVector<uint>
public partial struct Short2 : IPixel<Short2>, IPackedVector<uint>
{
// Largest two byte positive number 0xFFFF >> 1;
private const float MaxPos = 0x7FFF;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Short2 left, Short2 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Short2> CreatePixelOperations() => new PixelOperations<Short2>();
public readonly PixelOperations<Short2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

4
src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [-37267, -37267, -37267, -37267] to [37267, 37267, 37267, 37267] in vector form.
/// </para>
/// </summary>
public struct Short4 : IPixel<Short4>, IPackedVector<ulong>
public partial struct Short4 : IPixel<Short4>, IPackedVector<ulong>
{
// Largest two byte positive number 0xFFFF >> 1;
private const float MaxPos = 0x7FFF;
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public static bool operator !=(Short4 left, Short4 right) => !left.Equals(right);
/// <inheritdoc />
public readonly PixelOperations<Short4> CreatePixelOperations() => new PixelOperations<Short4>();
public readonly PixelOperations<Short4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -4,7 +4,7 @@
using System;
using System.Buffers;
using System.Numerics;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.PixelFormats
@ -22,6 +22,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary>
public static PixelOperations<TPixel> Instance { get; } = default(TPixel).CreatePixelOperations();
/// <summary>
/// Gets the pixel type info for the given <typeparamref name="TPixel"/>.
/// </summary>
/// <returns>The <see cref="PixelTypeInfo"/>.</returns>
public virtual PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<TPixel>();
/// <summary>
/// Bulk version of <see cref="IPixel.FromVector4"/> converting 'sourceVectors.Length' pixels into 'destinationColors'.
/// The method is DESTRUCTIVE altering the contents of <paramref name="sourceVectors"/>.
@ -108,28 +114,27 @@ namespace SixLabors.ImageSharp.PixelFormats
{
const int SliceLength = 1024;
int numberOfSlices = sourcePixels.Length / SliceLength;
using (IMemoryOwner<Vector4> tempVectors = configuration.MemoryAllocator.Allocate<Vector4>(SliceLength))
using IMemoryOwner<Vector4> tempVectors = configuration.MemoryAllocator.Allocate<Vector4>(SliceLength);
Span<Vector4> vectorSpan = tempVectors.GetSpan();
for (int i = 0; i < numberOfSlices; i++)
{
Span<Vector4> vectorSpan = tempVectors.GetSpan();
for (int i = 0; i < numberOfSlices; i++)
{
int start = i * SliceLength;
ReadOnlySpan<TSourcePixel> s = sourcePixels.Slice(start, SliceLength);
Span<TPixel> d = destinationPixels.Slice(start, SliceLength);
PixelOperations<TSourcePixel>.Instance.ToVector4(configuration, s, vectorSpan);
this.FromVector4Destructive(configuration, vectorSpan, d);
}
int start = i * SliceLength;
ReadOnlySpan<TSourcePixel> s = sourcePixels.Slice(start, SliceLength);
Span<TPixel> d = destinationPixels.Slice(start, SliceLength);
PixelOperations<TSourcePixel>.Instance.ToVector4(configuration, s, vectorSpan);
this.FromVector4Destructive(configuration, vectorSpan, d);
}
int endOfCompleteSlices = numberOfSlices * SliceLength;
int remainder = sourcePixels.Length - endOfCompleteSlices;
if (remainder > 0)
{
ReadOnlySpan<TSourcePixel> s = sourcePixels.Slice(endOfCompleteSlices);
Span<TPixel> d = destinationPixels.Slice(endOfCompleteSlices);
vectorSpan = vectorSpan.Slice(0, remainder);
PixelOperations<TSourcePixel>.Instance.ToVector4(configuration, s, vectorSpan);
this.FromVector4Destructive(configuration, vectorSpan, d);
}
int endOfCompleteSlices = numberOfSlices * SliceLength;
int remainder = sourcePixels.Length - endOfCompleteSlices;
if (remainder > 0)
{
ReadOnlySpan<TSourcePixel> s = sourcePixels.Slice(endOfCompleteSlices);
Span<TPixel> d = destinationPixels.Slice(endOfCompleteSlices);
vectorSpan = vectorSpan.Slice(0, remainder);
PixelOperations<TSourcePixel>.Instance.ToVector4(configuration, s, vectorSpan);
this.FromVector4Destructive(configuration, vectorSpan, d);
}
}

2
tests/ImageSharp.Tests.ProfilingSandbox/Program.cs

@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.ProfilingSandbox
private static void RunToVector4ProfilingTest()
{
var tests = new PixelOperationsTests.Rgba32OperationsTests(new ConsoleOutput());
var tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput());
tests.Benchmark_ToVector4();
}

24
tests/ImageSharp.Tests/ImageSharp.Tests.csproj

@ -17,6 +17,14 @@
<InternalsVisibleTo Include="ImageSharp.Tests.ProfilingSandbox" Key="$(SixLaborsPublicKey)" />
</ItemGroup>
<ItemGroup>
<None Include="PixelFormats\PixelOperations\Generated\PixelOperationsTests.Specialized.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>PixelOperationsTests.Specialized.Generated.tt</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
@ -27,6 +35,10 @@
</ItemGroup>
<ItemGroup>
<None Update="PixelFormats\PixelOperations\Generated\PixelOperationsTests.Specialized.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>PixelOperationsTests.Specialized.Generated.cs</LastGenOutput>
</None>
<None Update="TestFonts\OpenSans-Regular.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -38,5 +50,17 @@
</None>
</ItemGroup>
<ItemGroup>
<Compile Update="PixelFormats\PixelOperations\Generated\PixelOperationsTests.Specialized.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>PixelOperationsTests.Specialized.Generated.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>

718
tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs

@ -0,0 +1,718 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public partial class A8_OperationsTests : PixelOperationsTests<A8>
{
public A8_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<A8.PixelOperations>(PixelOperations<A8>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = A8.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<A8>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = A8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Argb32_OperationsTests : PixelOperationsTests<Argb32>
{
public Argb32_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Argb32.PixelOperations>(PixelOperations<Argb32>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Argb32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Argb32>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Argb32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Bgr24_OperationsTests : PixelOperationsTests<Bgr24>
{
public Bgr24_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgr24.PixelOperations>(PixelOperations<Bgr24>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Bgr24.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Bgr24>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Bgr24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Bgr565_OperationsTests : PixelOperationsTests<Bgr565>
{
public Bgr565_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgr565.PixelOperations>(PixelOperations<Bgr565>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Bgr565.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Bgr565>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Bgr565.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Bgra32_OperationsTests : PixelOperationsTests<Bgra32>
{
public Bgra32_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgra32.PixelOperations>(PixelOperations<Bgra32>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Bgra32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Bgra32>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Bgra32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Bgra4444_OperationsTests : PixelOperationsTests<Bgra4444>
{
public Bgra4444_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgra4444.PixelOperations>(PixelOperations<Bgra4444>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Bgra4444.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Bgra4444>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Bgra4444.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Bgra5551_OperationsTests : PixelOperationsTests<Bgra5551>
{
public Bgra5551_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgra5551.PixelOperations>(PixelOperations<Bgra5551>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Bgra5551.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Bgra5551>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Bgra5551.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Byte4_OperationsTests : PixelOperationsTests<Byte4>
{
public Byte4_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Byte4.PixelOperations>(PixelOperations<Byte4>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Byte4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Byte4>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Byte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class HalfSingle_OperationsTests : PixelOperationsTests<HalfSingle>
{
public HalfSingle_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<HalfSingle.PixelOperations>(PixelOperations<HalfSingle>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = HalfSingle.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<HalfSingle>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = HalfSingle.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class HalfVector2_OperationsTests : PixelOperationsTests<HalfVector2>
{
public HalfVector2_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<HalfVector2.PixelOperations>(PixelOperations<HalfVector2>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = HalfVector2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<HalfVector2>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = HalfVector2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class HalfVector4_OperationsTests : PixelOperationsTests<HalfVector4>
{
public HalfVector4_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<HalfVector4.PixelOperations>(PixelOperations<HalfVector4>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = HalfVector4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<HalfVector4>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = HalfVector4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class L16_OperationsTests : PixelOperationsTests<L16>
{
public L16_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<L16.PixelOperations>(PixelOperations<L16>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = L16.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<L16>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = L16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class L8_OperationsTests : PixelOperationsTests<L8>
{
public L8_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<L8.PixelOperations>(PixelOperations<L8>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = L8.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<L8>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = L8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class La16_OperationsTests : PixelOperationsTests<La16>
{
public La16_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<La16.PixelOperations>(PixelOperations<La16>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = La16.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<La16>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = La16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class La32_OperationsTests : PixelOperationsTests<La32>
{
public La32_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<La32.PixelOperations>(PixelOperations<La32>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = La32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<La32>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = La32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class NormalizedByte2_OperationsTests : PixelOperationsTests<NormalizedByte2>
{
public NormalizedByte2_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<NormalizedByte2.PixelOperations>(PixelOperations<NormalizedByte2>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = NormalizedByte2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<NormalizedByte2>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = NormalizedByte2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class NormalizedByte4_OperationsTests : PixelOperationsTests<NormalizedByte4>
{
public NormalizedByte4_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<NormalizedByte4.PixelOperations>(PixelOperations<NormalizedByte4>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = NormalizedByte4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<NormalizedByte4>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = NormalizedByte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class NormalizedShort2_OperationsTests : PixelOperationsTests<NormalizedShort2>
{
public NormalizedShort2_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<NormalizedShort2.PixelOperations>(PixelOperations<NormalizedShort2>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = NormalizedShort2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<NormalizedShort2>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = NormalizedShort2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class NormalizedShort4_OperationsTests : PixelOperationsTests<NormalizedShort4>
{
public NormalizedShort4_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<NormalizedShort4.PixelOperations>(PixelOperations<NormalizedShort4>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = NormalizedShort4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<NormalizedShort4>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = NormalizedShort4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Rg32_OperationsTests : PixelOperationsTests<Rg32>
{
public Rg32_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rg32.PixelOperations>(PixelOperations<Rg32>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rg32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rg32>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rg32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Rgb24_OperationsTests : PixelOperationsTests<Rgb24>
{
public Rgb24_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgb24.PixelOperations>(PixelOperations<Rgb24>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rgb24.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rgb24>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rgb24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Rgb48_OperationsTests : PixelOperationsTests<Rgb48>
{
public Rgb48_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgb48.PixelOperations>(PixelOperations<Rgb48>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rgb48.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rgb48>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rgb48.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Rgba1010102_OperationsTests : PixelOperationsTests<Rgba1010102>
{
public Rgba1010102_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgba1010102.PixelOperations>(PixelOperations<Rgba1010102>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rgba1010102.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rgba1010102>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rgba1010102.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Rgba32_OperationsTests : PixelOperationsTests<Rgba32>
{
public Rgba32_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgba32.PixelOperations>(PixelOperations<Rgba32>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rgba32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rgba32>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rgba32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Rgba64_OperationsTests : PixelOperationsTests<Rgba64>
{
public Rgba64_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgba64.PixelOperations>(PixelOperations<Rgba64>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Rgba64.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Rgba64>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Rgba64.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class RgbaVector_OperationsTests : PixelOperationsTests<RgbaVector>
{
public RgbaVector_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<RgbaVector.PixelOperations>(PixelOperations<RgbaVector>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = RgbaVector.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<RgbaVector>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = RgbaVector.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
public partial class Short2_OperationsTests : PixelOperationsTests<Short2>
{
public Short2_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Short2.PixelOperations>(PixelOperations<Short2>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Short2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Short2>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Short2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
public partial class Short4_OperationsTests : PixelOperationsTests<Short4>
{
public Short4_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Short4.PixelOperations>(PixelOperations<Short4>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = Short4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<Short4>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = Short4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
}
}

11
tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.tt

@ -0,0 +1,11 @@
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
<# GenerateAllSpecializedClasses(); #>
}
}

117
tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude

@ -0,0 +1,117 @@
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
<#+
private static readonly string[] UnassociatedAlphaPixelTypes =
{
"A8",
"Argb32",
"Bgra32",
"Bgra4444",
"Bgra5551",
"Byte4",
"HalfVector4",
"La16",
"La32",
"NormalizedByte4",
"NormalizedShort4",
"Rgba1010102",
"Rgba32",
"Rgba64",
"RgbaVector",
"Short4"
};
private static readonly string[] AssociatedAlphaPixelTypes = Array.Empty<string>();
private static readonly string[] CommonPixelTypes =
{
"A8",
"Argb32",
"Bgr24",
"Bgr565",
"Bgra32",
"Bgra4444",
"Bgra5551",
"Byte4",
"HalfSingle",
"HalfVector2",
"HalfVector4",
"L16",
"L8",
"La16",
"La32",
"NormalizedByte2",
"NormalizedByte4",
"NormalizedShort2",
"NormalizedShort4",
"Rg32",
"Rgb24",
"Rgb48",
"Rgba1010102",
"Rgba32",
"Rgba64",
"RgbaVector",
"Short2",
"Short4",
};
void GenerateSpecializedClass(string pixelType, string alpha)
{
#>
public partial class <#=pixelType#>_OperationsTests : PixelOperationsTests<<#=pixelType#>>
{
public <#=pixelType#>_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<<#=pixelType#>.PixelOperations>(PixelOperations<<#=pixelType#>>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectBitsPerPixel()
{
var bits = <#=pixelType#>.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
Assert.Equal(Unsafe.SizeOf<<#=pixelType#>>() * 8, bits);
}
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = <#=pixelType#>.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(<#=alpha#>, alphaRepresentation);
}
}
<#+
}
void GenerateAllSpecializedClasses()
{
foreach (string pixelType in CommonPixelTypes)
{
string alpha = "PixelAlphaRepresentation.None";
if (AssociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Associated";
}
else if (UnassociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Unassociated";
}
GenerateSpecializedClass(pixelType, alpha);
}
}
#>

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Argb32OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Argb32OperationsTests : PixelOperationsTests<Argb32>
{
public Argb32OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Argb32.PixelOperations>(PixelOperations<Argb32>.Instance);
}
}
}

25
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgr24OperationsTests.cs

@ -1,25 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Bgr24OperationsTests : PixelOperationsTests<Bgr24>
{
public Bgr24OperationsTests(ITestOutputHelper output)
: base(output)
{
this.HasAlpha = false;
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgr24.PixelOperations>(PixelOperations<Bgr24>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgra32OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Bgra32OperationsTests : PixelOperationsTests<Bgra32>
{
public Bgra32OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Bgra32.PixelOperations>(PixelOperations<Bgra32>.Instance);
}
}
}

20
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Bgra5551OperationsTests.cs

@ -1,20 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Bgra5551OperationsTests : PixelOperationsTests<Bgra5551>
{
public Bgra5551OperationsTests(ITestOutputHelper output)
: base(output)
{
}
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L16OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class L16OperationsTests : PixelOperationsTests<L16>
{
public L16OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<L16.PixelOperations>(PixelOperations<L16>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L8OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class L8OperationsTests : PixelOperationsTests<L8>
{
public L8OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<L8.PixelOperations>(PixelOperations<L8>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La16OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class La16OperationsTests : PixelOperationsTests<La16>
{
public La16OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<La16.PixelOperations>(PixelOperations<La16>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La32OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class La32OperationsTests : PixelOperationsTests<La32>
{
public La32OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<La32.PixelOperations>(PixelOperations<La32>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgb24OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Rgb24OperationsTests : PixelOperationsTests<Rgb24>
{
public Rgb24OperationsTests(ITestOutputHelper output)
: base(output)
{
this.HasAlpha = false;
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgb24.PixelOperations>(PixelOperations<Rgb24>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgb48OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Rgb48OperationsTests : PixelOperationsTests<Rgb48>
{
public Rgb48OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgb48.PixelOperations>(PixelOperations<Rgb48>.Instance);
}
}
}

17
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgba32OperationsTests.cs

@ -1,29 +1,18 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Buffers;
using System.Numerics;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Rgba32OperationsTests : PixelOperationsTests<Rgba32>
public partial class Rgba32_OperationsTests : PixelOperationsTests<Rgba32>
{
public Rgba32OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgba32.PixelOperations>(PixelOperations<Rgba32>.Instance);
[Fact(Skip = SkipProfilingBenchmarks)]
public void Benchmark_ToVector4()
{
@ -43,4 +32,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
}
}
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Rgba64OperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Rgba64OperationsTests : PixelOperationsTests<Rgba64>
{
public Rgba64OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Rgba64.PixelOperations>(PixelOperations<Rgba64>.Instance);
}
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.RgbaVectorOperationsTests.cs

@ -1,24 +0,0 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class RgbaVectorOperationsTests : PixelOperationsTests<RgbaVector>
{
public RgbaVectorOperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<RgbaVector.PixelOperations>(PixelOperations<RgbaVector>.Instance);
}
}
}

2
tests/Images/External

@ -1 +1 @@
Subproject commit 8b43d14d21ce9b436af3d12a70d38402cdba176b
Subproject commit cc6465910d092319ef9bf4e99698a0649996d3c5
Loading…
Cancel
Save