Browse Source

Switched pixel format type constraint to unmanaged

pull/1122/head
Sergio Pedri 6 years ago
parent
commit
5cccfbcacd
  1. 16
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  2. 14
      src/ImageSharp/Advanced/AotCompilerTools.cs
  3. 2
      src/ImageSharp/Advanced/IImageVisitor.cs
  4. 2
      src/ImageSharp/Advanced/IPixelSource.cs
  5. 4
      src/ImageSharp/Color/Color.cs
  6. 2
      src/ImageSharp/Common/Helpers/Buffer2DUtils.cs
  7. 12
      src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs
  8. 2
      src/ImageSharp/Common/Helpers/ImageMaths.cs
  9. 2
      src/ImageSharp/Formats/Bmp/BmpDecoder.cs
  10. 20
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  11. 2
      src/ImageSharp/Formats/Bmp/BmpEncoder.cs
  12. 16
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  13. 2
      src/ImageSharp/Formats/Gif/GifDecoder.cs
  14. 8
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  15. 2
      src/ImageSharp/Formats/Gif/GifEncoder.cs
  16. 14
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  17. 2
      src/ImageSharp/Formats/IImageDecoder.cs
  18. 2
      src/ImageSharp/Formats/IImageEncoder.cs
  19. 6
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs
  20. 2
      src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
  21. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
  22. 4
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  23. 2
      src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
  24. 8
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
  25. 2
      src/ImageSharp/Formats/PixelTypeInfo.cs
  26. 2
      src/ImageSharp/Formats/Png/PngDecoder.cs
  27. 14
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  28. 2
      src/ImageSharp/Formats/Png/PngEncoder.cs
  29. 20
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  30. 10
      src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs
  31. 20
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  32. 2
      src/ImageSharp/Formats/Tga/TgaDecoder.cs
  33. 16
      src/ImageSharp/Formats/Tga/TgaDecoderCore.cs
  34. 2
      src/ImageSharp/Formats/Tga/TgaEncoder.cs
  35. 18
      src/ImageSharp/Formats/Tga/TgaEncoderCore.cs
  36. 4
      src/ImageSharp/Image.Decode.cs
  37. 24
      src/ImageSharp/Image.FromBytes.cs
  38. 12
      src/ImageSharp/Image.FromFile.cs
  39. 12
      src/ImageSharp/Image.FromStream.cs
  40. 16
      src/ImageSharp/Image.LoadPixelData.cs
  41. 12
      src/ImageSharp/Image.WrapMemory.cs
  42. 6
      src/ImageSharp/Image.cs
  43. 2
      src/ImageSharp/ImageExtensions.Internal.cs
  44. 2
      src/ImageSharp/ImageExtensions.cs
  45. 4
      src/ImageSharp/ImageFrame.LoadPixelData.cs
  46. 2
      src/ImageSharp/ImageFrame.cs
  47. 2
      src/ImageSharp/ImageFrameCollection{TPixel}.cs
  48. 8
      src/ImageSharp/ImageFrame{TPixel}.cs
  49. 2
      src/ImageSharp/Image{TPixel}.cs
  50. 2
      src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs
  51. 2
      src/ImageSharp/PixelFormats/IPixel.cs
  52. 2
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  53. 2
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  54. 216
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  55. 2
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  56. 6
      src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs
  57. 2
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs
  58. 6
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  59. 16
      src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs
  60. 4
      src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs
  61. 2
      src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
  62. 18
      src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
  63. 4
      src/ImageSharp/Processing/IImageProcessingContextFactory.cs
  64. 2
      src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs
  65. 2
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
  66. 2
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
  67. 2
      src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
  68. 2
      src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
  69. 2
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
  70. 2
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
  71. 2
      src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs
  72. 2
      src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs
  73. 2
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs
  74. 2
      src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
  75. 2
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
  76. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
  77. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
  78. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs
  79. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
  80. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs
  81. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs
  82. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
  83. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs
  84. 6
      src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs
  85. 4
      src/ImageSharp/Processing/Processors/Dithering/IDither.cs
  86. 10
      src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs
  87. 2
      src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs
  88. 2
      src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs
  89. 6
      src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs
  90. 4
      src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
  91. 2
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs
  92. 2
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  93. 2
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs
  94. 2
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs
  95. 2
      src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs
  96. 2
      src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs
  97. 2
      src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs
  98. 2
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
  99. 2
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
  100. 2
      src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs

16
src/ImageSharp/Advanced/AdvancedImageExtensions.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Advanced
/// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>. /// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>.
/// </remarks> /// </remarks>
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source) public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source)); => source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
/// <summary> /// <summary>
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Advanced
/// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>. /// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>.
/// </remarks> /// </remarks>
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source) public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source)); => source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
/// <summary> /// <summary>
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Advanced
[Obsolete( [Obsolete(
@"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")] @"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")]
public static Span<TPixel> GetPixelSpan<TPixel>(this ImageFrame<TPixel> source) public static Span<TPixel> GetPixelSpan<TPixel>(this ImageFrame<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Advanced
[Obsolete( [Obsolete(
@"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")] @"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")]
public static Span<TPixel> GetPixelSpan<TPixel>(this Image<TPixel> source) public static Span<TPixel> GetPixelSpan<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="rowIndex">The row.</param> /// <param name="rowIndex">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns> /// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelRowSpan<TPixel>(this ImageFrame<TPixel> source, int rowIndex) public static Span<TPixel> GetPixelRowSpan<TPixel>(this ImageFrame<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="rowIndex">The row.</param> /// <param name="rowIndex">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns> /// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelRowSpan<TPixel>(this Image<TPixel> source, int rowIndex) public static Span<TPixel> GetPixelRowSpan<TPixel>(this Image<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="rowIndex">The row.</param> /// <param name="rowIndex">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns> /// <returns>The <see cref="Span{TPixel}"/></returns>
public static Memory<TPixel> GetPixelRowMemory<TPixel>(this ImageFrame<TPixel> source, int rowIndex) public static Memory<TPixel> GetPixelRowMemory<TPixel>(this ImageFrame<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="rowIndex">The row.</param> /// <param name="rowIndex">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns> /// <returns>The <see cref="Span{TPixel}"/></returns>
public static Memory<TPixel> GetPixelRowMemory<TPixel>(this Image<TPixel> source, int rowIndex) public static Memory<TPixel> GetPixelRowMemory<TPixel>(this Image<TPixel> source, int rowIndex)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));

14
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void Seed<TPixel>() private static void Seed<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// This is we actually call all the individual methods you need to seed. // This is we actually call all the individual methods you need to seed.
AotCompileOctreeQuantizer<TPixel>(); AotCompileOctreeQuantizer<TPixel>();
@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCompileOctreeQuantizer<TPixel>() private static void AotCompileOctreeQuantizer<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var test = new OctreeFrameQuantizer<TPixel>(Configuration.Default, new OctreeQuantizer().Options)) using (var test = new OctreeFrameQuantizer<TPixel>(Configuration.Default, new OctreeQuantizer().Options))
{ {
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCompileWuQuantizer<TPixel>() private static void AotCompileWuQuantizer<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var test = new WuFrameQuantizer<TPixel>(Configuration.Default, new WuQuantizer().Options)) using (var test = new WuFrameQuantizer<TPixel>(Configuration.Default, new WuQuantizer().Options))
{ {
@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCompilePaletteQuantizer<TPixel>() private static void AotCompilePaletteQuantizer<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var test = (PaletteFrameQuantizer<TPixel>)new PaletteQuantizer(Array.Empty<Color>()).CreateFrameQuantizer<TPixel>(Configuration.Default)) using (var test = (PaletteFrameQuantizer<TPixel>)new PaletteQuantizer(Array.Empty<Color>()).CreateFrameQuantizer<TPixel>(Configuration.Default))
{ {
@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCompileDithering<TPixel>() private static void AotCompileDithering<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ErrorDither errorDither = ErrorDither.FloydSteinberg; ErrorDither errorDither = ErrorDither.FloydSteinberg;
OrderedDither orderedDither = OrderedDither.Bayer2x2; OrderedDither orderedDither = OrderedDither.Bayer2x2;
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="encoder">The image encoder to seed.</param> /// <param name="encoder">The image encoder to seed.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCodec<TPixel>(IImageDecoder decoder, IImageEncoder encoder) private static void AotCodec<TPixel>(IImageDecoder decoder, IImageEncoder encoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
try try
{ {
@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
private static void AotCompilePixelOperations<TPixel>() private static void AotCompilePixelOperations<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var pixelOp = new PixelOperations<TPixel>(); var pixelOp = new PixelOperations<TPixel>();
pixelOp.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.Clear); pixelOp.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.Clear);

2
src/ImageSharp/Advanced/IImageVisitor.cs

@ -17,6 +17,6 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="image">The image.</param> /// <param name="image">The image.</param>
/// <typeparam name="TPixel">The pixel type.</typeparam> /// <typeparam name="TPixel">The pixel type.</typeparam>
void Visit<TPixel>(Image<TPixel> image) void Visit<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
} }
} }

2
src/ImageSharp/Advanced/IPixelSource.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Advanced
/// </summary> /// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam> /// <typeparam name="TPixel">The type of the pixel.</typeparam>
internal interface IPixelSource<TPixel> internal interface IPixelSource<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Gets the pixel buffer. /// Gets the pixel buffer.

4
src/ImageSharp/Color/Color.cs

@ -220,7 +220,7 @@ namespace SixLabors.ImageSharp
/// <returns>The pixel value.</returns> /// <returns>The pixel value.</returns>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public TPixel ToPixel<TPixel>() public TPixel ToPixel<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
pixel.FromRgba64(this.data); pixel.FromRgba64(this.data);
@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp
Configuration configuration, Configuration configuration,
ReadOnlySpan<Color> source, ReadOnlySpan<Color> source,
Span<TPixel> destination) Span<TPixel> destination)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ReadOnlySpan<Rgba64> rgba64Span = MemoryMarshal.Cast<Color, Rgba64>(source); ReadOnlySpan<Rgba64> rgba64Span = MemoryMarshal.Cast<Color, Rgba64>(source);
PixelOperations<TPixel>.Instance.FromRgba64(configuration, rgba64Span, destination); PixelOperations<TPixel>.Instance.FromRgba64(configuration, rgba64Span, destination);

2
src/ImageSharp/Common/Helpers/Buffer2DUtils.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp
int maxRow, int maxRow,
int minColumn, int minColumn,
int maxColumn) int maxColumn)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ComplexVector4 vector = default; ComplexVector4 vector = default;
int kernelLength = kernel.Length; int kernelLength = kernel.Length;

12
src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp
int maxRow, int maxRow,
int minColumn, int minColumn,
int maxColumn) int maxColumn)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Convolve2DImpl( Convolve2DImpl(
in matrixY, in matrixY,
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp
int maxRow, int maxRow,
int minColumn, int minColumn,
int maxColumn) int maxColumn)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Convolve2DImpl( Convolve2DImpl(
in matrixY, in matrixY,
@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp
int minColumn, int minColumn,
int maxColumn, int maxColumn,
out Vector4 vector) out Vector4 vector)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Vector4 vectorY = default; Vector4 vectorY = default;
Vector4 vectorX = default; Vector4 vectorX = default;
@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp
int maxRow, int maxRow,
int minColumn, int minColumn,
int maxColumn) int maxColumn)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Vector4 vector = default; Vector4 vector = default;
@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp
int maxRow, int maxRow,
int minColumn, int minColumn,
int maxColumn) int maxColumn)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Vector4 vector = default; Vector4 vector = default;
@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp
int minColumn, int minColumn,
int maxColumn, int maxColumn,
ref Vector4 vector) ref Vector4 vector)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int matrixHeight = matrix.Rows; int matrixHeight = matrix.Rows;
int matrixWidth = matrix.Columns; int matrixWidth = matrix.Columns;

2
src/ImageSharp/Common/Helpers/ImageMaths.cs

@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp
/// The <see cref="Rectangle"/>. /// The <see cref="Rectangle"/>.
/// </returns> /// </returns>
public static Rectangle GetFilteredBoundingRectangle<TPixel>(ImageFrame<TPixel> bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B) public static Rectangle GetFilteredBoundingRectangle<TPixel>(ImageFrame<TPixel> bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int width = bitmap.Width; int width = bitmap.Width;
int height = bitmap.Height; int height = bitmap.Height;

2
src/ImageSharp/Formats/Bmp/BmpDecoder.cs

@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));

20
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// </exception> /// </exception>
/// <returns>The decoded image.</returns> /// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Stream stream) public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
try try
{ {
@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="pixels">The output pixel buffer containing the decoded image.</param> /// <param name="pixels">The output pixel buffer containing the decoded image.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadBitFields<TPixel>(Buffer2D<TPixel> pixels, bool inverted) private void ReadBitFields<TPixel>(Buffer2D<TPixel> pixels, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (this.infoHeader.BitsPerPixel == 16) if (this.infoHeader.BitsPerPixel == 16)
{ {
@ -296,7 +296,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="height">The height of the bitmap.</param> /// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRle<TPixel>(BmpCompression compression, Buffer2D<TPixel> pixels, byte[] colors, int width, int height, bool inverted) private void ReadRle<TPixel>(BmpCompression compression, Buffer2D<TPixel> pixels, byte[] colors, int width, int height, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel color = default; TPixel color = default;
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height, AllocationOptions.Clean)) using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height, AllocationOptions.Clean))
@ -376,7 +376,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="height">The height of the bitmap.</param> /// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRle24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted) private void ReadRle24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel color = default; TPixel color = default;
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * 3, AllocationOptions.Clean)) using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * 3, AllocationOptions.Clean))
@ -814,7 +814,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// the bytes per color palette entry's can be 3 bytes instead of 4.</param> /// the bytes per color palette entry's can be 3 bytes instead of 4.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgbPalette<TPixel>(Buffer2D<TPixel> pixels, byte[] colors, int width, int height, int bitsPerPixel, int bytesPerColorMapEntry, bool inverted) private void ReadRgbPalette<TPixel>(Buffer2D<TPixel> pixels, byte[] colors, int width, int height, int bitsPerPixel, int bytesPerColorMapEntry, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Pixels per byte (bits per pixel). // Pixels per byte (bits per pixel).
int ppb = 8 / bitsPerPixel; int ppb = 8 / bitsPerPixel;
@ -872,7 +872,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="greenMask">The bitmask for the green channel.</param> /// <param name="greenMask">The bitmask for the green channel.</param>
/// <param name="blueMask">The bitmask for the blue channel.</param> /// <param name="blueMask">The bitmask for the blue channel.</param>
private void ReadRgb16<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted, int redMask = DefaultRgb16RMask, int greenMask = DefaultRgb16GMask, int blueMask = DefaultRgb16BMask) private void ReadRgb16<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted, int redMask = DefaultRgb16RMask, int greenMask = DefaultRgb16GMask, int blueMask = DefaultRgb16BMask)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int padding = CalculatePadding(width, 2); int padding = CalculatePadding(width, 2);
int stride = (width * 2) + padding; int stride = (width * 2) + padding;
@ -939,7 +939,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="height">The height of the bitmap.</param> /// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted) private void ReadRgb24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int padding = CalculatePadding(width, 3); int padding = CalculatePadding(width, 3);
@ -968,7 +968,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="height">The height of the bitmap.</param> /// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb32Fast<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted) private void ReadRgb32Fast<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int padding = CalculatePadding(width, 4); int padding = CalculatePadding(width, 4);
@ -998,7 +998,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="height">The height of the bitmap.</param> /// <param name="height">The height of the bitmap.</param>
/// <param name="inverted">Whether the bitmap is inverted.</param> /// <param name="inverted">Whether the bitmap is inverted.</param>
private void ReadRgb32Slow<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted) private void ReadRgb32Slow<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int padding = CalculatePadding(width, 4); int padding = CalculatePadding(width, 4);
@ -1099,7 +1099,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="blueMask">The bitmask for the blue channel.</param> /// <param name="blueMask">The bitmask for the blue channel.</param>
/// <param name="alphaMask">The bitmask for the alpha channel.</param> /// <param name="alphaMask">The bitmask for the alpha channel.</param>
private void ReadRgb32BitFields<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted, int redMask, int greenMask, int blueMask, int alphaMask) private void ReadRgb32BitFields<TPixel>(Buffer2D<TPixel> pixels, int width, int height, bool inverted, int redMask, int greenMask, int blueMask, int alphaMask)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel color = default; TPixel color = default;
int padding = CalculatePadding(width, 4); int padding = CalculatePadding(width, 4);

2
src/ImageSharp/Formats/Bmp/BmpEncoder.cs

@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <inheritdoc/> /// <inheritdoc/>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator()); var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator());
encoder.Encode(image, stream); encoder.Encode(image, stream);

16
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The <see cref="ImageFrame{TPixel}"/> containing pixel data. /// The <see cref="ImageFrame{TPixel}"/> containing pixel data.
/// </param> /// </param>
private void WriteImage<TPixel>(Stream stream, ImageFrame<TPixel> image) private void WriteImage<TPixel>(Stream stream, ImageFrame<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Buffer2D<TPixel> pixels = image.PixelBuffer; Buffer2D<TPixel> pixels = image.PixelBuffer;
switch (this.bitsPerPixel) switch (this.bitsPerPixel)
@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write32Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write32Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4))
{ {
@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write24Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write24Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3))
{ {
@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write16Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write16Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2))
{ {
@ -309,7 +309,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param> /// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
private void Write8Bit<TPixel>(Stream stream, ImageFrame<TPixel> image) private void Write8Bit<TPixel>(Stream stream, ImageFrame<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
bool isL8 = typeof(TPixel) == typeof(L8); bool isL8 = typeof(TPixel) == typeof(L8);
using (IMemoryOwner<byte> colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean)) using (IMemoryOwner<byte> colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean))
@ -334,7 +334,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param> /// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
/// <param name="colorPalette">A byte span of size 1024 for the color palette.</param> /// <param name="colorPalette">A byte span of size 1024 for the color palette.</param>
private void Write8BitColor<TPixel>(Stream stream, ImageFrame<TPixel> image, Span<byte> colorPalette) private void Write8BitColor<TPixel>(Stream stream, ImageFrame<TPixel> image, Span<byte> colorPalette)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using IFrameQuantizer<TPixel> quantizer = this.quantizer.CreateFrameQuantizer<TPixel>(this.configuration); using IFrameQuantizer<TPixel> quantizer = this.quantizer.CreateFrameQuantizer<TPixel>(this.configuration);
using QuantizedFrame<TPixel> quantized = quantizer.QuantizeFrame(image, image.Bounds()); using QuantizedFrame<TPixel> quantized = quantizer.QuantizeFrame(image, image.Bounds());
@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param> /// <param name="image"> The <see cref="ImageFrame{TPixel}"/> containing pixel data.</param>
/// <param name="colorPalette">A byte span of size 1024 for the color palette.</param> /// <param name="colorPalette">A byte span of size 1024 for the color palette.</param>
private void Write8BitGray<TPixel>(Stream stream, ImageFrame<TPixel> image, Span<byte> colorPalette) private void Write8BitGray<TPixel>(Stream stream, ImageFrame<TPixel> image, Span<byte> colorPalette)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Create a color palette with 256 different gray values. // Create a color palette with 256 different gray values.
for (int i = 0; i <= 255; i++) for (int i = 0; i <= 255; i++)

2
src/ImageSharp/Formats/Gif/GifDecoder.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var decoder = new GifDecoderCore(configuration, this); var decoder = new GifDecoderCore(configuration, this);

8
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="stream">The stream containing image data. </param> /// <param name="stream">The stream containing image data. </param>
/// <returns>The decoded image</returns> /// <returns>The decoded image</returns>
public Image<TPixel> Decode<TPixel>(Stream stream) public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Image<TPixel> image = null; Image<TPixel> image = null;
ImageFrame<TPixel> previousFrame = null; ImageFrame<TPixel> previousFrame = null;
@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="image">The image to decode the information to.</param> /// <param name="image">The image to decode the information to.</param>
/// <param name="previousFrame">The previous frame.</param> /// <param name="previousFrame">The previous frame.</param>
private void ReadFrame<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPixel> previousFrame) private void ReadFrame<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPixel> previousFrame)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.ReadImageDescriptor(); this.ReadImageDescriptor();
@ -405,7 +405,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="colorTable">The color table containing the available colors.</param> /// <param name="colorTable">The color table containing the available colors.</param>
/// <param name="descriptor">The <see cref="GifImageDescriptor"/></param> /// <param name="descriptor">The <see cref="GifImageDescriptor"/></param>
private void ReadFrameColors<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPixel> previousFrame, Span<byte> indices, ReadOnlySpan<Rgb24> colorTable, in GifImageDescriptor descriptor) private void ReadFrameColors<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPixel> previousFrame, Span<byte> indices, ReadOnlySpan<Rgb24> colorTable, in GifImageDescriptor descriptor)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref byte indicesRef = ref MemoryMarshal.GetReference(indices); ref byte indicesRef = ref MemoryMarshal.GetReference(indices);
int imageWidth = this.logicalScreenDescriptor.Width; int imageWidth = this.logicalScreenDescriptor.Width;
@ -535,7 +535,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="frame">The frame.</param> /// <param name="frame">The frame.</param>
private void RestoreToBackground<TPixel>(ImageFrame<TPixel> frame) private void RestoreToBackground<TPixel>(ImageFrame<TPixel> frame)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (this.restoreArea is null) if (this.restoreArea is null)
{ {

2
src/ImageSharp/Formats/Gif/GifEncoder.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <inheritdoc/> /// <inheritdoc/>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new GifEncoderCore(image.GetConfiguration(), this); var encoder = new GifEncoderCore(image.GetConfiguration(), this);
encoder.Encode(image, stream); encoder.Encode(image, stream);

14
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
} }
private void EncodeGlobal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> quantized, int transparencyIndex, Stream stream) private void EncodeGlobal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> quantized, int transparencyIndex, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
for (int i = 0; i < image.Frames.Count; i++) for (int i = 0; i < image.Frames.Count; i++)
{ {
@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
} }
private void EncodeLocal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> quantized, Stream stream) private void EncodeLocal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> quantized, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ImageFrame<TPixel> previousFrame = null; ImageFrame<TPixel> previousFrame = null;
GifFrameMetadata previousMeta = null; GifFrameMetadata previousMeta = null;
@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The <see cref="int"/>. /// The <see cref="int"/>.
/// </returns> /// </returns>
private int GetTransparentIndex<TPixel>(QuantizedFrame<TPixel> quantized) private int GetTransparentIndex<TPixel>(QuantizedFrame<TPixel> quantized)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Transparent pixels are much more likely to be found at the end of a palette // Transparent pixels are much more likely to be found at the end of a palette
int index = -1; int index = -1;
@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="hasColorTable">Whether to use the global color table.</param> /// <param name="hasColorTable">Whether to use the global color table.</param>
/// <param name="stream">The stream to write to.</param> /// <param name="stream">The stream to write to.</param>
private void WriteImageDescriptor<TPixel>(ImageFrame<TPixel> image, bool hasColorTable, Stream stream) private void WriteImageDescriptor<TPixel>(ImageFrame<TPixel> image, bool hasColorTable, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
byte packedValue = GifImageDescriptor.GetPackedValue( byte packedValue = GifImageDescriptor.GetPackedValue(
localColorTableFlag: hasColorTable, localColorTableFlag: hasColorTable,
@ -438,7 +438,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode.</param> /// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode.</param>
/// <param name="stream">The stream to write to.</param> /// <param name="stream">The stream to write to.</param>
private void WriteColorTable<TPixel>(QuantizedFrame<TPixel> image, Stream stream) private void WriteColorTable<TPixel>(QuantizedFrame<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// The maximum number of colors for the bit depth // The maximum number of colors for the bit depth
int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * 3; int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * 3;
@ -462,7 +462,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="image">The <see cref="QuantizedFrame{TPixel}"/> containing indexed pixels.</param> /// <param name="image">The <see cref="QuantizedFrame{TPixel}"/> containing indexed pixels.</param>
/// <param name="stream">The stream to write to.</param> /// <param name="stream">The stream to write to.</param>
private void WriteImageData<TPixel>(QuantizedFrame<TPixel> image, Stream stream) private void WriteImageData<TPixel>(QuantizedFrame<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var encoder = new LzwEncoder(this.memoryAllocator, (byte)this.bitDepth)) using (var encoder = new LzwEncoder(this.memoryAllocator, (byte)this.bitDepth))
{ {

2
src/ImageSharp/Formats/IImageDecoder.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110) // TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
/// <summary> /// <summary>
/// Decodes the image from the specified stream to an <see cref="Image"/>. /// Decodes the image from the specified stream to an <see cref="Image"/>.

2
src/ImageSharp/Formats/IImageEncoder.cs

@ -18,6 +18,6 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
void Encode<TPixel>(Image<TPixel> image, Stream stream) void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
} }
} }

6
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs

@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// <typeparam name="TPixel">The pixel type</typeparam> /// <typeparam name="TPixel">The pixel type</typeparam>
/// <param name="destination">The destination image</param> /// <param name="destination">The destination image</param>
public void PostProcess<TPixel>(ImageFrame<TPixel> destination) public void PostProcess<TPixel>(ImageFrame<TPixel> destination)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.PixelRowCounter = 0; this.PixelRowCounter = 0;
@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// <typeparam name="TPixel">The pixel type</typeparam> /// <typeparam name="TPixel">The pixel type</typeparam>
/// <param name="destination">The destination image.</param> /// <param name="destination">The destination image.</param>
public void DoPostProcessorStep<TPixel>(ImageFrame<TPixel> destination) public void DoPostProcessorStep<TPixel>(ImageFrame<TPixel> destination)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
foreach (JpegComponentPostProcessor cpp in this.ComponentProcessors) foreach (JpegComponentPostProcessor cpp in this.ComponentProcessors)
{ {
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// <typeparam name="TPixel">The pixel type</typeparam> /// <typeparam name="TPixel">The pixel type</typeparam>
/// <param name="destination">The destination image</param> /// <param name="destination">The destination image</param>
private void ConvertColorsInto<TPixel>(ImageFrame<TPixel> destination) private void ConvertColorsInto<TPixel>(ImageFrame<TPixel> destination)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep); int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep);

2
src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel type to work on</typeparam> /// <typeparam name="TPixel">The pixel type to work on</typeparam>
internal ref struct YCbCrForwardConverter<TPixel> internal ref struct YCbCrForwardConverter<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// The Y component /// The Y component

2
src/ImageSharp/Formats/Jpeg/JpegDecoder.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));

4
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <param name="stream">The stream, where the image should be.</param> /// <param name="stream">The stream, where the image should be.</param>
/// <returns>The decoded image.</returns> /// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Stream stream) public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.ParseStream(stream); this.ParseStream(stream);
this.InitExifProfile(); this.InitExifProfile();
@ -958,7 +958,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
private Image<TPixel> PostProcessIntoImage<TPixel>() private Image<TPixel> PostProcessIntoImage<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (this.ImageWidth == 0 || this.ImageHeight == 0) if (this.ImageWidth == 0 || this.ImageHeight == 0)
{ {

2
src/ImageSharp/Formats/Jpeg/JpegEncoder.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new JpegEncoderCore(this); var encoder = new JpegEncoderCore(this);
encoder.Encode(image, stream); encoder.Encode(image, stream);

8
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <param name="image">The image to write from.</param> /// <param name="image">The image to write from.</param>
/// <param name="stream">The stream to write to.</param> /// <param name="stream">The stream to write to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
@ -394,7 +394,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="pixels">The pixel accessor providing access to the image pixels.</param> /// <param name="pixels">The pixel accessor providing access to the image pixels.</param>
private void Encode444<TPixel>(Image<TPixel> pixels) private void Encode444<TPixel>(Image<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.)
// (Partially done with YCbCrForwardConverter<TPixel>) // (Partially done with YCbCrForwardConverter<TPixel>)
@ -891,7 +891,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="image">The pixel accessor providing access to the image pixels.</param> /// <param name="image">The pixel accessor providing access to the image pixels.</param>
private void WriteStartOfScan<TPixel>(Image<TPixel> image) private void WriteStartOfScan<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.)
// TODO: We should allow grayscale writing. // TODO: We should allow grayscale writing.
@ -918,7 +918,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="pixels">The pixel accessor providing access to the image pixels.</param> /// <param name="pixels">The pixel accessor providing access to the image pixels.</param>
private void Encode420<TPixel>(Image<TPixel> pixels) private void Encode420<TPixel>(Image<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.)
Block8x8F b = default; Block8x8F b = default;

2
src/ImageSharp/Formats/PixelTypeInfo.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats
public int BitsPerPixel { get; } public int BitsPerPixel { get; }
internal static PixelTypeInfo Create<TPixel>() internal static PixelTypeInfo Create<TPixel>()
where TPixel : struct, IPixel<TPixel> => where TPixel : unmanaged, IPixel<TPixel> =>
new PixelTypeInfo(Unsafe.SizeOf<TPixel>() * 8); new PixelTypeInfo(Unsafe.SizeOf<TPixel>() * 8);
} }
} }

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

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> /// <param name="stream">The <see cref="Stream"/> containing image data.</param>
/// <returns>The decoded image.</returns> /// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var decoder = new PngDecoderCore(configuration, this); var decoder = new PngDecoderCore(configuration, this);

14
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// </exception> /// </exception>
/// <returns>The decoded image.</returns> /// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Stream stream) public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var metadata = new ImageMetadata(); var metadata = new ImageMetadata();
PngMetadata pngMetadata = metadata.GetPngMetadata(); PngMetadata pngMetadata = metadata.GetPngMetadata();
@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="metadata">The metadata information for the image</param> /// <param name="metadata">The metadata information for the image</param>
/// <param name="image">The image that we will populate</param> /// <param name="image">The image that we will populate</param>
private void InitializeImage<TPixel>(ImageMetadata metadata, out Image<TPixel> image) private void InitializeImage<TPixel>(ImageMetadata metadata, out Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
image = new Image<TPixel>(this.configuration, this.header.Width, this.header.Height, metadata); image = new Image<TPixel>(this.configuration, this.header.Width, this.header.Height, metadata);
this.bytesPerPixel = this.CalculateBytesPerPixel(); this.bytesPerPixel = this.CalculateBytesPerPixel();
@ -471,7 +471,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="image"> The pixel data.</param> /// <param name="image"> The pixel data.</param>
/// <param name="pngMetadata">The png metadata</param> /// <param name="pngMetadata">The png metadata</param>
private void ReadScanlines<TPixel>(PngChunk chunk, ImageFrame<TPixel> image, PngMetadata pngMetadata) private void ReadScanlines<TPixel>(PngChunk chunk, ImageFrame<TPixel> image, PngMetadata pngMetadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var deframeStream = new ZlibInflateStream(this.currentStream, this.ReadNextDataChunk)) using (var deframeStream = new ZlibInflateStream(this.currentStream, this.ReadNextDataChunk))
{ {
@ -497,7 +497,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="image">The image to decode to.</param> /// <param name="image">The image to decode to.</param>
/// <param name="pngMetadata">The png metadata</param> /// <param name="pngMetadata">The png metadata</param>
private void DecodePixelData<TPixel>(Stream compressedStream, ImageFrame<TPixel> image, PngMetadata pngMetadata) private void DecodePixelData<TPixel>(Stream compressedStream, ImageFrame<TPixel> image, PngMetadata pngMetadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
while (this.currentRow < this.header.Height) while (this.currentRow < this.header.Height)
{ {
@ -553,7 +553,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="image">The current image.</param> /// <param name="image">The current image.</param>
/// <param name="pngMetadata">The png metadata.</param> /// <param name="pngMetadata">The png metadata.</param>
private void DecodeInterlacedPixelData<TPixel>(Stream compressedStream, ImageFrame<TPixel> image, PngMetadata pngMetadata) private void DecodeInterlacedPixelData<TPixel>(Stream compressedStream, ImageFrame<TPixel> image, PngMetadata pngMetadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int pass = 0; int pass = 0;
int width = this.header.Width; int width = this.header.Width;
@ -642,7 +642,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="pixels">The image</param> /// <param name="pixels">The image</param>
/// <param name="pngMetadata">The png metadata.</param> /// <param name="pngMetadata">The png metadata.</param>
private void ProcessDefilteredScanline<TPixel>(ReadOnlySpan<byte> defilteredScanline, ImageFrame<TPixel> pixels, PngMetadata pngMetadata) private void ProcessDefilteredScanline<TPixel>(ReadOnlySpan<byte> defilteredScanline, ImageFrame<TPixel> pixels, PngMetadata pngMetadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Span<TPixel> rowSpan = pixels.GetPixelRowSpan(this.currentRow); Span<TPixel> rowSpan = pixels.GetPixelRowSpan(this.currentRow);
@ -726,7 +726,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="pixelOffset">The column start index. Always 0 for none interlaced images.</param> /// <param name="pixelOffset">The column start index. Always 0 for none interlaced images.</param>
/// <param name="increment">The column increment. Always 1 for none interlaced images.</param> /// <param name="increment">The column increment. Always 1 for none interlaced images.</param>
private void ProcessInterlacedDefilteredScanline<TPixel>(ReadOnlySpan<byte> defilteredScanline, Span<TPixel> rowSpan, PngMetadata pngMetadata, int pixelOffset = 0, int increment = 1) private void ProcessInterlacedDefilteredScanline<TPixel>(ReadOnlySpan<byte> defilteredScanline, Span<TPixel> rowSpan, PngMetadata pngMetadata, int pixelOffset = 0, int increment = 1)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Trim the first marker byte from the buffer // Trim the first marker byte from the buffer
ReadOnlySpan<byte> trimmed = defilteredScanline.Slice(1, defilteredScanline.Length - 1); ReadOnlySpan<byte> trimmed = defilteredScanline.Slice(1, defilteredScanline.Length - 1);

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

@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this))) using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this)))
{ {

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

@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="rowSpan">The image row span.</param> /// <param name="rowSpan">The image row span.</param>
private void CollectGrayscaleBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan) private void CollectGrayscaleBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan);
Span<byte> rawScanlineSpan = this.currentScanline.GetSpan(); Span<byte> rawScanlineSpan = this.currentScanline.GetSpan();
@ -288,7 +288,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="rowSpan">The row span.</param> /// <param name="rowSpan">The row span.</param>
private void CollectTPixelBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan) private void CollectTPixelBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Span<byte> rawScanlineSpan = this.currentScanline.GetSpan(); Span<byte> rawScanlineSpan = this.currentScanline.GetSpan();
@ -372,7 +372,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="quantized">The quantized pixels. Can be null.</param> /// <param name="quantized">The quantized pixels. Can be null.</param>
/// <param name="row">The row.</param> /// <param name="row">The row.</param>
private void CollectPixelBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan, QuantizedFrame<TPixel> quantized, int row) private void CollectPixelBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan, QuantizedFrame<TPixel> quantized, int row)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
switch (this.options.ColorType) switch (this.options.ColorType)
{ {
@ -441,7 +441,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="row">The row.</param> /// <param name="row">The row.</param>
/// <returns>The <see cref="IManagedByteBuffer"/></returns> /// <returns>The <see cref="IManagedByteBuffer"/></returns>
private IManagedByteBuffer EncodePixelRow<TPixel>(ReadOnlySpan<TPixel> rowSpan, QuantizedFrame<TPixel> quantized, int row) private IManagedByteBuffer EncodePixelRow<TPixel>(ReadOnlySpan<TPixel> rowSpan, QuantizedFrame<TPixel> quantized, int row)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.CollectPixelBytes(rowSpan, quantized, row); this.CollectPixelBytes(rowSpan, quantized, row);
return this.FilterPixelBytes(); return this.FilterPixelBytes();
@ -547,7 +547,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> /// <param name="stream">The <see cref="Stream"/> containing image data.</param>
/// <param name="quantized">The quantized frame.</param> /// <param name="quantized">The quantized frame.</param>
private void WritePaletteChunk<TPixel>(Stream stream, QuantizedFrame<TPixel> quantized) private void WritePaletteChunk<TPixel>(Stream stream, QuantizedFrame<TPixel> quantized)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (quantized == null) if (quantized == null)
{ {
@ -784,7 +784,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="quantized">The quantized pixel data. Can be null.</param> /// <param name="quantized">The quantized pixel data. Can be null.</param>
/// <param name="stream">The stream.</param> /// <param name="stream">The stream.</param>
private void WriteDataChunks<TPixel>(ImageFrame<TPixel> pixels, QuantizedFrame<TPixel> quantized, Stream stream) private void WriteDataChunks<TPixel>(ImageFrame<TPixel> pixels, QuantizedFrame<TPixel> quantized, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
byte[] buffer; byte[] buffer;
int bufferLength; int bufferLength;
@ -882,7 +882,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="quantized">The quantized pixels span.</param> /// <param name="quantized">The quantized pixels span.</param>
/// <param name="deflateStream">The deflate stream.</param> /// <param name="deflateStream">The deflate stream.</param>
private void EncodePixels<TPixel>(ImageFrame<TPixel> pixels, QuantizedFrame<TPixel> quantized, ZlibDeflateStream deflateStream) private void EncodePixels<TPixel>(ImageFrame<TPixel> pixels, QuantizedFrame<TPixel> quantized, ZlibDeflateStream deflateStream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int bytesPerScanline = this.CalculateScanlineLength(this.width); int bytesPerScanline = this.CalculateScanlineLength(this.width);
int resultLength = bytesPerScanline + 1; int resultLength = bytesPerScanline + 1;
@ -906,7 +906,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="pixels">The pixels.</param> /// <param name="pixels">The pixels.</param>
/// <param name="deflateStream">The deflate stream.</param> /// <param name="deflateStream">The deflate stream.</param>
private void EncodeAdam7Pixels<TPixel>(ImageFrame<TPixel> pixels, ZlibDeflateStream deflateStream) private void EncodeAdam7Pixels<TPixel>(ImageFrame<TPixel> pixels, ZlibDeflateStream deflateStream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int width = pixels.Width; int width = pixels.Width;
int height = pixels.Height; int height = pixels.Height;
@ -961,7 +961,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <param name="quantized">The quantized.</param> /// <param name="quantized">The quantized.</param>
/// <param name="deflateStream">The deflate stream.</param> /// <param name="deflateStream">The deflate stream.</param>
private void EncodeAdam7IndexedPixels<TPixel>(QuantizedFrame<TPixel> quantized, ZlibDeflateStream deflateStream) private void EncodeAdam7IndexedPixels<TPixel>(QuantizedFrame<TPixel> quantized, ZlibDeflateStream deflateStream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int width = quantized.Width; int width = quantized.Width;
int height = quantized.Height; int height = quantized.Height;

10
src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Png
PngMetadata pngMetadata, PngMetadata pngMetadata,
out bool use16Bit, out bool use16Bit,
out int bytesPerPixel) out int bytesPerPixel)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Always take the encoder options over the metadata values. // Always take the encoder options over the metadata values.
options.Gamma ??= pngMetadata.Gamma; options.Gamma ??= pngMetadata.Gamma;
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Png
public static QuantizedFrame<TPixel> CreateQuantizedFrame<TPixel>( public static QuantizedFrame<TPixel> CreateQuantizedFrame<TPixel>(
PngEncoderOptions options, PngEncoderOptions options,
Image<TPixel> image) Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (options.ColorType != PngColorType.Palette) if (options.ColorType != PngColorType.Palette)
{ {
@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Formats.Png
PngEncoderOptions options, PngEncoderOptions options,
Image<TPixel> image, Image<TPixel> image,
QuantizedFrame<TPixel> quantizedFrame) QuantizedFrame<TPixel> quantizedFrame)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
byte bitDepth; byte bitDepth;
if (options.ColorType == PngColorType.Palette) if (options.ColorType == PngColorType.Palette)
@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// This is not exhaustive but covers many common pixel formats. /// This is not exhaustive but covers many common pixel formats.
/// </summary> /// </summary>
private static PngColorType SuggestColorType<TPixel>() private static PngColorType SuggestColorType<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return typeof(TPixel) switch return typeof(TPixel) switch
{ {
@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// This is not exhaustive but covers many common pixel formats. /// This is not exhaustive but covers many common pixel formats.
/// </summary> /// </summary>
private static PngBitDepth SuggestBitDepth<TPixel>() private static PngBitDepth SuggestBitDepth<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return typeof(TPixel) switch return typeof(TPixel) switch
{ {

20
src/ImageSharp/Formats/Png/PngScanlineProcessor.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Png
bool hasTrans, bool hasTrans,
L16 luminance16Trans, L16 luminance16Trans,
L8 luminanceTrans) L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Formats.Png
bool hasTrans, bool hasTrans,
L16 luminance16Trans, L16 luminance16Trans,
L8 luminanceTrans) L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample) int bytesPerSample)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Formats.Png
int increment, int increment,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample) int bytesPerSample)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
ReadOnlySpan<byte> palette, ReadOnlySpan<byte> palette,
byte[] paletteAlpha) byte[] paletteAlpha)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -284,7 +284,7 @@ namespace SixLabors.ImageSharp.Formats.Png
int increment, int increment,
ReadOnlySpan<byte> palette, ReadOnlySpan<byte> palette,
byte[] paletteAlpha) byte[] paletteAlpha)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -331,7 +331,7 @@ namespace SixLabors.ImageSharp.Formats.Png
bool hasTrans, bool hasTrans,
Rgb48 rgb48Trans, Rgb48 rgb48Trans,
Rgb24 rgb24Trans) Rgb24 rgb24Trans)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan);
@ -404,7 +404,7 @@ namespace SixLabors.ImageSharp.Formats.Png
bool hasTrans, bool hasTrans,
Rgb48 rgb48Trans, Rgb48 rgb48Trans,
Rgb24 rgb24Trans) Rgb24 rgb24Trans)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);
@ -482,7 +482,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Span<TPixel> rowSpan, Span<TPixel> rowSpan,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample) int bytesPerSample)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan);
@ -515,7 +515,7 @@ namespace SixLabors.ImageSharp.Formats.Png
int increment, int increment,
int bytesPerPixel, int bytesPerPixel,
int bytesPerSample) int bytesPerSample)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel pixel = default; TPixel pixel = default;
ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan);

2
src/ImageSharp/Formats/Tga/TgaDecoder.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
{ {
/// <inheritdoc/> /// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream) public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));

16
src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// </exception> /// </exception>
/// <returns>The decoded image.</returns> /// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Stream stream) public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
try try
{ {
@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="colorMapPixelSizeInBytes">Color map size of one entry in bytes.</param> /// <param name="colorMapPixelSizeInBytes">Color map size of one entry in bytes.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadPaletted<TPixel>(int width, int height, Buffer2D<TPixel> pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted) private void ReadPaletted<TPixel>(int width, int height, Buffer2D<TPixel> pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.memoryAllocator.AllocateManagedByteBuffer(width, AllocationOptions.Clean)) using (IManagedByteBuffer row = this.memoryAllocator.AllocateManagedByteBuffer(width, AllocationOptions.Clean))
{ {
@ -285,7 +285,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="colorMapPixelSizeInBytes">Color map size of one entry in bytes.</param> /// <param name="colorMapPixelSizeInBytes">Color map size of one entry in bytes.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadPalettedRle<TPixel>(int width, int height, Buffer2D<TPixel> pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted) private void ReadPalettedRle<TPixel>(int width, int height, Buffer2D<TPixel> pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int bytesPerPixel = 1; int bytesPerPixel = 1;
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean)) using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean))
@ -336,7 +336,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadMonoChrome<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted) private void ReadMonoChrome<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 1, 0)) using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 1, 0))
{ {
@ -363,7 +363,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadBgra16<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted) private void ReadBgra16<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 2, 0)) using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 2, 0))
{ {
@ -398,7 +398,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadBgr24<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted) private void ReadBgr24<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 3, 0)) using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 3, 0))
{ {
@ -425,7 +425,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> to assign the palette to.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadBgra32<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted) private void ReadBgra32<TPixel>(int width, int height, Buffer2D<TPixel> pixels, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 4, 0)) using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 4, 0))
{ {
@ -453,7 +453,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="bytesPerPixel">The bytes per pixel.</param> /// <param name="bytesPerPixel">The bytes per pixel.</param>
/// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param> /// <param name="inverted">Indicates, if the origin of the image is top left rather the bottom left (the default).</param>
private void ReadRle<TPixel>(int width, int height, Buffer2D<TPixel> pixels, int bytesPerPixel, bool inverted) private void ReadRle<TPixel>(int width, int height, Buffer2D<TPixel> pixels, int bytesPerPixel, bool inverted)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
TPixel color = default; TPixel color = default;
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean)) using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean))

2
src/ImageSharp/Formats/Tga/TgaEncoder.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <inheritdoc/> /// <inheritdoc/>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator()); var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator());
encoder.Encode(image, stream); encoder.Encode(image, stream);

18
src/ImageSharp/Formats/Tga/TgaEncoderCore.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param> /// <param name="image">The <see cref="ImageFrame{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream) public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// The <see cref="ImageFrame{TPixel}"/> containing pixel data. /// The <see cref="ImageFrame{TPixel}"/> containing pixel data.
/// </param> /// </param>
private void WriteImage<TPixel>(Stream stream, ImageFrame<TPixel> image) private void WriteImage<TPixel>(Stream stream, ImageFrame<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Buffer2D<TPixel> pixels = image.PixelBuffer; Buffer2D<TPixel> pixels = image.PixelBuffer;
switch (this.bitsPerPixel) switch (this.bitsPerPixel)
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="stream">The stream to write the image to.</param> /// <param name="stream">The stream to write the image to.</param>
/// <param name="image">The image to encode.</param> /// <param name="image">The image to encode.</param>
private void WriteRunLengthEncodedImage<TPixel>(Stream stream, ImageFrame<TPixel> image) private void WriteRunLengthEncodedImage<TPixel>(Stream stream, ImageFrame<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Rgba32 color = default; Rgba32 color = default;
Buffer2D<TPixel> pixels = image.PixelBuffer; Buffer2D<TPixel> pixels = image.PixelBuffer;
@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="yStart">Y coordinate to start searching for the same pixels.</param> /// <param name="yStart">Y coordinate to start searching for the same pixels.</param>
/// <returns>The number of equal pixels.</returns> /// <returns>The number of equal pixels.</returns>
private byte FindEqualPixels<TPixel>(Buffer2D<TPixel> pixels, int xStart, int yStart) private byte FindEqualPixels<TPixel>(Buffer2D<TPixel> pixels, int xStart, int yStart)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
byte equalPixelCount = 0; byte equalPixelCount = 0;
bool firstRow = true; bool firstRow = true;
@ -249,7 +249,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write8Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write8Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 1)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 1))
{ {
@ -273,7 +273,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write16Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write16Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2))
{ {
@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write24Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write24Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3))
{ {
@ -321,7 +321,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="stream">The <see cref="Stream"/> to write to.</param> /// <param name="stream">The <see cref="Stream"/> to write to.</param>
/// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param> /// <param name="pixels">The <see cref="Buffer2D{TPixel}"/> containing pixel data.</param>
private void Write32Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels) private void Write32Bit<TPixel>(Stream stream, Buffer2D<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4)) using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4))
{ {
@ -344,7 +344,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
/// <param name="sourcePixel">The pixel to get the luminance from.</param> /// <param name="sourcePixel">The pixel to get the luminance from.</param>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public static int GetLuminance<TPixel>(TPixel sourcePixel) public static int GetLuminance<TPixel>(TPixel sourcePixel)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var vector = sourcePixel.ToVector4(); var vector = sourcePixel.ToVector4();
return ImageMaths.GetBT709Luminance(ref vector, 256); return ImageMaths.GetBT709Luminance(ref vector, 256);

4
src/ImageSharp/Image.Decode.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp
int width, int width,
int height, int height,
ImageMetadata metadata) ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Buffer2D<TPixel> uninitializedMemoryBuffer = Buffer2D<TPixel> uninitializedMemoryBuffer =
configuration.MemoryAllocator.Allocate2D<TPixel>(width, height); configuration.MemoryAllocator.Allocate2D<TPixel>(width, height);
@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp
/// </returns> /// </returns>
private static (Image<TPixel> img, IImageFormat format) Decode<TPixel>(Stream stream, Configuration config) private static (Image<TPixel> img, IImageFormat format) Decode<TPixel>(Stream stream, Configuration config)
#pragma warning restore SA1008 // Opening parenthesis must be spaced correctly #pragma warning restore SA1008 // Opening parenthesis must be spaced correctly
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format); IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format);
if (decoder is null) if (decoder is null)

24
src/ImageSharp/Image.FromBytes.cs

@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(byte[] data) public static Image<TPixel> Load<TPixel>(byte[] data)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data); => Load<TPixel>(Configuration.Default, data);
/// <summary> /// <summary>
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(byte[] data, out IImageFormat format) public static Image<TPixel> Load<TPixel>(byte[] data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data, out format); => Load<TPixel>(Configuration.Default, data, out format);
/// <summary> /// <summary>
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data) public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var stream = new MemoryStream(data, 0, data.Length, false, true)) using (var stream = new MemoryStream(data, 0, data.Length, false, true))
{ {
@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, out IImageFormat format) public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var stream = new MemoryStream(data, 0, data.Length, false, true)) using (var stream = new MemoryStream(data, 0, data.Length, false, true))
{ {
@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var stream = new MemoryStream(data, 0, data.Length, false, true)) using (var stream = new MemoryStream(data, 0, data.Length, false, true))
{ {
@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var stream = new MemoryStream(data, 0, data.Length, false, true)) using (var stream = new MemoryStream(data, 0, data.Length, false, true))
{ {
@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data) public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data); => Load<TPixel>(Configuration.Default, data);
/// <summary> /// <summary>
@ -186,7 +186,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, out IImageFormat format) public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data, out format); => Load<TPixel>(Configuration.Default, data, out format);
/// <summary> /// <summary>
@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data, decoder); => Load<TPixel>(Configuration.Default, data, decoder);
/// <summary> /// <summary>
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static unsafe Image<TPixel> Load<TPixel>(Configuration config, ReadOnlySpan<byte> data) public static unsafe Image<TPixel> Load<TPixel>(Configuration config, ReadOnlySpan<byte> data)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
fixed (byte* ptr = &data.GetPinnableReference()) fixed (byte* ptr = &data.GetPinnableReference())
{ {
@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp
Configuration config, Configuration config,
ReadOnlySpan<byte> data, ReadOnlySpan<byte> data,
IImageDecoder decoder) IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
fixed (byte* ptr = &data.GetPinnableReference()) fixed (byte* ptr = &data.GetPinnableReference())
{ {
@ -254,7 +254,7 @@ namespace SixLabors.ImageSharp
Configuration config, Configuration config,
ReadOnlySpan<byte> data, ReadOnlySpan<byte> data,
out IImageFormat format) out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
fixed (byte* ptr = &data.GetPinnableReference()) fixed (byte* ptr = &data.GetPinnableReference())
{ {

12
src/ImageSharp/Image.FromFile.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(string path) public static Image<TPixel> Load<TPixel>(string path)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return Load<TPixel>(Configuration.Default, path); return Load<TPixel>(Configuration.Default, path);
} }
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(string path, out IImageFormat format) public static Image<TPixel> Load<TPixel>(string path, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return Load<TPixel>(Configuration.Default, path, out format); return Load<TPixel>(Configuration.Default, path, out format);
} }
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, string path) public static Image<TPixel> Load<TPixel>(Configuration config, string path)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (Stream stream = config.FileSystem.OpenRead(path)) using (Stream stream = config.FileSystem.OpenRead(path))
{ {
@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, string path, out IImageFormat format) public static Image<TPixel> Load<TPixel>(Configuration config, string path, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (Stream stream = config.FileSystem.OpenRead(path)) using (Stream stream = config.FileSystem.OpenRead(path))
{ {
@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return Load<TPixel>(Configuration.Default, path, decoder); return Load<TPixel>(Configuration.Default, path, decoder);
} }
@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, string path, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(Configuration config, string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (Stream stream = config.FileSystem.OpenRead(path)) using (Stream stream = config.FileSystem.OpenRead(path))
{ {

12
src/ImageSharp/Image.FromStream.cs

@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream) public static Image<TPixel> Load<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(null, stream); => Load<TPixel>(null, stream);
/// <summary> /// <summary>
@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream, out IImageFormat format) public static Image<TPixel> Load<TPixel>(Stream stream, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(null, stream, out format); => Load<TPixel>(null, stream, out format);
/// <summary> /// <summary>
@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> WithSeekableStream(Configuration.Default, stream, s => decoder.Decode<TPixel>(Configuration.Default, s)); => WithSeekableStream(Configuration.Default, stream, s => decoder.Decode<TPixel>(Configuration.Default, s));
/// <summary> /// <summary>
@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, IImageDecoder decoder) public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> WithSeekableStream(config, stream, s => decoder.Decode<TPixel>(config, s)); => WithSeekableStream(config, stream, s => decoder.Decode<TPixel>(config, s));
/// <summary> /// <summary>
@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream) public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Load<TPixel>(config, stream, out IImageFormat _); => Load<TPixel>(config, stream, out IImageFormat _);
/// <summary> /// <summary>
@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, out IImageFormat format) public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, out IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
config = config ?? Configuration.Default; config = config ?? Configuration.Default;
(Image<TPixel> img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode<TPixel>(s, config)); (Image<TPixel> img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode<TPixel>(s, config));

16
src/ImageSharp/Image.LoadPixelData.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(TPixel[] data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(TPixel[] data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData(Configuration.Default, data, width, height); => LoadPixelData(Configuration.Default, data, width, height);
/// <summary> /// <summary>
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<TPixel> data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData(Configuration.Default, data, width, height); => LoadPixelData(Configuration.Default, data, width, height);
/// <summary> /// <summary>
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(byte[] data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(byte[] data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData<TPixel>(Configuration.Default, data, width, height); => LoadPixelData<TPixel>(Configuration.Default, data, width, height);
/// <summary> /// <summary>
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<byte> data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData<TPixel>(Configuration.Default, data, width, height); => LoadPixelData<TPixel>(Configuration.Default, data, width, height);
/// <summary> /// <summary>
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, byte[] data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, byte[] data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData(config, MemoryMarshal.Cast<byte, TPixel>(new ReadOnlySpan<byte>(data)), width, height); => LoadPixelData(config, MemoryMarshal.Cast<byte, TPixel>(new ReadOnlySpan<byte>(data)), width, height);
/// <summary> /// <summary>
@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, ReadOnlySpan<byte> data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData(config, MemoryMarshal.Cast<byte, TPixel>(data), width, height); => LoadPixelData(config, MemoryMarshal.Cast<byte, TPixel>(data), width, height);
/// <summary> /// <summary>
@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, TPixel[] data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, TPixel[] data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return LoadPixelData(config, new ReadOnlySpan<TPixel>(data), width, height); return LoadPixelData(config, new ReadOnlySpan<TPixel>(data), width, height);
} }
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, ReadOnlySpan<TPixel> data, int width, int height) public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int count = width * height; int count = width * height;
Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));

12
src/ImageSharp/Image.WrapMemory.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp
int width, int width,
int height, int height,
ImageMetadata metadata) ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var memorySource = MemoryGroup<TPixel>.Wrap(pixelMemory); var memorySource = MemoryGroup<TPixel>.Wrap(pixelMemory);
return new Image<TPixel>(config, memorySource, width, height, metadata); return new Image<TPixel>(config, memorySource, width, height, metadata);
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp
Memory<TPixel> pixelMemory, Memory<TPixel> pixelMemory,
int width, int width,
int height) int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return WrapMemory(config, pixelMemory, width, height, new ImageMetadata()); return WrapMemory(config, pixelMemory, width, height, new ImageMetadata());
} }
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp
Memory<TPixel> pixelMemory, Memory<TPixel> pixelMemory,
int width, int width,
int height) int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return WrapMemory(Configuration.Default, pixelMemory, width, height); return WrapMemory(Configuration.Default, pixelMemory, width, height);
} }
@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp
int width, int width,
int height, int height,
ImageMetadata metadata) ImageMetadata metadata)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var memorySource = MemoryGroup<TPixel>.Wrap(pixelMemoryOwner); var memorySource = MemoryGroup<TPixel>.Wrap(pixelMemoryOwner);
return new Image<TPixel>(config, memorySource, width, height, metadata); return new Image<TPixel>(config, memorySource, width, height, metadata);
@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp
IMemoryOwner<TPixel> pixelMemoryOwner, IMemoryOwner<TPixel> pixelMemoryOwner,
int width, int width,
int height) int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return WrapMemory(config, pixelMemoryOwner, width, height, new ImageMetadata()); return WrapMemory(config, pixelMemoryOwner, width, height, new ImageMetadata());
} }
@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp
IMemoryOwner<TPixel> pixelMemoryOwner, IMemoryOwner<TPixel> pixelMemoryOwner,
int width, int width,
int height) int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return WrapMemory(Configuration.Default, pixelMemoryOwner, width, height); return WrapMemory(Configuration.Default, pixelMemoryOwner, width, height);
} }

6
src/ImageSharp/Image.cs

@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel2">The pixel format.</typeparam> /// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="Image{TPixel2}"/></returns> /// <returns>The <see cref="Image{TPixel2}"/></returns>
public Image<TPixel2> CloneAs<TPixel2>() public Image<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration()); where TPixel2 : unmanaged, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration());
/// <summary> /// <summary>
/// Returns a copy of the image in the given pixel format. /// Returns a copy of the image in the given pixel format.
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp
/// <param name="configuration">The configuration providing initialization code which allows extending the library.</param> /// <param name="configuration">The configuration providing initialization code which allows extending the library.</param>
/// <returns>The <see cref="Image{TPixel2}"/>.</returns> /// <returns>The <see cref="Image{TPixel2}"/>.</returns>
public abstract Image<TPixel2> CloneAs<TPixel2>(Configuration configuration) public abstract Image<TPixel2> CloneAs<TPixel2>(Configuration configuration)
where TPixel2 : struct, IPixel<TPixel2>; where TPixel2 : unmanaged, IPixel<TPixel2>;
/// <summary> /// <summary>
/// Update the size of the image after mutation. /// Update the size of the image after mutation.
@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp
} }
public void Visit<TPixel>(Image<TPixel> image) public void Visit<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.encoder.Encode(image, this.stream); this.encoder.Encode(image, this.stream);
} }

2
src/ImageSharp/ImageExtensions.Internal.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp
/// The <see cref="Buffer2D{TPixel}" /> /// The <see cref="Buffer2D{TPixel}" />
/// </returns> /// </returns>
internal static Buffer2D<TPixel> GetRootFramePixelBuffer<TPixel>(this Image<TPixel> image) internal static Buffer2D<TPixel> GetRootFramePixelBuffer<TPixel>(this Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return image.Frames.RootFrame.PixelBuffer; return image.Frames.RootFrame.PixelBuffer;
} }

2
src/ImageSharp/ImageExtensions.cs

@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp
/// <param name="format">The format.</param> /// <param name="format">The format.</param>
/// <returns>The <see cref="string"/></returns> /// <returns>The <see cref="string"/></returns>
public static string ToBase64String<TPixel>(this Image<TPixel> source, IImageFormat format) public static string ToBase64String<TPixel>(this Image<TPixel> source, IImageFormat format)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
using (var stream = new MemoryStream()) using (var stream = new MemoryStream())
{ {

4
src/ImageSharp/ImageFrame.LoadPixelData.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height) internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> LoadPixelData(configuration, MemoryMarshal.Cast<byte, TPixel>(data), width, height); => LoadPixelData(configuration, MemoryMarshal.Cast<byte, TPixel>(data), width, height);
/// <summary> /// <summary>
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height) internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
int count = width * height; int count = width * height;
Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data));

2
src/ImageSharp/ImageFrame.cs

@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp
protected abstract void Dispose(bool disposing); protected abstract void Dispose(bool disposing);
internal abstract void CopyPixelsTo<TDestinationPixel>(MemoryGroup<TDestinationPixel> destination) internal abstract void CopyPixelsTo<TDestinationPixel>(MemoryGroup<TDestinationPixel> destination)
where TDestinationPixel : struct, IPixel<TDestinationPixel>; where TDestinationPixel : unmanaged, IPixel<TDestinationPixel>;
/// <summary> /// <summary>
/// Updates the size of the image frame. /// Updates the size of the image frame.

2
src/ImageSharp/ImageFrameCollection{TPixel}.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam> /// <typeparam name="TPixel">The type of the pixel.</typeparam>
public sealed class ImageFrameCollection<TPixel> : ImageFrameCollection, IEnumerable<ImageFrame<TPixel>> public sealed class ImageFrameCollection<TPixel> : ImageFrameCollection, IEnumerable<ImageFrame<TPixel>>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly IList<ImageFrame<TPixel>> frames = new List<ImageFrame<TPixel>>(); private readonly IList<ImageFrame<TPixel>> frames = new List<ImageFrame<TPixel>>();
private readonly Image<TPixel> parent; private readonly Image<TPixel> parent;

8
src/ImageSharp/ImageFrame{TPixel}.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
public sealed class ImageFrame<TPixel> : ImageFrame, IPixelSource<TPixel> public sealed class ImageFrame<TPixel> : ImageFrame, IPixelSource<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private bool isDisposed; private bool isDisposed;
@ -258,7 +258,7 @@ namespace SixLabors.ImageSharp
/// <typeparam name="TPixel2">The pixel format.</typeparam> /// <typeparam name="TPixel2">The pixel format.</typeparam>
/// <returns>The <see cref="ImageFrame{TPixel2}"/></returns> /// <returns>The <see cref="ImageFrame{TPixel2}"/></returns>
internal ImageFrame<TPixel2> CloneAs<TPixel2>() internal ImageFrame<TPixel2> CloneAs<TPixel2>()
where TPixel2 : struct, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration()); where TPixel2 : unmanaged, IPixel<TPixel2> => this.CloneAs<TPixel2>(this.GetConfiguration());
/// <summary> /// <summary>
/// Returns a copy of the image frame in the given pixel format. /// Returns a copy of the image frame in the given pixel format.
@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp
/// <param name="configuration">The configuration providing initialization code which allows extending the library.</param> /// <param name="configuration">The configuration providing initialization code which allows extending the library.</param>
/// <returns>The <see cref="ImageFrame{TPixel2}"/></returns> /// <returns>The <see cref="ImageFrame{TPixel2}"/></returns>
internal ImageFrame<TPixel2> CloneAs<TPixel2>(Configuration configuration) internal ImageFrame<TPixel2> CloneAs<TPixel2>(Configuration configuration)
where TPixel2 : struct, IPixel<TPixel2> where TPixel2 : unmanaged, IPixel<TPixel2>
{ {
if (typeof(TPixel2) == typeof(TPixel)) if (typeof(TPixel2) == typeof(TPixel))
{ {
@ -327,7 +327,7 @@ namespace SixLabors.ImageSharp
/// A <see langword="struct"/> implementing the clone logic for <see cref="ImageFrame{TPixel}"/>. /// A <see langword="struct"/> implementing the clone logic for <see cref="ImageFrame{TPixel}"/>.
/// </summary> /// </summary>
private readonly struct RowIntervalOperation<TPixel2> : IRowIntervalOperation private readonly struct RowIntervalOperation<TPixel2> : IRowIntervalOperation
where TPixel2 : struct, IPixel<TPixel2> where TPixel2 : unmanaged, IPixel<TPixel2>
{ {
private readonly ImageFrame<TPixel> source; private readonly ImageFrame<TPixel> source;
private readonly ImageFrame<TPixel2> target; private readonly ImageFrame<TPixel2> target;

2
src/ImageSharp/Image{TPixel}.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
public sealed class Image<TPixel> : Image public sealed class Image<TPixel> : Image
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private bool isDisposed; private bool isDisposed;

2
src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs

@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
/// The <see cref="Image{TPixel}"/>. /// The <see cref="Image{TPixel}"/>.
/// </returns> /// </returns>
public Image<TPixel> CreateThumbnail<TPixel>() public Image<TPixel> CreateThumbnail<TPixel>()
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.InitializeValues(); this.InitializeValues();

2
src/ImageSharp/PixelFormats/IPixel.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <typeparam name="TSelf">The type implementing this interface</typeparam> /// <typeparam name="TSelf">The type implementing this interface</typeparam>
public interface IPixel<TSelf> : IPixel, IEquatable<TSelf> public interface IPixel<TSelf> : IPixel, IEquatable<TSelf>
where TSelf : struct, IPixel<TSelf> where TSelf : unmanaged, IPixel<TSelf>
{ {
/// <summary> /// <summary>
/// Creates a <see cref="PixelOperations{TPixel}"/> instance for this pixel type. /// Creates a <see cref="PixelOperations{TPixel}"/> instance for this pixel type.

2
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// to be opaque /// to be opaque
/// </remarks> /// </remarks>
internal static class DefaultPixelBlenders<TPixel> internal static class DefaultPixelBlenders<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt

@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// to be opaque /// to be opaque
/// </remarks> /// </remarks>
internal static class DefaultPixelBlenders<TPixel> internal static class DefaultPixelBlenders<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
<# <#

216
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs

@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -278,7 +278,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -316,7 +316,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -335,7 +335,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -354,7 +354,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -373,7 +373,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -392,7 +392,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -608,7 +608,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -646,7 +646,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -665,7 +665,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -684,7 +684,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -703,7 +703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -722,7 +722,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -741,7 +741,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -760,7 +760,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -779,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -798,7 +798,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -817,7 +817,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1014,7 +1014,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1033,7 +1033,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1052,7 +1052,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1071,7 +1071,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1090,7 +1090,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1109,7 +1109,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1128,7 +1128,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1147,7 +1147,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1166,7 +1166,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1185,7 +1185,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1204,7 +1204,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1223,7 +1223,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1420,7 +1420,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1439,7 +1439,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1458,7 +1458,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1477,7 +1477,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1496,7 +1496,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1515,7 +1515,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1534,7 +1534,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1553,7 +1553,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1572,7 +1572,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1591,7 +1591,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1610,7 +1610,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1629,7 +1629,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1826,7 +1826,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1845,7 +1845,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1864,7 +1864,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1883,7 +1883,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1902,7 +1902,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1921,7 +1921,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1940,7 +1940,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1959,7 +1959,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1978,7 +1978,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -1997,7 +1997,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2016,7 +2016,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2035,7 +2035,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2232,7 +2232,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2251,7 +2251,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2270,7 +2270,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2289,7 +2289,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2308,7 +2308,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2327,7 +2327,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2346,7 +2346,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2365,7 +2365,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2384,7 +2384,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2403,7 +2403,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2422,7 +2422,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2441,7 +2441,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2638,7 +2638,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2657,7 +2657,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2676,7 +2676,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2695,7 +2695,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2714,7 +2714,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2733,7 +2733,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2752,7 +2752,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2771,7 +2771,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2790,7 +2790,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2809,7 +2809,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2828,7 +2828,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -2847,7 +2847,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3044,7 +3044,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3063,7 +3063,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3082,7 +3082,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3101,7 +3101,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3120,7 +3120,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3139,7 +3139,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3158,7 +3158,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3177,7 +3177,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3196,7 +3196,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3215,7 +3215,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3234,7 +3234,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3253,7 +3253,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3450,7 +3450,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3469,7 +3469,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3488,7 +3488,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3507,7 +3507,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3526,7 +3526,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3545,7 +3545,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3564,7 +3564,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3583,7 +3583,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3602,7 +3602,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3621,7 +3621,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3640,7 +3640,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;
@ -3659,7 +3659,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;

2
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt

@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <returns>The <typeparamref name="TPixel"/>.</returns> /// <returns>The <typeparamref name="TPixel"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel <#=blender#><#=composer#><TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel <#=blender#><#=composer#><TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
opacity = opacity.Clamp(0, 1); opacity = opacity.Clamp(0, 1);
TPixel dest = default; TPixel dest = default;

6
src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <typeparam name="TPixel">The type of the pixel</typeparam> /// <typeparam name="TPixel">The type of the pixel</typeparam>
public abstract class PixelBlender<TPixel> public abstract class PixelBlender<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Blend 2 pixels together. /// Blend 2 pixels together.
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ReadOnlySpan<TPixel> background, ReadOnlySpan<TPixel> background,
ReadOnlySpan<TPixelSrc> source, ReadOnlySpan<TPixelSrc> source,
float amount) float amount)
where TPixelSrc : struct, IPixel<TPixelSrc> where TPixelSrc : unmanaged, IPixel<TPixelSrc>
{ {
Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length));
Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length));
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ReadOnlySpan<TPixel> background, ReadOnlySpan<TPixel> background,
ReadOnlySpan<TPixelSrc> source, ReadOnlySpan<TPixelSrc> source,
ReadOnlySpan<float> amount) ReadOnlySpan<float> amount)
where TPixelSrc : struct, IPixel<TPixelSrc> where TPixelSrc : unmanaged, IPixel<TPixelSrc>
{ {
Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length));
Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length));

2
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Provides access to pixel blenders /// Provides access to pixel blenders
/// </content> /// </content>
public partial class PixelOperations<TPixel> public partial class PixelOperations<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Find an instance of the pixel blender. /// Find an instance of the pixel blender.

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

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
public partial class PixelOperations<TPixel> public partial class PixelOperations<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Gets the global <see cref="PixelOperations{TPixel}"/> instance for the pixel type <typeparamref name="TPixel"/> /// Gets the global <see cref="PixelOperations{TPixel}"/> instance for the pixel type <typeparamref name="TPixel"/>
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Configuration configuration, Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels, ReadOnlySpan<TSourcePixel> sourcePixels,
Span<TPixel> destinationPixels) Span<TPixel> destinationPixels)
where TSourcePixel : struct, IPixel<TSourcePixel> where TSourcePixel : unmanaged, IPixel<TSourcePixel>
{ {
const int SliceLength = 1024; const int SliceLength = 1024;
int numberOfSlices = sourcePixels.Length / SliceLength; int numberOfSlices = sourcePixels.Length / SliceLength;
@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.PixelFormats
Configuration configuration, Configuration configuration,
ReadOnlySpan<TPixel> sourcePixels, ReadOnlySpan<TPixel> sourcePixels,
Span<TDestinationPixel> destinationPixels) Span<TDestinationPixel> destinationPixels)
where TDestinationPixel : struct, IPixel<TDestinationPixel> where TDestinationPixel : unmanaged, IPixel<TDestinationPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels));

16
src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
Span<Vector4> sourceVectors, Span<Vector4> sourceVectors,
Span<TPixel> destPixels, Span<TPixel> destPixels,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels)); Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels));
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
ReadOnlySpan<TPixel> sourcePixels, ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors, Span<Vector4> destVectors,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors));
@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
Span<Vector4> sourceVectors, Span<Vector4> sourceVectors,
Span<TPixel> destPixels, Span<TPixel> destPixels,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ApplyBackwardConversionModifiers(sourceVectors, modifiers); ApplyBackwardConversionModifiers(sourceVectors, modifiers);
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
ReadOnlySpan<TPixel> sourcePixels, ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors, Span<Vector4> destVectors,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
if (modifiers.IsDefined(PixelConversionModifiers.Scale)) if (modifiers.IsDefined(PixelConversionModifiers.Scale))
{ {
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
private static void UnsafeFromVector4Core<TPixel>( private static void UnsafeFromVector4Core<TPixel>(
ReadOnlySpan<Vector4> sourceVectors, ReadOnlySpan<Vector4> sourceVectors,
Span<TPixel> destPixels) Span<TPixel> destPixels)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors); ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels); ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
private static void UnsafeToVector4Core<TPixel>( private static void UnsafeToVector4Core<TPixel>(
ReadOnlySpan<TPixel> sourcePixels, ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors) Span<Vector4> destVectors)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Vector4 destRef = ref MemoryMarshal.GetReference(destVectors); ref Vector4 destRef = ref MemoryMarshal.GetReference(destVectors);
@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
private static void UnsafeFromScaledVector4Core<TPixel>( private static void UnsafeFromScaledVector4Core<TPixel>(
ReadOnlySpan<Vector4> sourceVectors, ReadOnlySpan<Vector4> sourceVectors,
Span<TPixel> destinationColors) Span<TPixel> destinationColors)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors); ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors);
ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors); ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors);
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
private static void UnsafeToScaledVector4Core<TPixel>( private static void UnsafeToScaledVector4Core<TPixel>(
ReadOnlySpan<TPixel> sourceColors, ReadOnlySpan<TPixel> sourceColors,
Span<Vector4> destinationVectors) Span<Vector4> destinationVectors)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourceColors); ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourceColors);
ref Vector4 destRef = ref MemoryMarshal.GetReference(destinationVectors); ref Vector4 destRef = ref MemoryMarshal.GetReference(destinationVectors);

4
src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs

@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
ReadOnlySpan<TPixel> sourcePixels, ReadOnlySpan<TPixel> sourcePixels,
Span<Vector4> destVectors, Span<Vector4> destVectors,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors));
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
Span<Vector4> sourceVectors, Span<Vector4> sourceVectors,
Span<TPixel> destPixels, Span<TPixel> destPixels,
PixelConversionModifiers modifiers) PixelConversionModifiers modifiers)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels)); Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels));

2
src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam> /// <typeparam name="TPixel">The pixel format</typeparam>
internal class DefaultImageProcessorContext<TPixel> : IInternalImageProcessingContext<TPixel> internal class DefaultImageProcessorContext<TPixel> : IInternalImageProcessingContext<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly bool mutate; private readonly bool mutate;
private readonly Image<TPixel> source; private readonly Image<TPixel> source;

18
src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs

@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image to mutate.</param> /// <param name="source">The image to mutate.</param>
/// <param name="operation">The operation to perform on the source.</param> /// <param name="operation">The operation to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation) public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Mutate(source, source.GetConfiguration(), operation); => Mutate(source, source.GetConfiguration(), operation);
/// <summary> /// <summary>
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param> /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="operation">The operation to perform on the source.</param> /// <param name="operation">The operation to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, Configuration configuration, Action<IImageProcessingContext> operation) public static void Mutate<TPixel>(this Image<TPixel> source, Configuration configuration, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image to mutate.</param> /// <param name="source">The image to mutate.</param>
/// <param name="operations">The operations to perform on the source.</param> /// <param name="operations">The operations to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations) public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Mutate(source, source.GetConfiguration(), operations); => Mutate(source, source.GetConfiguration(), operations);
/// <summary> /// <summary>
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param> /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
/// <param name="operations">The operations to perform on the source.</param> /// <param name="operations">The operations to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, Configuration configuration, params IImageProcessor[] operations) public static void Mutate<TPixel>(this Image<TPixel> source, Configuration configuration, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.NotNull(operations, nameof(operations)); Guard.NotNull(operations, nameof(operations));
@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="operation">The operation to perform on the clone.</param> /// <param name="operation">The operation to perform on the clone.</param>
/// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns> /// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Clone(source, source.GetConfiguration(), operation); => Clone(source, source.GetConfiguration(), operation);
/// <summary> /// <summary>
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="operation">The operation to perform on the clone.</param> /// <param name="operation">The operation to perform on the clone.</param>
/// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns> /// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Configuration configuration, Action<IImageProcessingContext> operation) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Configuration configuration, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="operations">The operations to perform on the clone.</param> /// <param name="operations">The operations to perform on the clone.</param>
/// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns> /// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> Clone(source, source.GetConfiguration(), operations); => Clone(source, source.GetConfiguration(), operations);
/// <summary> /// <summary>
@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="operations">The operations to perform on the clone.</param> /// <param name="operations">The operations to perform on the clone.</param>
/// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns> /// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Configuration configuration, params IImageProcessor[] operations) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Configuration configuration, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp.Processing
public Image ResultImage { get; private set; } public Image ResultImage { get; private set; }
public void Visit<TPixel>(Image<TPixel> image) public void Visit<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
IInternalImageProcessingContext<TPixel> operationsRunner = IInternalImageProcessingContext<TPixel> operationsRunner =
this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate); this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate);

4
src/ImageSharp/Processing/IImageProcessingContextFactory.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="mutate">A flag to determine whether image operations are allowed to mutate the source image.</param> /// <param name="mutate">A flag to determine whether image operations are allowed to mutate the source image.</param>
/// <returns>A new <see cref="IInternalImageProcessingContext{TPixel}"/></returns> /// <returns>A new <see cref="IInternalImageProcessingContext{TPixel}"/></returns>
IInternalImageProcessingContext<TPixel> CreateImageProcessingContext<TPixel>(Configuration configuration, Image<TPixel> source, bool mutate) IInternalImageProcessingContext<TPixel> CreateImageProcessingContext<TPixel>(Configuration configuration, Image<TPixel> source, bool mutate)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
} }
/// <summary> /// <summary>
@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Processing
{ {
/// <inheritdoc/> /// <inheritdoc/>
public IInternalImageProcessingContext<TPixel> CreateImageProcessingContext<TPixel>(Configuration configuration, Image<TPixel> source, bool mutate) public IInternalImageProcessingContext<TPixel> CreateImageProcessingContext<TPixel>(Configuration configuration, Image<TPixel> source, bool mutate)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return new DefaultImageProcessorContext<TPixel>(configuration, source, mutate); return new DefaultImageProcessorContext<TPixel>(configuration, source, mutate);
} }

2
src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel type.</typeparam> /// <typeparam name="TPixel">The pixel type.</typeparam>
internal interface IInternalImageProcessingContext<TPixel> : IImageProcessingContext internal interface IInternalImageProcessingContext<TPixel> : IImageProcessingContext
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Returns the result image to return by <see cref="ProcessingExtensions.Clone(Image, Configuration, System.Action{IImageProcessingContext})"/> /// Returns the result image to return by <see cref="ProcessingExtensions.Clone(Image, Configuration, System.Action{IImageProcessingContext})"/>

2
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new BinaryThresholdProcessor<TPixel>(configuration, this, source, sourceRectangle); => new BinaryThresholdProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class BinaryThresholdProcessor<TPixel> : ImageProcessor<TPixel> internal class BinaryThresholdProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly BinaryThresholdProcessor definition; private readonly BinaryThresholdProcessor definition;

2
src/ImageSharp/Processing/Processors/CloningImageProcessor.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
{ {
/// <inheritdoc/> /// <inheritdoc/>
public abstract ICloningImageProcessor<TPixel> CreatePixelSpecificCloningProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public abstract ICloningImageProcessor<TPixel> CreatePixelSpecificCloningProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
/// <inheritdoc/> /// <inheritdoc/>
IImageProcessor<TPixel> IImageProcessor.CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) IImageProcessor<TPixel> IImageProcessor.CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)

2
src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
public abstract class CloningImageProcessor<TPixel> : ICloningImageProcessor<TPixel> public abstract class CloningImageProcessor<TPixel> : ICloningImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CloningImageProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="CloningImageProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new BokehBlurProcessor<TPixel>(configuration, this, source, sourceRectangle); => new BokehBlurProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <remarks>This processor is based on the code from Mike Pound, see <a href="https://github.com/mikepound/convolve">github.com/mikepound/convolve</a>.</remarks> /// <remarks>This processor is based on the code from Mike Pound, see <a href="https://github.com/mikepound/convolve">github.com/mikepound/convolve</a>.</remarks>
internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel> internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// The gamma highlight factor to use when applying the effect /// The gamma highlight factor to use when applying the effect

2
src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new BoxBlurProcessor<TPixel>(configuration, this, source, sourceRectangle); => new BoxBlurProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class BoxBlurProcessor<TPixel> : ImageProcessor<TPixel> internal class BoxBlurProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BoxBlurProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="BoxBlurProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class Convolution2DProcessor<TPixel> : ImageProcessor<TPixel> internal class Convolution2DProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Convolution2DProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="Convolution2DProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel> internal class Convolution2PassProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Convolution2PassProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="Convolution2PassProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel> internal class ConvolutionProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ConvolutionProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="ConvolutionProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class EdgeDetector2DProcessor<TPixel> : ImageProcessor<TPixel> internal class EdgeDetector2DProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="EdgeDetector2DProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="EdgeDetector2DProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class EdgeDetectorCompassProcessor<TPixel> : ImageProcessor<TPixel> internal class EdgeDetectorCompassProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="EdgeDetectorCompassProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="EdgeDetectorCompassProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs

@ -26,6 +26,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <inheritdoc /> /// <inheritdoc />
public abstract IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public abstract IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
} }
} }

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class EdgeDetectorProcessor<TPixel> : ImageProcessor<TPixel> internal class EdgeDetectorProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="EdgeDetectorProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="EdgeDetectorProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new GaussianBlurProcessor<TPixel>(configuration, this, source, sourceRectangle); => new GaussianBlurProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class GaussianBlurProcessor<TPixel> : ImageProcessor<TPixel> internal class GaussianBlurProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GaussianBlurProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="GaussianBlurProcessor{TPixel}"/> class.

2
src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new GaussianSharpenProcessor<TPixel>(configuration, this, source, sourceRectangle); => new GaussianSharpenProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class GaussianSharpenProcessor<TPixel> : ImageProcessor<TPixel> internal class GaussianSharpenProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GaussianSharpenProcessor{TPixel}"/> class. /// Initializes a new instance of the <see cref="GaussianSharpenProcessor{TPixel}"/> class.

6
src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
Memory<byte> output, Memory<byte> output,
Rectangle bounds) Rectangle bounds)
where TFrameQuantizer : struct, IFrameQuantizer<TPixel> where TFrameQuantizer : struct, IFrameQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Span<byte> outputSpan = output.Span; Span<byte> outputSpan = output.Span;
ReadOnlySpan<TPixel> paletteSpan = palette.Span; ReadOnlySpan<TPixel> paletteSpan = palette.Span;
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
Rectangle bounds, Rectangle bounds,
float scale) float scale)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var pixelMap = new EuclideanPixelMap<TPixel>(palette); var pixelMap = new EuclideanPixelMap<TPixel>(palette);
@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
int x, int x,
int y, int y,
float scale) float scale)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// Equal? Break out as there's no error to pass. // Equal? Break out as there's no error to pass.
if (source.Equals(transformed)) if (source.Equals(transformed))

4
src/ImageSharp/Processing/Processors/Dithering/IDither.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
Memory<byte> output, Memory<byte> output,
Rectangle bounds) Rectangle bounds)
where TFrameQuantizer : struct, IFrameQuantizer<TPixel> where TFrameQuantizer : struct, IFrameQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
/// <summary> /// <summary>
/// Transforms the image frame applying a dither matrix. /// Transforms the image frame applying a dither matrix.
@ -48,6 +48,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
Rectangle bounds, Rectangle bounds,
float scale) float scale)
where TPixel : struct, IPixel<TPixel>; where TPixel : unmanaged, IPixel<TPixel>;
} }
} }

10
src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs

@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
Memory<byte> output, Memory<byte> output,
Rectangle bounds) Rectangle bounds)
where TFrameQuantizer : struct, IFrameQuantizer<TPixel> where TFrameQuantizer : struct, IFrameQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var ditherOperation = new QuantizeDitherRowIntervalOperation<TFrameQuantizer, TPixel>( var ditherOperation = new QuantizeDitherRowIntervalOperation<TFrameQuantizer, TPixel>(
ref quantizer, ref quantizer,
@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
Rectangle bounds, Rectangle bounds,
float scale) float scale)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
var ditherOperation = new PaletteDitherRowIntervalOperation<TPixel>( var ditherOperation = new PaletteDitherRowIntervalOperation<TPixel>(
in Unsafe.AsRef(this), in Unsafe.AsRef(this),
@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
int y, int y,
int bitDepth, int bitDepth,
float scale) float scale)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
Rgba32 rgba = default; Rgba32 rgba = default;
source.ToRgba32(ref rgba); source.ToRgba32(ref rgba);
@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
private readonly struct QuantizeDitherRowIntervalOperation<TFrameQuantizer, TPixel> : IRowIntervalOperation private readonly struct QuantizeDitherRowIntervalOperation<TFrameQuantizer, TPixel> : IRowIntervalOperation
where TFrameQuantizer : struct, IFrameQuantizer<TPixel> where TFrameQuantizer : struct, IFrameQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly TFrameQuantizer quantizer; private readonly TFrameQuantizer quantizer;
private readonly OrderedDither dither; private readonly OrderedDither dither;
@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
} }
private readonly struct PaletteDitherRowIntervalOperation<TPixel> : IRowIntervalOperation private readonly struct PaletteDitherRowIntervalOperation<TPixel> : IRowIntervalOperation
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly OrderedDither dither; private readonly OrderedDither dither;
private readonly ImageFrame<TPixel> source; private readonly ImageFrame<TPixel> source;

2
src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs

@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new PaletteDitherProcessor<TPixel>(configuration, this, source, sourceRectangle); => new PaletteDitherProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal sealed class PaletteDitherProcessor<TPixel> : ImageProcessor<TPixel> internal sealed class PaletteDitherProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly int paletteLength; private readonly int paletteLength;
private readonly IDither dither; private readonly IDither dither;

6
src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixelBg> CreatePixelSpecificProcessor<TPixelBg>(Configuration configuration, Image<TPixelBg> source, Rectangle sourceRectangle) public IImageProcessor<TPixelBg> CreatePixelSpecificProcessor<TPixelBg>(Configuration configuration, Image<TPixelBg> source, Rectangle sourceRectangle)
where TPixelBg : struct, IPixel<TPixelBg> where TPixelBg : unmanaged, IPixel<TPixelBg>
{ {
var visitor = new ProcessorFactoryVisitor<TPixelBg>(configuration, this, source, sourceRectangle); var visitor = new ProcessorFactoryVisitor<TPixelBg>(configuration, this, source, sourceRectangle);
this.Image.AcceptVisitor(visitor); this.Image.AcceptVisitor(visitor);
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
} }
private class ProcessorFactoryVisitor<TPixelBg> : IImageVisitor private class ProcessorFactoryVisitor<TPixelBg> : IImageVisitor
where TPixelBg : struct, IPixel<TPixelBg> where TPixelBg : unmanaged, IPixel<TPixelBg>
{ {
private readonly Configuration configuration; private readonly Configuration configuration;
private readonly DrawImageProcessor definition; private readonly DrawImageProcessor definition;
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
public IImageProcessor<TPixelBg> Result { get; private set; } public IImageProcessor<TPixelBg> Result { get; private set; }
public void Visit<TPixelFg>(Image<TPixelFg> image) public void Visit<TPixelFg>(Image<TPixelFg> image)
where TPixelFg : struct, IPixel<TPixelFg> where TPixelFg : unmanaged, IPixel<TPixelFg>
{ {
this.Result = new DrawImageProcessor<TPixelBg, TPixelFg>( this.Result = new DrawImageProcessor<TPixelBg, TPixelFg>(
this.configuration, this.configuration,

4
src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs

@ -15,8 +15,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <typeparam name="TPixelBg">The pixel format of destination image.</typeparam> /// <typeparam name="TPixelBg">The pixel format of destination image.</typeparam>
/// <typeparam name="TPixelFg">The pixel format of source image.</typeparam> /// <typeparam name="TPixelFg">The pixel format of source image.</typeparam>
internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg> internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg>
where TPixelBg : struct, IPixel<TPixelBg> where TPixelBg : unmanaged, IPixel<TPixelBg>
where TPixelFg : struct, IPixel<TPixelFg> where TPixelFg : unmanaged, IPixel<TPixelFg>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DrawImageProcessor{TPixelBg, TPixelFg}"/> class. /// Initializes a new instance of the <see cref="DrawImageProcessor{TPixelBg, TPixelFg}"/> class.

2
src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new OilPaintingProcessor<TPixel>(configuration, this, source, sourceRectangle); => new OilPaintingProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <remarks>Adapted from <see href="https://softwarebydefault.com/2013/06/29/oil-painting-cartoon-filter/"/> by Dewald Esterhuizen.</remarks> /// <remarks>Adapted from <see href="https://softwarebydefault.com/2013/06/29/oil-painting-cartoon-filter/"/> by Dewald Esterhuizen.</remarks>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class OilPaintingProcessor<TPixel> : ImageProcessor<TPixel> internal class OilPaintingProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly OilPaintingProcessor definition; private readonly OilPaintingProcessor definition;

2
src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return new PixelRowDelegateProcessor<TPixel, PixelRowDelegate>( return new PixelRowDelegateProcessor<TPixel, PixelRowDelegate>(
new PixelRowDelegate(this.PixelRowOperation), new PixelRowDelegate(this.PixelRowOperation),

2
src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
/// <typeparam name="TDelegate">The row processor type.</typeparam> /// <typeparam name="TDelegate">The row processor type.</typeparam>
internal sealed class PixelRowDelegateProcessor<TPixel, TDelegate> : ImageProcessor<TPixel> internal sealed class PixelRowDelegateProcessor<TPixel, TDelegate> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
where TDelegate : struct, IPixelRowDelegate where TDelegate : struct, IPixelRowDelegate
{ {
private readonly TDelegate rowDelegate; private readonly TDelegate rowDelegate;

2
src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new PixelateProcessor<TPixel>(configuration, this, source, sourceRectangle); => new PixelateProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class PixelateProcessor<TPixel> : ImageProcessor<TPixel> internal class PixelateProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly PixelateProcessor definition; private readonly PixelateProcessor definition;

2
src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
return new PixelRowDelegateProcessor<TPixel, PixelRowDelegate>( return new PixelRowDelegateProcessor<TPixel, PixelRowDelegate>(
new PixelRowDelegate(this.PixelRowOperation), new PixelRowDelegate(this.PixelRowOperation),

2
src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
/// <inheritdoc /> /// <inheritdoc />
public virtual IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) public virtual IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
=> new FilterProcessor<TPixel>(configuration, this, source, sourceRectangle); => new FilterProcessor<TPixel>(configuration, this, source, sourceRectangle);
} }
} }

2
src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam> /// <typeparam name="TPixel">The pixel format.</typeparam>
internal class FilterProcessor<TPixel> : ImageProcessor<TPixel> internal class FilterProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private readonly FilterProcessor definition; private readonly FilterProcessor definition;

2
src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
/// Converts the colors of the image recreating an old Lomograph effect. /// Converts the colors of the image recreating an old Lomograph effect.
/// </summary> /// </summary>
internal class LomographProcessor<TPixel> : FilterProcessor<TPixel> internal class LomographProcessor<TPixel> : FilterProcessor<TPixel>
where TPixel : struct, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private static readonly Color VeryDarkGreen = Color.FromRgba(0, 10, 0, 255); private static readonly Color VeryDarkGreen = Color.FromRgba(0, 10, 0, 255);

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save