From 5cccfbcacd6382eaca77418429ef791619cca1ce Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 23 Feb 2020 03:12:25 +0100 Subject: [PATCH] Switched pixel format type constraint to unmanaged --- .../Advanced/AdvancedImageExtensions.cs | 16 +- src/ImageSharp/Advanced/AotCompilerTools.cs | 14 +- src/ImageSharp/Advanced/IImageVisitor.cs | 2 +- src/ImageSharp/Advanced/IPixelSource.cs | 2 +- src/ImageSharp/Color/Color.cs | 4 +- .../Common/Helpers/Buffer2DUtils.cs | 2 +- .../Common/Helpers/DenseMatrixUtils.cs | 12 +- src/ImageSharp/Common/Helpers/ImageMaths.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoder.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 20 +- src/ImageSharp/Formats/Bmp/BmpEncoder.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 16 +- src/ImageSharp/Formats/Gif/GifDecoder.cs | 2 +- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 8 +- src/ImageSharp/Formats/Gif/GifEncoder.cs | 2 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 14 +- src/ImageSharp/Formats/IImageDecoder.cs | 2 +- src/ImageSharp/Formats/IImageEncoder.cs | 2 +- .../Decoder/JpegImagePostProcessor.cs | 6 +- .../Encoder/YCbCrForwardConverter{TPixel}.cs | 2 +- src/ImageSharp/Formats/Jpeg/JpegDecoder.cs | 2 +- .../Formats/Jpeg/JpegDecoderCore.cs | 4 +- src/ImageSharp/Formats/Jpeg/JpegEncoder.cs | 2 +- .../Formats/Jpeg/JpegEncoderCore.cs | 8 +- src/ImageSharp/Formats/PixelTypeInfo.cs | 2 +- src/ImageSharp/Formats/Png/PngDecoder.cs | 2 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 14 +- src/ImageSharp/Formats/Png/PngEncoder.cs | 2 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 20 +- .../Formats/Png/PngEncoderOptionsHelpers.cs | 10 +- .../Formats/Png/PngScanlineProcessor.cs | 20 +- src/ImageSharp/Formats/Tga/TgaDecoder.cs | 2 +- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 16 +- src/ImageSharp/Formats/Tga/TgaEncoder.cs | 2 +- src/ImageSharp/Formats/Tga/TgaEncoderCore.cs | 18 +- src/ImageSharp/Image.Decode.cs | 4 +- src/ImageSharp/Image.FromBytes.cs | 24 +- src/ImageSharp/Image.FromFile.cs | 12 +- src/ImageSharp/Image.FromStream.cs | 12 +- src/ImageSharp/Image.LoadPixelData.cs | 16 +- src/ImageSharp/Image.WrapMemory.cs | 12 +- src/ImageSharp/Image.cs | 6 +- src/ImageSharp/ImageExtensions.Internal.cs | 2 +- src/ImageSharp/ImageExtensions.cs | 2 +- src/ImageSharp/ImageFrame.LoadPixelData.cs | 4 +- src/ImageSharp/ImageFrame.cs | 2 +- .../ImageFrameCollection{TPixel}.cs | 2 +- src/ImageSharp/ImageFrame{TPixel}.cs | 8 +- src/ImageSharp/Image{TPixel}.cs | 2 +- .../Metadata/Profiles/Exif/ExifProfile.cs | 2 +- src/ImageSharp/PixelFormats/IPixel.cs | 2 +- .../DefaultPixelBlenders.Generated.cs | 2 +- .../DefaultPixelBlenders.Generated.tt | 2 +- .../PorterDuffFunctions.Generated.cs | 216 +++++++++--------- .../PorterDuffFunctions.Generated.tt | 2 +- .../PixelFormats/PixelBlender{TPixel}.cs | 6 +- .../PixelOperations{TPixel}.PixelBenders.cs | 2 +- .../PixelFormats/PixelOperations{TPixel}.cs | 6 +- .../Utils/Vector4Converters.Default.cs | 16 +- .../Utils/Vector4Converters.RgbaCompatible.cs | 4 +- .../DefaultImageProcessorContext{TPixel}.cs | 2 +- .../Extensions/ProcessingExtensions.cs | 18 +- .../IImageProcessingContextFactory.cs | 4 +- ...IInternalImageProcessingContext{TPixel}.cs | 2 +- .../Binarization/BinaryThresholdProcessor.cs | 2 +- .../BinaryThresholdProcessor{TPixel}.cs | 2 +- .../Processors/CloningImageProcessor.cs | 2 +- .../CloningImageProcessor{TPixel}.cs | 2 +- .../Convolution/BokehBlurProcessor.cs | 2 +- .../Convolution/BokehBlurProcessor{TPixel}.cs | 2 +- .../Convolution/BoxBlurProcessor.cs | 2 +- .../Convolution/BoxBlurProcessor{TPixel}.cs | 2 +- .../Convolution2DProcessor{TPixel}.cs | 2 +- .../Convolution2PassProcessor{TPixel}.cs | 2 +- .../ConvolutionProcessor{TPixel}.cs | 2 +- .../EdgeDetector2DProcessor{TPixel}.cs | 2 +- .../EdgeDetectorCompassProcessor{TPixel}.cs | 2 +- .../Convolution/EdgeDetectorProcessor.cs | 2 +- .../EdgeDetectorProcessor{TPixel}.cs | 2 +- .../Convolution/GaussianBlurProcessor.cs | 2 +- .../GaussianBlurProcessor{TPixel}.cs | 2 +- .../Convolution/GaussianSharpenProcessor.cs | 2 +- .../GaussianSharpenProcessor{TPixel}.cs | 2 +- .../Processors/Dithering/ErrorDither.cs | 6 +- .../Processors/Dithering/IDither.cs | 4 +- .../Processors/Dithering/OrderedDither.cs | 10 +- .../Dithering/PaletteDitherProcessor.cs | 2 +- .../PaletteDitherProcessor{TPixel}.cs | 2 +- .../Processors/Drawing/DrawImageProcessor.cs | 6 +- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 4 +- .../Effects/OilPaintingProcessor.cs | 2 +- .../Effects/OilPaintingProcessor{TPixel}.cs | 2 +- .../Effects/PixelRowDelegateProcessor.cs | 2 +- ...lRowDelegateProcessor{TPixel,TDelegate}.cs | 2 +- .../Processors/Effects/PixelateProcessor.cs | 2 +- .../Effects/PixelateProcessor{TPixel}.cs | 2 +- .../PositionAwarePixelRowDelegateProcessor.cs | 2 +- .../Processors/Filters/FilterProcessor.cs | 2 +- .../Filters/FilterProcessor{TPixel}.cs | 2 +- .../Filters/LomographProcessor{TPixel}.cs | 2 +- .../Filters/PolaroidProcessor{TPixel}.cs | 2 +- .../Processors/ICloningImageProcessor.cs | 2 +- .../ICloningImageProcessor{TPixel}.cs | 2 +- .../Processing/Processors/IImageProcessor.cs | 2 +- .../Processors/IImageProcessor{TPixel}.cs | 2 +- .../Processors/ImageProcessorExtensions.cs | 2 +- .../Processors/ImageProcessor{TPixel}.cs | 2 +- ...eHistogramEqualizationProcessor{TPixel}.cs | 2 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 2 +- ...lHistogramEqualizationProcessor{TPixel}.cs | 2 +- .../HistogramEqualizationProcessor.cs | 2 +- .../HistogramEqualizationProcessor{TPixel}.cs | 2 +- .../Overlays/BackgroundColorProcessor.cs | 2 +- .../BackgroundColorProcessor{TPixel}.cs | 2 +- .../Processors/Overlays/GlowProcessor.cs | 2 +- .../Overlays/GlowProcessor{TPixel}.cs | 2 +- .../Processors/Overlays/VignetteProcessor.cs | 2 +- .../Overlays/VignetteProcessor{TPixel}.cs | 2 +- .../Quantization/EuclideanPixelMap{TPixel}.cs | 2 +- .../Quantization/FrameQuantizerExtensions.cs | 6 +- .../Quantization/IFrameQuantizer{TPixel}.cs | 2 +- .../Quantization/IPixelMap{TPixel}.cs | 2 +- .../Processors/Quantization/IQuantizer.cs | 4 +- .../OctreeFrameQuantizer{TPixel}.cs | 2 +- .../Quantization/OctreeQuantizer.cs | 4 +- .../PaletteFrameQuantizer{TPixel}.cs | 2 +- .../Quantization/PaletteQuantizer.cs | 4 +- .../Quantization/QuantizeProcessor.cs | 2 +- .../Quantization/QuantizeProcessor{TPixel}.cs | 2 +- .../Quantization/QuantizedFrame{TPixel}.cs | 2 +- .../Quantization/WuFrameQuantizer{TPixel}.cs | 2 +- .../Processors/Quantization/WuQuantizer.cs | 4 +- .../AffineTransformProcessor{TPixel}.cs | 2 +- .../Transforms/AutoOrientProcessor.cs | 2 +- .../Transforms/AutoOrientProcessor{TPixel}.cs | 2 +- .../Transforms/CropProcessor{TPixel}.cs | 2 +- .../Transforms/EntropyCropProcessor.cs | 2 +- .../EntropyCropProcessor{TPixel}.cs | 2 +- .../Processors/Transforms/FlipProcessor.cs | 2 +- .../Transforms/FlipProcessor{TPixel}.cs | 2 +- .../ProjectiveTransformProcessor{TPixel}.cs | 2 +- .../Resize/ResizeProcessor{TPixel}.cs | 2 +- .../Transforms/Resize/ResizeWorker.cs | 2 +- .../Transforms/RotateProcessor{TPixel}.cs | 2 +- .../Transforms/TransformKernelMap.cs | 2 +- .../Transforms/TransformProcessor.cs | 2 +- .../Transforms/TransformProcessorHelpers.cs | 2 +- .../Color/Bulk/FromRgba32Bytes.cs | 2 +- .../Color/Bulk/FromVector4.cs | 2 +- .../Color/Bulk/Rgb24Bytes.cs | 2 +- .../Color/Bulk/ToRgba32Bytes.cs | 2 +- .../Color/Bulk/ToVector4.cs | 2 +- .../PixelConversion_Rgba32_To_Argb32.cs | 2 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 4 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 4 +- .../ImageSharp.Benchmarks/Samplers/Resize.cs | 2 +- .../Advanced/AdvancedImageExtensionsTests.cs | 14 +- .../Drawing/DrawImageTests.cs | 8 +- .../Formats/Bmp/BmpDecoderTests.cs | 70 +++--- .../Formats/Bmp/BmpEncoderTests.cs | 34 +-- .../Formats/GeneralFormatTests.cs | 4 +- .../Formats/Gif/GifDecoderTests.cs | 14 +- .../Formats/Gif/GifEncoderTests.cs | 4 +- .../Formats/Jpg/GenericBlock8x8Tests.cs | 6 +- .../Formats/Jpg/JpegDecoderTests.Baseline.cs | 4 +- .../Jpg/JpegDecoderTests.Progressive.cs | 2 +- .../Formats/Jpg/JpegDecoderTests.cs | 8 +- .../Formats/Jpg/JpegEncoderTests.cs | 8 +- .../Jpg/JpegImagePostProcessorTests.cs | 6 +- .../Formats/Jpg/LibJpegToolsTests.cs | 2 +- .../Formats/Jpg/SpectralJpegTests.cs | 6 +- .../Formats/Jpg/Utils/VerifyJpeg.cs | 2 +- .../Formats/Png/PngDecoderTests.cs | 24 +- .../Formats/Png/PngEncoderTests.cs | 20 +- .../Formats/Png/PngMetadataTests.cs | 8 +- .../Formats/Png/PngSmokeTests.cs | 8 +- .../Formats/Tga/TgaDecoderTests.cs | 34 +-- .../Formats/Tga/TgaEncoderTests.cs | 20 +- .../Formats/Tga/TgaTestUtils.cs | 4 +- .../ImageFrameCollectionTests.Generic.cs | 4 +- .../ImageFrameCollectionTests.NonGeneric.cs | 8 +- .../PixelFormats/PixelBlenderTests.cs | 2 +- .../PorterDuffFunctionsTestsTPixel.cs | 54 ++--- ...ConverterTests.ReferenceImplementations.cs | 4 +- .../PixelOperations/PixelOperationsTests.cs | 6 +- .../Processing/FakeImageOperationsProvider.cs | 10 +- .../HistogramEqualizationTests.cs | 6 +- .../Binarization/BinaryDitherTests.cs | 12 +- .../Binarization/BinaryThresholdTest.cs | 4 +- .../Basic1ParameterConvolutionTests.cs | 4 +- .../Processors/Convolution/BokehBlurTest.cs | 8 +- .../Processors/Convolution/DetectEdgesTest.cs | 12 +- .../Processors/Dithering/DitherTests.cs | 14 +- .../Processors/Effects/BackgroundColorTest.cs | 4 +- .../Processors/Effects/OilPaintTest.cs | 4 +- .../Processors/Effects/PixelShaderTest.cs | 8 +- .../Processors/Effects/PixelateTest.cs | 4 +- .../Processors/Filters/BlackWhiteTest.cs | 2 +- .../Processors/Filters/BrightnessTest.cs | 2 +- .../Processors/Filters/ColorBlindnessTest.cs | 2 +- .../Processors/Filters/ContrastTest.cs | 2 +- .../Processors/Filters/FilterTest.cs | 6 +- .../Processors/Filters/GrayscaleTest.cs | 2 +- .../Processing/Processors/Filters/HueTest.cs | 2 +- .../Processors/Filters/InvertTest.cs | 2 +- .../Processors/Filters/KodachromeTest.cs | 2 +- .../Processors/Filters/LightnessTest.cs | 2 +- .../Processors/Filters/LomographTest.cs | 2 +- .../Processors/Filters/OpacityTest.cs | 2 +- .../Processors/Filters/PolaroidTest.cs | 2 +- .../Processors/Filters/SaturateTest.cs | 2 +- .../Processors/Filters/SepiaTest.cs | 2 +- .../Processors/Overlays/OverlayTestBase.cs | 8 +- .../Processors/Quantization/QuantizerTests.cs | 6 +- .../Transforms/AffineTransformTests.cs | 16 +- .../Processors/Transforms/AutoOrientTests.cs | 4 +- .../Processors/Transforms/CropTest.cs | 2 +- .../Processors/Transforms/EntropyCropTest.cs | 2 +- .../Processors/Transforms/FlipTests.cs | 4 +- .../Processors/Transforms/PadTest.cs | 4 +- .../Processors/Transforms/ResizeTests.cs | 50 ++-- .../Processors/Transforms/RotateFlipTests.cs | 2 +- .../Processors/Transforms/RotateTests.cs | 4 +- .../Processors/Transforms/SkewTests.cs | 4 +- .../Transforms/ProjectiveTransformTests.cs | 8 +- .../Quantization/QuantizedImageTests.cs | 6 +- .../Quantization/WuQuantizerTests.cs | 2 +- tests/ImageSharp.Tests/TestFormat.cs | 8 +- .../ImageComparison/ImageComparer.cs | 20 +- .../ImageComparison/ImageSimilarityReport.cs | 4 +- .../ImageProviders/BlankProvider.cs | 2 +- .../ImageProviders/FileProvider.cs | 2 +- .../ImageProviders/MemberMethodProvider.cs | 2 +- .../ImageProviders/SolidProvider.cs | 2 +- .../ImageProviders/TestImageProvider.cs | 2 +- .../ImageProviders/TestPatternProvider.cs | 2 +- .../TestUtilities/ImagingTestCaseUtility.cs | 6 +- .../ReferenceCodecs/MagickReferenceDecoder.cs | 6 +- .../ReferenceCodecs/SystemDrawingBridge.cs | 6 +- .../SystemDrawingReferenceDecoder.cs | 2 +- .../SystemDrawingReferenceEncoder.cs | 2 +- .../TestUtilities/TestImageExtensions.cs | 52 ++--- .../TestUtilities/TestPixel.cs | 2 +- .../TestUtilities/TestUtils.cs | 16 +- .../TestUtilities/Tests/GroupOutputTests.cs | 4 +- .../TestUtilities/Tests/ImageComparerTests.cs | 16 +- .../Tests/MagickReferenceCodecTests.cs | 4 +- .../Tests/ReferenceDecoderBenchmarks.cs | 8 +- .../Tests/SystemDrawingReferenceCodecTests.cs | 14 +- .../Tests/TestImageExtensionsTests.cs | 14 +- .../Tests/TestImageProviderTests.cs | 44 ++-- .../Tests/TestUtilityExtensionsTests.cs | 6 +- tests/ImageSharp.Tests/VectorAssert.cs | 2 +- 253 files changed, 876 insertions(+), 876 deletions(-) diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs index a988e22b2..0273f02f5 100644 --- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs +++ b/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 . /// public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source)); /// @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Advanced /// therefore it's not recommended to mutate the image while holding a reference to it's . /// public static IMemoryGroup GetPixelMemoryGroup(this Image source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source)); /// @@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Advanced [Obsolete( @"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")] public static Span GetPixelSpan(this ImageFrame source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Advanced [Obsolete( @"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")] public static Span GetPixelSpan(this Image source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); @@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Advanced /// The row. /// The public static Span GetPixelRowSpan(this ImageFrame source, int rowIndex) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Advanced /// The row. /// The public static Span GetPixelRowSpan(this Image source, int rowIndex) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); @@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Advanced /// The row. /// The public static Memory GetPixelRowMemory(this ImageFrame source, int rowIndex) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); @@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Advanced /// The row. /// The public static Memory GetPixelRowMemory(this Image source, int rowIndex) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs index c8c8568e4..23ae62c7a 100644 --- a/src/ImageSharp/Advanced/AotCompilerTools.cs +++ b/src/ImageSharp/Advanced/AotCompilerTools.cs @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void Seed() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // This is we actually call all the individual methods you need to seed. AotCompileOctreeQuantizer(); @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void AotCompileOctreeQuantizer() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var test = new OctreeFrameQuantizer(Configuration.Default, new OctreeQuantizer().Options)) { @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void AotCompileWuQuantizer() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var test = new WuFrameQuantizer(Configuration.Default, new WuQuantizer().Options)) { @@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void AotCompilePaletteQuantizer() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var test = (PaletteFrameQuantizer)new PaletteQuantizer(Array.Empty()).CreateFrameQuantizer(Configuration.Default)) { @@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void AotCompileDithering() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ErrorDither errorDither = ErrorDither.FloydSteinberg; OrderedDither orderedDither = OrderedDither.Bayer2x2; @@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Advanced /// The image encoder to seed. /// The pixel format. private static void AotCodec(IImageDecoder decoder, IImageEncoder encoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { try { @@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The pixel format. private static void AotCompilePixelOperations() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var pixelOp = new PixelOperations(); pixelOp.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.Clear); diff --git a/src/ImageSharp/Advanced/IImageVisitor.cs b/src/ImageSharp/Advanced/IImageVisitor.cs index ba8b13e2e..079db42c0 100644 --- a/src/ImageSharp/Advanced/IImageVisitor.cs +++ b/src/ImageSharp/Advanced/IImageVisitor.cs @@ -17,6 +17,6 @@ namespace SixLabors.ImageSharp.Advanced /// The image. /// The pixel type. void Visit(Image image) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Advanced/IPixelSource.cs b/src/ImageSharp/Advanced/IPixelSource.cs index a321e877b..d7162bc61 100644 --- a/src/ImageSharp/Advanced/IPixelSource.cs +++ b/src/ImageSharp/Advanced/IPixelSource.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// The type of the pixel. internal interface IPixelSource - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Gets the pixel buffer. diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index fcf091638..e0f9d1e8d 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -220,7 +220,7 @@ namespace SixLabors.ImageSharp /// The pixel value. [MethodImpl(InliningOptions.ShortMethod)] public TPixel ToPixel() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; pixel.FromRgba64(this.data); @@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp Configuration configuration, ReadOnlySpan source, Span destination) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ReadOnlySpan rgba64Span = MemoryMarshal.Cast(source); PixelOperations.Instance.FromRgba64(configuration, rgba64Span, destination); diff --git a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs index f82774601..312ab388d 100644 --- a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs +++ b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp int maxRow, int minColumn, int maxColumn) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ComplexVector4 vector = default; int kernelLength = kernel.Length; diff --git a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs index ff6e3a4ec..bd25a7b44 100644 --- a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs +++ b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp int maxRow, int minColumn, int maxColumn) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Convolve2DImpl( in matrixY, @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp int maxRow, int minColumn, int maxColumn) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Convolve2DImpl( in matrixY, @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp int minColumn, int maxColumn, out Vector4 vector) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Vector4 vectorY = default; Vector4 vectorX = default; @@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp int maxRow, int minColumn, int maxColumn) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Vector4 vector = default; @@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp int maxRow, int minColumn, int maxColumn) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Vector4 vector = default; @@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp int minColumn, int maxColumn, ref Vector4 vector) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int matrixHeight = matrix.Rows; int matrixWidth = matrix.Columns; diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index e7b14be42..84d3b13b0 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp /// The . /// public static Rectangle GetFilteredBoundingRectangle(ImageFrame bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int width = bitmap.Width; int height = bitmap.Height; diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index e5546b361..a956f19c7 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(stream, nameof(stream)); diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 80b20c025..dfdbb22fa 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// /// The decoded image. public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { try { @@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The output pixel buffer containing the decoded image. /// Whether the bitmap is inverted. private void ReadBitFields(Buffer2D pixels, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (this.infoHeader.BitsPerPixel == 16) { @@ -296,7 +296,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The height of the bitmap. /// Whether the bitmap is inverted. private void ReadRle(BmpCompression compression, Buffer2D pixels, byte[] colors, int width, int height, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default; using (IMemoryOwner buffer = this.memoryAllocator.Allocate(width * height, AllocationOptions.Clean)) @@ -376,7 +376,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The height of the bitmap. /// Whether the bitmap is inverted. private void ReadRle24(Buffer2D pixels, int width, int height, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default; using (IMemoryOwner buffer = this.memoryAllocator.Allocate(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. /// Whether the bitmap is inverted. private void ReadRgbPalette(Buffer2D pixels, byte[] colors, int width, int height, int bitsPerPixel, int bytesPerColorMapEntry, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Pixels per byte (bits per pixel). int ppb = 8 / bitsPerPixel; @@ -872,7 +872,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The bitmask for the green channel. /// The bitmask for the blue channel. private void ReadRgb16(Buffer2D pixels, int width, int height, bool inverted, int redMask = DefaultRgb16RMask, int greenMask = DefaultRgb16GMask, int blueMask = DefaultRgb16BMask) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int padding = CalculatePadding(width, 2); int stride = (width * 2) + padding; @@ -939,7 +939,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The height of the bitmap. /// Whether the bitmap is inverted. private void ReadRgb24(Buffer2D pixels, int width, int height, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int padding = CalculatePadding(width, 3); @@ -968,7 +968,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The height of the bitmap. /// Whether the bitmap is inverted. private void ReadRgb32Fast(Buffer2D pixels, int width, int height, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int padding = CalculatePadding(width, 4); @@ -998,7 +998,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The height of the bitmap. /// Whether the bitmap is inverted. private void ReadRgb32Slow(Buffer2D pixels, int width, int height, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int padding = CalculatePadding(width, 4); @@ -1099,7 +1099,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The bitmask for the blue channel. /// The bitmask for the alpha channel. private void ReadRgb32BitFields(Buffer2D pixels, int width, int height, bool inverted, int redMask, int greenMask, int blueMask, int alphaMask) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default; int padding = CalculatePadding(width, 4); diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs index 612675c33..9c05ae2d5 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator()); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 1b3e0228a..66a60d533 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The containing pixel data. /// private void WriteImage(Stream stream, ImageFrame image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Buffer2D pixels = image.PixelBuffer; switch (this.bitsPerPixel) @@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The to write to. /// The containing pixel data. private void Write32Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4)) { @@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The to write to. /// The containing pixel data. private void Write24Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3)) { @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The to write to. /// The containing pixel data. private void Write16Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2)) { @@ -309,7 +309,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The to write to. /// The containing pixel data. private void Write8Bit(Stream stream, ImageFrame image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { bool isL8 = typeof(TPixel) == typeof(L8); using (IMemoryOwner colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean)) @@ -334,7 +334,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The containing pixel data. /// A byte span of size 1024 for the color palette. private void Write8BitColor(Stream stream, ImageFrame image, Span colorPalette) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using IFrameQuantizer quantizer = this.quantizer.CreateFrameQuantizer(this.configuration); using QuantizedFrame quantized = quantizer.QuantizeFrame(image, image.Bounds()); @@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// The containing pixel data. /// A byte span of size 1024 for the color palette. private void Write8BitGray(Stream stream, ImageFrame image, Span colorPalette) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Create a color palette with 256 different gray values. for (int i = 0; i <= 255; i++) diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs index 24e3d8826..caa076553 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoder.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var decoder = new GifDecoderCore(configuration, this); diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index bc508cba7..02267de1a 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The stream containing image data. /// The decoded image public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image image = null; ImageFrame previousFrame = null; @@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The image to decode the information to. /// The previous frame. private void ReadFrame(ref Image image, ref ImageFrame previousFrame) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.ReadImageDescriptor(); @@ -405,7 +405,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The color table containing the available colors. /// The private void ReadFrameColors(ref Image image, ref ImageFrame previousFrame, Span indices, ReadOnlySpan colorTable, in GifImageDescriptor descriptor) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref byte indicesRef = ref MemoryMarshal.GetReference(indices); int imageWidth = this.logicalScreenDescriptor.Width; @@ -535,7 +535,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The pixel format. /// The frame. private void RestoreToBackground(ImageFrame frame) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (this.restoreArea is null) { diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index 248915cb7..978609d7f 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var encoder = new GifEncoderCore(image.GetConfiguration(), this); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 3a0fa5169..e32910d37 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Formats.Gif } private void EncodeGlobal(Image image, QuantizedFrame quantized, int transparencyIndex, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { for (int i = 0; i < image.Frames.Count; i++) { @@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Formats.Gif } private void EncodeLocal(Image image, QuantizedFrame quantized, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ImageFrame previousFrame = null; GifFrameMetadata previousMeta = null; @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The . /// private int GetTransparentIndex(QuantizedFrame quantized) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Transparent pixels are much more likely to be found at the end of a palette int index = -1; @@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// Whether to use the global color table. /// The stream to write to. private void WriteImageDescriptor(ImageFrame image, bool hasColorTable, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { byte packedValue = GifImageDescriptor.GetPackedValue( localColorTableFlag: hasColorTable, @@ -438,7 +438,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The to encode. /// The stream to write to. private void WriteColorTable(QuantizedFrame image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // The maximum number of colors for the bit depth int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * 3; @@ -462,7 +462,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The containing indexed pixels. /// The stream to write to. private void WriteImageData(QuantizedFrame image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var encoder = new LzwEncoder(this.memoryAllocator, (byte)this.bitDepth)) { diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs index 7188b57a6..7a7fc4b26 100644 --- a/src/ImageSharp/Formats/IImageDecoder.cs +++ b/src/ImageSharp/Formats/IImageDecoder.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats /// The . // TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110) Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; /// /// Decodes the image from the specified stream to an . diff --git a/src/ImageSharp/Formats/IImageEncoder.cs b/src/ImageSharp/Formats/IImageEncoder.cs index 76d831d5a..d5ff4b93c 100644 --- a/src/ImageSharp/Formats/IImageEncoder.cs +++ b/src/ImageSharp/Formats/IImageEncoder.cs @@ -18,6 +18,6 @@ namespace SixLabors.ImageSharp.Formats /// The to encode from. /// The to encode the image data to. void Encode(Image image, Stream stream) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs index 0400978d2..5352a0bff 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// The pixel type /// The destination image public void PostProcess(ImageFrame destination) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.PixelRowCounter = 0; @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// The pixel type /// The destination image. public void DoPostProcessorStep(ImageFrame destination) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (JpegComponentPostProcessor cpp in this.ComponentProcessors) { @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// The pixel type /// The destination image private void ConvertColorsInto(ImageFrame destination) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs index 9619a78fc..ba604e891 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder /// /// The pixel type to work on internal ref struct YCbCrForwardConverter - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// The Y component diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index 31085dbaa..b1144508e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(stream, nameof(stream)); diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 9b6a72cc9..951fec1d4 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The stream, where the image should be. /// The decoded image. public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.ParseStream(stream); this.InitExifProfile(); @@ -958,7 +958,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The pixel format. /// The . private Image PostProcessIntoImage() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (this.ImageWidth == 0 || this.ImageHeight == 0) { diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs index d649d3041..1c4035a98 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var encoder = new JpegEncoderCore(this); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index dcf2d72a5..32f4d2287 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The image to write from. /// The stream to write to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -394,7 +394,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The pixel format. /// The pixel accessor providing access to the image pixels. private void Encode444(Image pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // (Partially done with YCbCrForwardConverter) @@ -891,7 +891,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The pixel format. /// The pixel accessor providing access to the image pixels. private void WriteStartOfScan(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) // TODO: We should allow grayscale writing. @@ -918,7 +918,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The pixel format. /// The pixel accessor providing access to the image pixels. private void Encode420(Image pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.) Block8x8F b = default; diff --git a/src/ImageSharp/Formats/PixelTypeInfo.cs b/src/ImageSharp/Formats/PixelTypeInfo.cs index 66d04f39f..1683519c2 100644 --- a/src/ImageSharp/Formats/PixelTypeInfo.cs +++ b/src/ImageSharp/Formats/PixelTypeInfo.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats public int BitsPerPixel { get; } internal static PixelTypeInfo Create() - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => new PixelTypeInfo(Unsafe.SizeOf() * 8); } } diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index 3b41cfc6e..d605577e7 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The containing image data. /// The decoded image. public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var decoder = new PngDecoderCore(configuration, this); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 2701bd2a7..5702c768c 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// The decoded image. public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var metadata = new ImageMetadata(); PngMetadata pngMetadata = metadata.GetPngMetadata(); @@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The metadata information for the image /// The image that we will populate private void InitializeImage(ImageMetadata metadata, out Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { image = new Image(this.configuration, this.header.Width, this.header.Height, metadata); this.bytesPerPixel = this.CalculateBytesPerPixel(); @@ -471,7 +471,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The pixel data. /// The png metadata private void ReadScanlines(PngChunk chunk, ImageFrame image, PngMetadata pngMetadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var deframeStream = new ZlibInflateStream(this.currentStream, this.ReadNextDataChunk)) { @@ -497,7 +497,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The image to decode to. /// The png metadata private void DecodePixelData(Stream compressedStream, ImageFrame image, PngMetadata pngMetadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { while (this.currentRow < this.header.Height) { @@ -553,7 +553,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The current image. /// The png metadata. private void DecodeInterlacedPixelData(Stream compressedStream, ImageFrame image, PngMetadata pngMetadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int pass = 0; int width = this.header.Width; @@ -642,7 +642,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The image /// The png metadata. private void ProcessDefilteredScanline(ReadOnlySpan defilteredScanline, ImageFrame pixels, PngMetadata pngMetadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span rowSpan = pixels.GetPixelRowSpan(this.currentRow); @@ -726,7 +726,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The column start index. Always 0 for none interlaced images. /// The column increment. Always 1 for none interlaced images. private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defilteredScanline, Span rowSpan, PngMetadata pngMetadata, int pixelOffset = 0, int increment = 1) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Trim the first marker byte from the buffer ReadOnlySpan trimmed = defilteredScanline.Slice(1, defilteredScanline.Length - 1); diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index 3e46ad29e..e654036a8 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this))) { diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 5f14d483b..c62683e10 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The pixel format. /// The image row span. private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); Span rawScanlineSpan = this.currentScanline.GetSpan(); @@ -288,7 +288,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The pixel format. /// The row span. private void CollectTPixelBytes(ReadOnlySpan rowSpan) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span rawScanlineSpan = this.currentScanline.GetSpan(); @@ -372,7 +372,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The quantized pixels. Can be null. /// The row. private void CollectPixelBytes(ReadOnlySpan rowSpan, QuantizedFrame quantized, int row) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { switch (this.options.ColorType) { @@ -441,7 +441,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The row. /// The private IManagedByteBuffer EncodePixelRow(ReadOnlySpan rowSpan, QuantizedFrame quantized, int row) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.CollectPixelBytes(rowSpan, quantized, row); return this.FilterPixelBytes(); @@ -547,7 +547,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The containing image data. /// The quantized frame. private void WritePaletteChunk(Stream stream, QuantizedFrame quantized) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (quantized == null) { @@ -784,7 +784,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The quantized pixel data. Can be null. /// The stream. private void WriteDataChunks(ImageFrame pixels, QuantizedFrame quantized, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { byte[] buffer; int bufferLength; @@ -882,7 +882,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The quantized pixels span. /// The deflate stream. private void EncodePixels(ImageFrame pixels, QuantizedFrame quantized, ZlibDeflateStream deflateStream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int bytesPerScanline = this.CalculateScanlineLength(this.width); int resultLength = bytesPerScanline + 1; @@ -906,7 +906,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The pixels. /// The deflate stream. private void EncodeAdam7Pixels(ImageFrame pixels, ZlibDeflateStream deflateStream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int width = pixels.Width; int height = pixels.Height; @@ -961,7 +961,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// The quantized. /// The deflate stream. private void EncodeAdam7IndexedPixels(QuantizedFrame quantized, ZlibDeflateStream deflateStream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int width = quantized.Width; int height = quantized.Height; diff --git a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs index 172b6208a..20b8c41c9 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Png PngMetadata pngMetadata, out bool use16Bit, out int bytesPerPixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Always take the encoder options over the metadata values. options.Gamma ??= pngMetadata.Gamma; @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Png public static QuantizedFrame CreateQuantizedFrame( PngEncoderOptions options, Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (options.ColorType != PngColorType.Palette) { @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Formats.Png PngEncoderOptions options, Image image, QuantizedFrame quantizedFrame) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { byte bitDepth; if (options.ColorType == PngColorType.Palette) @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// This is not exhaustive but covers many common pixel formats. /// private static PngColorType SuggestColorType() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return typeof(TPixel) switch { @@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// This is not exhaustive but covers many common pixel formats. /// private static PngBitDepth SuggestBitDepth() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return typeof(TPixel) switch { diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 5f9d1de9c..cf365c8b9 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Png bool hasTrans, L16 luminance16Trans, L8 luminanceTrans) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Formats.Png bool hasTrans, L16 luminance16Trans, L8 luminanceTrans) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.Formats.Png Span rowSpan, int bytesPerPixel, int bytesPerSample) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Formats.Png int increment, int bytesPerPixel, int bytesPerSample) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Formats.Png Span rowSpan, ReadOnlySpan palette, byte[] paletteAlpha) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -284,7 +284,7 @@ namespace SixLabors.ImageSharp.Formats.Png int increment, ReadOnlySpan palette, byte[] paletteAlpha) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -331,7 +331,7 @@ namespace SixLabors.ImageSharp.Formats.Png bool hasTrans, Rgb48 rgb48Trans, Rgb24 rgb24Trans) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -404,7 +404,7 @@ namespace SixLabors.ImageSharp.Formats.Png bool hasTrans, Rgb48 rgb48Trans, Rgb24 rgb24Trans) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); @@ -482,7 +482,7 @@ namespace SixLabors.ImageSharp.Formats.Png Span rowSpan, int bytesPerPixel, int bytesPerSample) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -515,7 +515,7 @@ namespace SixLabors.ImageSharp.Formats.Png int increment, int bytesPerPixel, int bytesPerSample) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); diff --git a/src/ImageSharp/Formats/Tga/TgaDecoder.cs b/src/ImageSharp/Formats/Tga/TgaDecoder.cs index a6de902b8..2249c86bf 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoder.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoder.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Tga { /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(stream, nameof(stream)); diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index a86fd3bce..ead004003 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// /// The decoded image. public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { try { @@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// Color map size of one entry in bytes. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadPaletted(int width, int height, Buffer2D pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.memoryAllocator.AllocateManagedByteBuffer(width, AllocationOptions.Clean)) { @@ -285,7 +285,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// Color map size of one entry in bytes. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadPalettedRle(int width, int height, Buffer2D pixels, byte[] palette, int colorMapPixelSizeInBytes, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int bytesPerPixel = 1; using (IMemoryOwner buffer = this.memoryAllocator.Allocate(width * height * bytesPerPixel, AllocationOptions.Clean)) @@ -336,7 +336,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to assign the palette to. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadMonoChrome(int width, int height, Buffer2D pixels, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 1, 0)) { @@ -363,7 +363,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to assign the palette to. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadBgra16(int width, int height, Buffer2D pixels, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 2, 0)) { @@ -398,7 +398,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to assign the palette to. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadBgr24(int width, int height, Buffer2D pixels, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 3, 0)) { @@ -425,7 +425,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to assign the palette to. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadBgra32(int width, int height, Buffer2D pixels, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 4, 0)) { @@ -453,7 +453,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The bytes per pixel. /// Indicates, if the origin of the image is top left rather the bottom left (the default). private void ReadRle(int width, int height, Buffer2D pixels, int bytesPerPixel, bool inverted) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default; using (IMemoryOwner buffer = this.memoryAllocator.Allocate(width * height * bytesPerPixel, AllocationOptions.Clean)) diff --git a/src/ImageSharp/Formats/Tga/TgaEncoder.cs b/src/ImageSharp/Formats/Tga/TgaEncoder.cs index 2fcbb822f..e938067a1 100644 --- a/src/ImageSharp/Formats/Tga/TgaEncoder.cs +++ b/src/ImageSharp/Formats/Tga/TgaEncoder.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator()); encoder.Encode(image, stream); diff --git a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs index d1ec2ed4c..d5d7ce49e 100644 --- a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The containing pixel data. /// private void WriteImage(Stream stream, ImageFrame image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Buffer2D pixels = image.PixelBuffer; switch (this.bitsPerPixel) @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The stream to write the image to. /// The image to encode. private void WriteRunLengthEncodedImage(Stream stream, ImageFrame image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Rgba32 color = default; Buffer2D pixels = image.PixelBuffer; @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// Y coordinate to start searching for the same pixels. /// The number of equal pixels. private byte FindEqualPixels(Buffer2D pixels, int xStart, int yStart) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { byte equalPixelCount = 0; bool firstRow = true; @@ -249,7 +249,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to write to. /// The containing pixel data. private void Write8Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 1)) { @@ -273,7 +273,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to write to. /// The containing pixel data. private void Write16Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2)) { @@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to write to. /// The containing pixel data. private void Write24Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3)) { @@ -321,7 +321,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The to write to. /// The containing pixel data. private void Write32Bit(Stream stream, Buffer2D pixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4)) { @@ -344,7 +344,7 @@ namespace SixLabors.ImageSharp.Formats.Tga /// The pixel to get the luminance from. [MethodImpl(InliningOptions.ShortMethod)] public static int GetLuminance(TPixel sourcePixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var vector = sourcePixel.ToVector4(); return ImageMaths.GetBT709Luminance(ref vector, 256); diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 5c19a4239..c28a21452 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp int width, int height, ImageMetadata metadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Buffer2D uninitializedMemoryBuffer = configuration.MemoryAllocator.Allocate2D(width, height); @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp /// private static (Image img, IImageFormat format) Decode(Stream stream, Configuration config) #pragma warning restore SA1008 // Opening parenthesis must be spaced correctly - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format); if (decoder is null) diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 389fbba6d..0850e2213 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(byte[] data) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(Configuration.Default, data); /// @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(byte[] data, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(Configuration.Default, data, out format); /// @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, byte[] data) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var stream = new MemoryStream(data, 0, data.Length, false, true)) { @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, byte[] data, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var stream = new MemoryStream(data, 0, data.Length, false, true)) { @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(byte[] data, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var stream = new MemoryStream(data, 0, data.Length, false, true)) { @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, byte[] data, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var stream = new MemoryStream(data, 0, data.Length, false, true)) { @@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(ReadOnlySpan data) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(Configuration.Default, data); /// @@ -186,7 +186,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(ReadOnlySpan data, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(Configuration.Default, data, out format); /// @@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(ReadOnlySpan data, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(Configuration.Default, data, decoder); /// @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static unsafe Image Load(Configuration config, ReadOnlySpan data) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { fixed (byte* ptr = &data.GetPinnableReference()) { @@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp Configuration config, ReadOnlySpan data, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { fixed (byte* ptr = &data.GetPinnableReference()) { @@ -254,7 +254,7 @@ namespace SixLabors.ImageSharp Configuration config, ReadOnlySpan data, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { fixed (byte* ptr = &data.GetPinnableReference()) { diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index 95b4b9790..45ea378cf 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(string path) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return Load(Configuration.Default, path); } @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(string path, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return Load(Configuration.Default, path, out format); } @@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, string path) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Stream stream = config.FileSystem.OpenRead(path)) { @@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, string path, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Stream stream = config.FileSystem.OpenRead(path)) { @@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(string path, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return Load(Configuration.Default, path, decoder); } @@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image Load(Configuration config, string path, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Stream stream = config.FileSystem.OpenRead(path)) { diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index db2cc2fd1..d756ff7ac 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(null, stream); /// @@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Stream stream, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(null, stream, out format); /// @@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Stream stream, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => WithSeekableStream(Configuration.Default, stream, s => decoder.Decode(Configuration.Default, s)); /// @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Configuration config, Stream stream, IImageDecoder decoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => WithSeekableStream(config, stream, s => decoder.Decode(config, s)); /// @@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Configuration config, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Load(config, stream, out IImageFormat _); /// @@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new .> public static Image Load(Configuration config, Stream stream, out IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { config = config ?? Configuration.Default; (Image img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode(s, config)); diff --git a/src/ImageSharp/Image.LoadPixelData.cs b/src/ImageSharp/Image.LoadPixelData.cs index c655a87d0..f8f2e8485 100644 --- a/src/ImageSharp/Image.LoadPixelData.cs +++ b/src/ImageSharp/Image.LoadPixelData.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(TPixel[] data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(Configuration.Default, data, width, height); /// @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(Configuration.Default, data, width, height); /// @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(byte[] data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(Configuration.Default, data, width, height); /// @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(Configuration.Default, data, width, height); /// @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(Configuration config, byte[] data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(config, MemoryMarshal.Cast(new ReadOnlySpan(data)), width, height); /// @@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(Configuration config, ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(config, MemoryMarshal.Cast(data), width, height); /// @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(Configuration config, TPixel[] data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return LoadPixelData(config, new ReadOnlySpan(data), width, height); } @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . public static Image LoadPixelData(Configuration config, ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 9bb40a78b..e5181a0db 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp int width, int height, ImageMetadata metadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var memorySource = MemoryGroup.Wrap(pixelMemory); return new Image(config, memorySource, width, height, metadata); @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp Memory pixelMemory, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return WrapMemory(config, pixelMemory, width, height, new ImageMetadata()); } @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp Memory pixelMemory, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return WrapMemory(Configuration.Default, pixelMemory, width, height); } @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp int width, int height, ImageMetadata metadata) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var memorySource = MemoryGroup.Wrap(pixelMemoryOwner); return new Image(config, memorySource, width, height, metadata); @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp IMemoryOwner pixelMemoryOwner, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return WrapMemory(config, pixelMemoryOwner, width, height, new ImageMetadata()); } @@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp IMemoryOwner pixelMemoryOwner, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return WrapMemory(Configuration.Default, pixelMemoryOwner, width, height); } diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 574178d39..b1cefdf1d 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The public Image CloneAs() - where TPixel2 : struct, IPixel => this.CloneAs(this.GetConfiguration()); + where TPixel2 : unmanaged, IPixel => this.CloneAs(this.GetConfiguration()); /// /// Returns a copy of the image in the given pixel format. @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp /// The configuration providing initialization code which allows extending the library. /// The . public abstract Image CloneAs(Configuration configuration) - where TPixel2 : struct, IPixel; + where TPixel2 : unmanaged, IPixel; /// /// Update the size of the image after mutation. @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp } public void Visit(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.encoder.Encode(image, this.stream); } diff --git a/src/ImageSharp/ImageExtensions.Internal.cs b/src/ImageSharp/ImageExtensions.Internal.cs index 5b5e56665..a1fc51043 100644 --- a/src/ImageSharp/ImageExtensions.Internal.cs +++ b/src/ImageSharp/ImageExtensions.Internal.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp /// The /// internal static Buffer2D GetRootFramePixelBuffer(this Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return image.Frames.RootFrame.PixelBuffer; } diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 6cdc948d4..bb3128282 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp /// The format. /// The public static string ToBase64String(this Image source, IImageFormat format) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var stream = new MemoryStream()) { diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 837305d62..e6035a177 100644 --- a/src/ImageSharp/ImageFrame.LoadPixelData.cs +++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . internal static ImageFrame LoadPixelData(Configuration configuration, ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => LoadPixelData(configuration, MemoryMarshal.Cast(data), width, height); /// @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// A new . internal static ImageFrame LoadPixelData(Configuration configuration, ReadOnlySpan data, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs index cbd526662..93fa20587 100644 --- a/src/ImageSharp/ImageFrame.cs +++ b/src/ImageSharp/ImageFrame.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp protected abstract void Dispose(bool disposing); internal abstract void CopyPixelsTo(MemoryGroup destination) - where TDestinationPixel : struct, IPixel; + where TDestinationPixel : unmanaged, IPixel; /// /// Updates the size of the image frame. diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index b7f1d1bb6..89a1dfcc1 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp /// /// The type of the pixel. public sealed class ImageFrameCollection : ImageFrameCollection, IEnumerable> - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly IList> frames = new List>(); private readonly Image parent; diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index 85488c12d..321f2938c 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp /// /// The pixel format. public sealed class ImageFrame : ImageFrame, IPixelSource - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private bool isDisposed; @@ -258,7 +258,7 @@ namespace SixLabors.ImageSharp /// The pixel format. /// The internal ImageFrame CloneAs() - where TPixel2 : struct, IPixel => this.CloneAs(this.GetConfiguration()); + where TPixel2 : unmanaged, IPixel => this.CloneAs(this.GetConfiguration()); /// /// Returns a copy of the image frame in the given pixel format. @@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp /// The configuration providing initialization code which allows extending the library. /// The internal ImageFrame CloneAs(Configuration configuration) - where TPixel2 : struct, IPixel + where TPixel2 : unmanaged, IPixel { if (typeof(TPixel2) == typeof(TPixel)) { @@ -327,7 +327,7 @@ namespace SixLabors.ImageSharp /// A implementing the clone logic for . /// private readonly struct RowIntervalOperation : IRowIntervalOperation - where TPixel2 : struct, IPixel + where TPixel2 : unmanaged, IPixel { private readonly ImageFrame source; private readonly ImageFrame target; diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 83be52dd6..56f1f6b7b 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp /// /// The pixel format. public sealed class Image : Image - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private bool isDisposed; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index c2a731825..11d0bd01b 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif /// The . /// public Image CreateThumbnail() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.InitializeValues(); diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs index 61adedb0d..6d1c03e4b 100644 --- a/src/ImageSharp/PixelFormats/IPixel.cs +++ b/src/ImageSharp/PixelFormats/IPixel.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// The type implementing this interface public interface IPixel : IPixel, IEquatable - where TSelf : struct, IPixel + where TSelf : unmanaged, IPixel { /// /// Creates a instance for this pixel type. diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 4075b664c..f966de63c 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// to be opaque /// internal static class DefaultPixelBlenders - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index ccb98c495..a882de066 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// to be opaque /// internal static class DefaultPixelBlenders - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { <# diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index 4616ce36c..94127432b 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -278,7 +278,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -316,7 +316,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -335,7 +335,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -354,7 +354,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -373,7 +373,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -392,7 +392,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -608,7 +608,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -646,7 +646,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -665,7 +665,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -684,7 +684,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -703,7 +703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -722,7 +722,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -741,7 +741,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -760,7 +760,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -779,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -798,7 +798,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -817,7 +817,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1014,7 +1014,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1033,7 +1033,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1052,7 +1052,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1071,7 +1071,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1090,7 +1090,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1109,7 +1109,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1128,7 +1128,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1147,7 +1147,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1166,7 +1166,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1185,7 +1185,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1204,7 +1204,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1223,7 +1223,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1420,7 +1420,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1439,7 +1439,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1458,7 +1458,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1477,7 +1477,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1496,7 +1496,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1515,7 +1515,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1534,7 +1534,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1553,7 +1553,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1572,7 +1572,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1591,7 +1591,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1610,7 +1610,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1629,7 +1629,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1826,7 +1826,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1845,7 +1845,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1864,7 +1864,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1883,7 +1883,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1902,7 +1902,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1921,7 +1921,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1940,7 +1940,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1959,7 +1959,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1978,7 +1978,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -1997,7 +1997,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2016,7 +2016,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2035,7 +2035,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2232,7 +2232,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2251,7 +2251,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2270,7 +2270,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2289,7 +2289,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2308,7 +2308,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2327,7 +2327,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2346,7 +2346,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2365,7 +2365,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2384,7 +2384,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2403,7 +2403,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2422,7 +2422,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2441,7 +2441,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2638,7 +2638,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2657,7 +2657,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2676,7 +2676,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2695,7 +2695,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2714,7 +2714,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2733,7 +2733,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2752,7 +2752,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2771,7 +2771,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2790,7 +2790,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2809,7 +2809,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2828,7 +2828,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -2847,7 +2847,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3044,7 +3044,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3063,7 +3063,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3082,7 +3082,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3101,7 +3101,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3120,7 +3120,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3139,7 +3139,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3158,7 +3158,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3177,7 +3177,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3196,7 +3196,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3215,7 +3215,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3234,7 +3234,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3253,7 +3253,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3450,7 +3450,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrc(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3469,7 +3469,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3488,7 +3488,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3507,7 +3507,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3526,7 +3526,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3545,7 +3545,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3564,7 +3564,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3583,7 +3583,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3602,7 +3602,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3621,7 +3621,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3640,7 +3640,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightClear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; @@ -3659,7 +3659,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightXor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index bc4fa17c2..be2beb2f8 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel <#=blender#><#=composer#>(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { opacity = opacity.Clamp(0, 1); TPixel dest = default; diff --git a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs index c64fd3a2d..244aba7de 100644 --- a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// The type of the pixel public abstract class PixelBlender - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Blend 2 pixels together. @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats ReadOnlySpan background, ReadOnlySpan source, float amount) - where TPixelSrc : struct, IPixel + where TPixelSrc : unmanaged, IPixel { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) - where TPixelSrc : struct, IPixel + where TPixelSrc : unmanaged, IPixel { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs index 9f6fd2785..17af972a8 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// Provides access to pixel blenders /// public partial class PixelOperations - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Find an instance of the pixel blender. diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index 8ef894737..1e1047e2b 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// The pixel format. public partial class PixelOperations - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Gets the global instance for the pixel type @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats Configuration configuration, ReadOnlySpan sourcePixels, Span destinationPixels) - where TSourcePixel : struct, IPixel + where TSourcePixel : unmanaged, IPixel { const int SliceLength = 1024; int numberOfSlices = sourcePixels.Length / SliceLength; @@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.PixelFormats Configuration configuration, ReadOnlySpan sourcePixels, Span destinationPixels) - where TDestinationPixel : struct, IPixel + where TDestinationPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); diff --git a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs index e67bd9d53..ac50dd8c4 100644 --- a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs +++ b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils Span sourceVectors, Span destPixels, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels)); @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils ReadOnlySpan sourcePixels, Span destVectors, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors)); @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils Span sourceVectors, Span destPixels, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ApplyBackwardConversionModifiers(sourceVectors, modifiers); @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils ReadOnlySpan sourcePixels, Span destVectors, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (modifiers.IsDefined(PixelConversionModifiers.Scale)) { @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils private static void UnsafeFromVector4Core( ReadOnlySpan sourceVectors, Span destPixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors); ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels); @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils private static void UnsafeToVector4Core( ReadOnlySpan sourcePixels, Span destVectors) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Vector4 destRef = ref MemoryMarshal.GetReference(destVectors); @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils private static void UnsafeFromScaledVector4Core( ReadOnlySpan sourceVectors, Span destinationColors) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref Vector4 sourceRef = ref MemoryMarshal.GetReference(sourceVectors); ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors); @@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils private static void UnsafeToScaledVector4Core( ReadOnlySpan sourceColors, Span destinationVectors) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourceColors); ref Vector4 destRef = ref MemoryMarshal.GetReference(destinationVectors); diff --git a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs index 9c3a592d7..11a23b6eb 100644 --- a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs +++ b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.RgbaCompatible.cs @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils ReadOnlySpan sourcePixels, Span destVectors, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destVectors, nameof(destVectors)); @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils Span sourceVectors, Span destPixels, PixelConversionModifiers modifiers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourceVectors, destPixels, nameof(destPixels)); diff --git a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs index a4a3f9b3d..2e5919d1e 100644 --- a/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs +++ b/src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing /// /// The pixel format internal class DefaultImageProcessorContext : IInternalImageProcessingContext - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly bool mutate; private readonly Image source; diff --git a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs index 36966c296..59be5bf02 100644 --- a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing /// The image to mutate. /// The operation to perform on the source. public static void Mutate(this Image source, Action operation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Mutate(source, source.GetConfiguration(), operation); /// @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing /// The configuration which allows altering default behaviour or extending the library. /// The operation to perform on the source. public static void Mutate(this Image source, Configuration configuration, Action operation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(source, nameof(source)); @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Processing /// The image to mutate. /// The operations to perform on the source. public static void Mutate(this Image source, params IImageProcessor[] operations) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Mutate(source, source.GetConfiguration(), operations); /// @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing /// The configuration which allows altering default behaviour or extending the library. /// The operations to perform on the source. public static void Mutate(this Image source, Configuration configuration, params IImageProcessor[] operations) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); Guard.NotNull(operations, nameof(operations)); @@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing /// The operation to perform on the clone. /// The new public static Image Clone(this Image source, Action operation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Clone(source, source.GetConfiguration(), operation); /// @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Processing /// The operation to perform on the clone. /// The new public static Image Clone(this Image source, Configuration configuration, Action operation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(source, nameof(source)); @@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Processing /// The operations to perform on the clone. /// The new public static Image Clone(this Image source, params IImageProcessor[] operations) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => Clone(source, source.GetConfiguration(), operations); /// @@ -181,7 +181,7 @@ namespace SixLabors.ImageSharp.Processing /// The operations to perform on the clone. /// The new public static Image Clone(this Image source, Configuration configuration, params IImageProcessor[] operations) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(source, nameof(source)); @@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp.Processing public Image ResultImage { get; private set; } public void Visit(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IInternalImageProcessingContext operationsRunner = this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate); diff --git a/src/ImageSharp/Processing/IImageProcessingContextFactory.cs b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs index e3051ccdd..5394fac8b 100644 --- a/src/ImageSharp/Processing/IImageProcessingContextFactory.cs +++ b/src/ImageSharp/Processing/IImageProcessingContextFactory.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing /// A flag to determine whether image operations are allowed to mutate the source image. /// A new IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } /// @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Processing { /// public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return new DefaultImageProcessorContext(configuration, source, mutate); } diff --git a/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs b/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs index 9d023cca8..a39483b0d 100644 --- a/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs +++ b/src/ImageSharp/Processing/IInternalImageProcessingContext{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing /// /// The pixel type. internal interface IInternalImageProcessingContext : IImageProcessingContext - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Returns the result image to return by diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs index 7bfb02446..17fb39df3 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new BinaryThresholdProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index ed14a44e9..18b347144 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization /// /// The pixel format. internal class BinaryThresholdProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly BinaryThresholdProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs index 92c84a945..36cc7f697 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors { /// public abstract ICloningImageProcessor CreatePixelSpecificCloningProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; /// IImageProcessor IImageProcessor.CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index c539861f9..4cdb32428 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The pixel format. public abstract class CloningImageProcessor : ICloningImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs index 6bb02f1d1..65aa81c60 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new BokehBlurProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs index 36d36223a..17f60ebef 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// The pixel format. /// This processor is based on the code from Mike Pound, see github.com/mikepound/convolve. internal class BokehBlurProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// The gamma highlight factor to use when applying the effect diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs index 7ca4b6c6f..92f7ab02d 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new BoxBlurProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index 50004655f..fc80905ee 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class BoxBlurProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs index 1c4987c79..b4902fbd7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class Convolution2DProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs index 33a8ab7d1..30f2c6b4e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class Convolution2PassProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs index 542ee389b..b6f9bb319 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class ConvolutionProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index c8c57fc29..bdcf3cbc0 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class EdgeDetector2DProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs index c4da1e4b0..f93fe20b1 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class EdgeDetectorCompassProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs index eb7f07905..472547765 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor.cs @@ -26,6 +26,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// public abstract IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs index ce19ba82d..c49d03eb5 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class EdgeDetectorProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs index 9f511a754..d566f6691 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new GaussianBlurProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs index 3d0a7a714..cb77c8741 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class GaussianBlurProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs index b1f47863d..4854eae68 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new GaussianSharpenProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs index 506d34a3b..24c56363a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// The pixel format. internal class GaussianSharpenProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs index 079a22ecc..7b8e83585 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering Memory output, Rectangle bounds) where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span outputSpan = output.Span; ReadOnlySpan paletteSpan = palette.Span; @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering ImageFrame source, Rectangle bounds, float scale) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var pixelMap = new EuclideanPixelMap(palette); @@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering int x, int y, float scale) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Equal? Break out as there's no error to pass. if (source.Equals(transformed)) diff --git a/src/ImageSharp/Processing/Processors/Dithering/IDither.cs b/src/ImageSharp/Processing/Processors/Dithering/IDither.cs index fc8ee32f7..3d6edc9fa 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/IDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/IDither.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering Memory output, Rectangle bounds) where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; /// /// Transforms the image frame applying a dither matrix. @@ -48,6 +48,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering ImageFrame source, Rectangle bounds, float scale) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index 69e323bd5..7803f92b4 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering Memory output, Rectangle bounds) where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var ditherOperation = new QuantizeDitherRowIntervalOperation( ref quantizer, @@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering ImageFrame source, Rectangle bounds, float scale) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var ditherOperation = new PaletteDitherRowIntervalOperation( in Unsafe.AsRef(this), @@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering int y, int bitDepth, float scale) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Rgba32 rgba = default; source.ToRgba32(ref rgba); @@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering private readonly struct QuantizeDitherRowIntervalOperation : IRowIntervalOperation where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly TFrameQuantizer quantizer; private readonly OrderedDither dither; @@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering } private readonly struct PaletteDitherRowIntervalOperation : IRowIntervalOperation - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly OrderedDither dither; private readonly ImageFrame source; diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs index 6217535c5..5ce7ccec0 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor.cs @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new PaletteDitherProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 118352ec3..254847f45 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering /// /// The pixel format. internal sealed class PaletteDitherProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly int paletteLength; private readonly IDither dither; diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs index 032a0aab0..34a066049 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixelBg : struct, IPixel + where TPixelBg : unmanaged, IPixel { var visitor = new ProcessorFactoryVisitor(configuration, this, source, sourceRectangle); this.Image.AcceptVisitor(visitor); @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing } private class ProcessorFactoryVisitor : IImageVisitor - where TPixelBg : struct, IPixel + where TPixelBg : unmanaged, IPixel { private readonly Configuration configuration; private readonly DrawImageProcessor definition; @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing public IImageProcessor Result { get; private set; } public void Visit(Image image) - where TPixelFg : struct, IPixel + where TPixelFg : unmanaged, IPixel { this.Result = new DrawImageProcessor( this.configuration, diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index c1ce30cae..ae938aec1 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -15,8 +15,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The pixel format of destination image. /// The pixel format of source image. internal class DrawImageProcessor : ImageProcessor - where TPixelBg : struct, IPixel - where TPixelFg : struct, IPixel + where TPixelBg : unmanaged, IPixel + where TPixelFg : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs index a35e4d828..a816b0cb8 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new OilPaintingProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 50c0a22d3..270eb1343 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// Adapted from by Dewald Esterhuizen. /// The pixel format. internal class OilPaintingProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly OilPaintingProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs index 9563f8718..3721afee3 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( new PixelRowDelegate(this.PixelRowOperation), diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index 44ade727a..1907228c9 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// The pixel format. /// The row processor type. internal sealed class PixelRowDelegateProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel where TDelegate : struct, IPixelRowDelegate { private readonly TDelegate rowDelegate; diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs index a71f8424f..ba43ca617 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new PixelateProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs index 157ac7df1..60f5d29b0 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// /// The pixel format. internal class PixelateProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly PixelateProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs index 362b15810..6822daa42 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( new PixelRowDelegate(this.PixelRowOperation), diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs index 1542c6836..5cae98568 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters /// public virtual IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new FilterProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs index 19142ceb0..545c53915 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters /// /// The pixel format. internal class FilterProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly FilterProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs index 8e3759fba..5a19b7851 100644 --- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessor{TPixel}.cs +++ b/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. /// internal class LomographProcessor : FilterProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private static readonly Color VeryDarkGreen = Color.FromRgba(0, 10, 0, 255); diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs index 24ee16296..9f547be1c 100644 --- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters /// Converts the colors of the image recreating an old Polaroid effect. /// internal class PolaroidProcessor : FilterProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private static readonly Color LightOrange = Color.FromRgba(255, 153, 102, 128); private static readonly Color VeryDarkOrange = Color.FromRgb(102, 34, 0); diff --git a/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs index ad8051e6b..2f12e065b 100644 --- a/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ICloningImageProcessor.cs @@ -22,6 +22,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The ICloningImageProcessor CreatePixelSpecificCloningProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Processing/Processors/ICloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/ICloningImageProcessor{TPixel}.cs index 84b126229..988d6d866 100644 --- a/src/ImageSharp/Processing/Processors/ICloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/ICloningImageProcessor{TPixel}.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The pixel format. public interface ICloningImageProcessor : IImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Clones the specified and executes the process against the clone. diff --git a/src/ImageSharp/Processing/Processors/IImageProcessor.cs b/src/ImageSharp/Processing/Processors/IImageProcessor.cs index a9d5b20ec..9d2e301de 100644 --- a/src/ImageSharp/Processing/Processors/IImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/IImageProcessor.cs @@ -25,6 +25,6 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs index 1b874e4b9..4361936d1 100644 --- a/src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/IImageProcessor{TPixel}.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The pixel format. public interface IImageProcessor : IDisposable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Executes the process against the specified . diff --git a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs index 6f486e74b..7e72c7bf0 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Processors } public void Visit(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (IImageProcessor processorImpl = this.processor.CreatePixelSpecificProcessor(this.configuration, image, this.sourceRectangle)) { diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs index be8bc8e12..964a88d6a 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors /// /// The pixel format. public abstract class ImageProcessor : IImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index eb666a4f1..5fdedad6e 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// /// The pixel format. internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualizationProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index 4d0786947..cce527ad4 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// /// The pixel format. internal class AdaptiveHistogramEqualizationSlidingWindowProcessor : HistogramEqualizationProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 07fa55c5d..a99fb405e 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// /// The pixel format. internal class GlobalHistogramEqualizationProcessor : HistogramEqualizationProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor.cs index 8bd619095..031b121b9 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// public abstract IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; /// /// Creates the that implements the algorithm diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs index d7d72d4c8..ed0968f7c 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// /// The pixel format. internal abstract class HistogramEqualizationProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly float luminanceLevelsFloat; diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs index c9123bbbf..241ec1ebe 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new BackgroundColorProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs index b796016d1..a1e9d1c4e 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// /// The pixel format. internal class BackgroundColorProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly BackgroundColorProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 4f7ce7ba7..87e93ca21 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new GlowProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs index 21a4e1345..33c4123e9 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// /// The pixel format. internal class GlowProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly PixelBlender blender; private readonly GlowProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index 9915a5f52..5654eccfa 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new VignetteProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index 3515a2891..0618873f2 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays /// /// The pixel format. internal class VignetteProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly PixelBlender blender; private readonly VignetteProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index a5e8d70b0..929a66674 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. internal readonly struct EuclideanPixelMap : IPixelMap, IEquatable> - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly ConcurrentDictionary vectorCache; private readonly ConcurrentDictionary distanceCache; diff --git a/src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerExtensions.cs b/src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerExtensions.cs index 5b49fe9e8..a88d2b1e2 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerExtensions.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/FrameQuantizerExtensions.cs @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization ImageFrame source, Rectangle bounds) where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(source, nameof(source)); var interest = Rectangle.Intersect(source.Bounds(), bounds); @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization Memory output, ReadOnlyMemory palette) where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IDither dither = quantizer.Options.Dither; @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private readonly struct RowIntervalOperation : IRowIntervalOperation where TFrameQuantizer : struct, IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly TFrameQuantizer quantizer; private readonly ImageFrame source; diff --git a/src/ImageSharp/Processing/Processors/Quantization/IFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/IFrameQuantizer{TPixel}.cs index d3091c3b0..5aaae9fa6 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/IFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/IFrameQuantizer{TPixel}.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. public interface IFrameQuantizer : IDisposable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Gets the configuration. diff --git a/src/ImageSharp/Processing/Processors/Quantization/IPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/IPixelMap{TPixel}.cs index d25f2b07d..b421dce21 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/IPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/IPixelMap{TPixel}.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. internal interface IPixelMap - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Gets the color palette containing colors to match. diff --git a/src/ImageSharp/Processing/Processors/Quantization/IQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/IQuantizer.cs index 2daddf105..01e4b5e8a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/IQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/IQuantizer.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// The pixel format. /// The . IFrameQuantizer CreateFrameQuantizer(Configuration configuration) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; /// /// Creates the generic frame quantizer. @@ -32,6 +32,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// The options to create the quantizer with. /// The . IFrameQuantizer CreateFrameQuantizer(Configuration configuration, QuantizerOptions options) - where TPixel : struct, IPixel; + where TPixel : unmanaged, IPixel; } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs index 2b8ef3f0b..1b7c9edd6 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. public struct OctreeFrameQuantizer : IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly int colors; private readonly Octree octree; diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs index a5660c43b..3328fd6c7 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs @@ -35,12 +35,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => this.CreateFrameQuantizer(configuration, this.Options); /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration, QuantizerOptions options) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new OctreeFrameQuantizer(configuration, options); } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs index b8925b664..3200dfab8 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteFrameQuantizer{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. internal struct PaletteFrameQuantizer : IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly ReadOnlyMemory palette; private readonly EuclideanPixelMap pixelMap; diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index c1198c58f..07fa6e41e 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -44,12 +44,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => this.CreateFrameQuantizer(configuration, this.Options); /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration, QuantizerOptions options) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(options, nameof(options)); diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor.cs index 93211855d..bdaeb57f6 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new QuantizeProcessor(configuration, this.Quantizer, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs index bfcc26ae2..5a0116a03 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. internal class QuantizeProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly IQuantizer quantizer; diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizedFrame{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizedFrame{TPixel}.cs index fccc799bb..a7c67a868 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/QuantizedFrame{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizedFrame{TPixel}.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. public sealed class QuantizedFrame : IDisposable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private IMemoryOwner pixels; private bool isDisposed; diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs index 396f120aa..177f7e859 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// The pixel format. internal struct WuFrameQuantizer : IFrameQuantizer - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly MemoryAllocator memoryAllocator; diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs index b8c54f467..872e6d5bd 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs @@ -34,12 +34,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => this.CreateFrameQuantizer(configuration, this.Options); /// public IFrameQuantizer CreateFrameQuantizer(Configuration configuration, QuantizerOptions options) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new WuFrameQuantizer(configuration, options); } } diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs index 574d3cb18..0ecbacd75 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class AffineTransformProcessor : TransformProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly Size targetSize; private readonly Matrix3x2 transformMatrix; diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs index a059fb819..534832d13 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms { /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new AutoOrientProcessor(configuration, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor{TPixel}.cs index 90edcfac5..be1388dce 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class AutoOrientProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index e8eeea3cb..2dbd80650 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class CropProcessor : TransformProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly Rectangle cropRectangle; diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs index d5aaaf515..b2a50a988 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new EntropyCropProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs index 74d719fbe..8c91e1953 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class EntropyCropProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly EntropyCropProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index 60e22e2d0..b154aba88 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new FlipProcessor(configuration, this, source, sourceRectangle); } } diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs index 877fa074e..8db2d42c6 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class FlipProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly FlipProcessor definition; diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs index 175615ebd..56bf35635 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class ProjectiveTransformProcessor : TransformProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly Size targetSize; private readonly IResampler resampler; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index 92c1b71fe..5fcc8494b 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class ResizeProcessor : TransformProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private bool isDisposed; private readonly int targetWidth; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index de339823e..e773c2a0c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// For more details, and visual explanation, see "ResizeWorker.pptx". /// internal sealed class ResizeWorker : IDisposable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly Buffer2D transposedFirstPassBuffer; diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs index 198e142d0..6ce5c71f9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal class RotateProcessor : AffineTransformProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private readonly float degrees; diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformKernelMap.cs index a0d44cb7a..9627a378d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformKernelMap.cs @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ref float xSpanRef, Buffer2D sourcePixels, Span targetRow) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Clamp sampling pixel radial extents to the source image edges Vector2 minXY = transformedPoint - this.extents; diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor.cs index 3a0a7e54e..5423eea88 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// The pixel format. internal abstract class TransformProcessor : CloningImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorHelpers.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorHelpers.cs index 14eeca7cc..c1dce02be 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorHelpers.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessorHelpers.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// The pixel format. /// The image to update public static void UpdateDimensionalMetadata(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ExifProfile profile = image.Metadata.ExifProfile; if (profile is null) diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs index 8c35f072c..dc1d21c14 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/FromRgba32Bytes.cs @@ -12,7 +12,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk { public abstract class FromRgba32Bytes - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private IMemoryOwner destination; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs index 1a5c70e3c..f2af362e0 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/FromVector4.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk { [Config(typeof(Config.ShortClr))] public abstract class FromVector4 - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { protected IMemoryOwner source; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs index 5c02c6688..dfcc51646 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/Rgb24Bytes.cs @@ -10,7 +10,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk { public abstract class Rgb24Bytes - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private IMemoryOwner source; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs index 9ff118ebd..c21c0abf5 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToRgba32Bytes.cs @@ -12,7 +12,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk { public abstract class ToRgba32Bytes - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private IMemoryOwner source; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs index 1131366fc..b57136a92 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -13,7 +13,7 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk { public abstract class ToVector4 - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { protected IMemoryOwner source; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs index ef9d033d9..7acb3ecfe 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion [MethodImpl(MethodImplOptions.NoInlining)] private static void Default_GenericImpl(ReadOnlySpan source, Span dest) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index 4b09dd81e..d4e26179a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion [MethodImpl(MethodImplOptions.NoInlining)] private static void Default_GenericImpl(ReadOnlySpan source, Span dest) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion [MethodImpl(MethodImplOptions.NoInlining)] private static void Group4GenericImpl(ReadOnlySpan source, Span dest) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index 4241a12f6..8953228f9 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Benchmarks Span background, Span source, Span amount) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Benchmarks Span background, Span source, Span amount) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.MustBeGreaterThanOrEqualTo(destination.Length, background.Length, nameof(destination)); Guard.MustBeGreaterThanOrEqualTo(source.Length, background.Length, nameof(destination)); diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs index 2d299baa9..49a1bd541 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Benchmarks #pragma warning disable SA1649 // File name should match first type name public abstract class ResizeBenchmarkBase #pragma warning restore SA1649 // File name should match first type name - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { protected readonly Configuration Configuration = new Configuration(new JpegConfigurationModule()); diff --git a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs index f9a562b9d..dca124849 100644 --- a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [WithBasicTestPatternImages(131, 127, PixelTypes.Rgba32)] [WithBasicTestPatternImages(333, 555, PixelTypes.Bgr24)] public void OwnedMemory_PixelDataIsCorrect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [Theory] [WithBlankImages(16, 16, PixelTypes.Rgba32)] public void OwnedMemory_DestructiveMutate_ShouldInvalidateMemoryGroup(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [WithBasicTestPatternImages(1, 1, PixelTypes.Rgba32)] [WithBasicTestPatternImages(131, 127, PixelTypes.Bgr24)] public void ConsumedMemory_PixelDataIsCorrect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image image0 = provider.GetImage(); var targetBuffer = new TPixel[image0.Width * image0.Height]; @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced TestImageProvider provider, IMemoryGroup memoryGroup, Size size) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.True(memoryGroup.IsValid); Assert.Equal(size.Width * size.Height, memoryGroup.TotalLength); @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [WithBasicTestPatternImages(131, 127, PixelTypes.Rgba32)] [WithBasicTestPatternImages(333, 555, PixelTypes.Bgr24)] public void GetPixelRowMemory_PixelDataIsCorrect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); @@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [Theory] [WithBasicTestPatternImages(16, 16, PixelTypes.Rgba32)] public void GetPixelRowMemory_DestructiveMutate_ShouldInvalidateMemory(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); @@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced [WithBlankImages(100, 111, PixelTypes.Rgba32)] [WithBlankImages(400, 600, PixelTypes.Rgba32)] public void GetPixelRowSpan_ShouldReferenceSpanOfMemory(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 520691065..c3bc2f2ae 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Theory] [WithFile(TestImages.Png.Rainbow, nameof(BlendingModes), PixelTypes.Rgba32)] public void ImageBlendingMatchesSvgSpecExamples(TestImageProvider provider, PixelColorBlendingMode mode) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image background = provider.GetImage()) using (var source = Image.Load(TestFile.Create(TestImages.Png.Ducky).Bytes)) @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing string brushImage, PixelColorBlendingMode mode, float opacity) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) using (var blend = Image.Load(TestFile.Create(brushImage).Bytes)) @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Theory] [WithTestPatternImages(200, 200, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void DrawImageOfDifferentPixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { byte[] brushData = TestFile.Create(TestImages.Png.Ducky).Bytes; @@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Theory] [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] public void DrawTransformed(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) using (var blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes)) diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index 4705fa3f2..a8376f51b 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFileCollection(nameof(MiscBmpFiles), PixelTypes.Rgba32, false)] [WithFileCollection(nameof(MiscBmpFiles), PixelTypes.Rgba32, true)] public void BmpDecoder_CanDecode_MiscellaneousBitmaps(TestImageProvider provider, bool enforceDiscontiguousBuffers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Bit32Rgb, PixelTypes.Rgba32)] [WithFile(Bit16, PixelTypes.Rgba32)] public void BmpDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); ImageFormatException ex = Assert.Throws(() => provider.GetImage(BmpDecoder)); @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFileCollection(nameof(BitfieldsBmpFiles), PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBitfields(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Bit16Inverted, PixelTypes.Rgba32)] [WithFile(Bit8Inverted, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_Inverted(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Bit1, PixelTypes.Rgba32)] [WithFile(Bit1Pal1, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_1Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_4Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit8, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_8Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit16, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -163,7 +163,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit32Rgb, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_32Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Rgba32v4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_32BitV4Header_Fast(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(RLE4Delta, PixelTypes.Rgba32)] [WithFile(Rle4Delta320240, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { @@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(RLE4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { @@ -226,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Rle8Delta320240, PixelTypes.Rgba32)] [WithFile(Rle8Blank160120, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { @@ -242,7 +242,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(RLE8Cut, PixelTypes.Rgba32)] [WithFile(RLE8Delta, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) { @@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(RLE8, PixelTypes.Rgba32, true)] [WithFile(RLE8Inverted, PixelTypes.Rgba32, true)] public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit(TestImageProvider provider, bool enforceDiscontiguousBuffers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (enforceDiscontiguousBuffers) { @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(RLE24Cut, PixelTypes.Rgba32, true)] [WithFile(RLE24Delta, PixelTypes.Rgba32, true)] public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit(TestImageProvider provider, bool enforceNonContiguous) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (enforceNonContiguous) { @@ -298,7 +298,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(RgbaAlphaBitfields, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeAlphaBitfields(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -312,7 +312,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit32Rgba, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBitmap_WithAlphaChannel(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -324,7 +324,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Rgba321010102, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBitfields_WithUnusualBitmasks(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -343,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(WinBmpv2, PixelTypes.Rgba32)] [WithFile(CoreHeader, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBmpv2(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(WinBmpv3, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBmpv3(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -367,7 +367,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(LessThanFullSizedPalette, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeLessThanFullPalette(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -380,7 +380,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(OversizedPalette, PixelTypes.Rgba32)] [WithFile(Rgb24LargePalette, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeOversizedPalette(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -395,7 +395,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(InvalidPaletteSize, PixelTypes.Rgba32)] public void BmpDecoder_ThrowsImageFormatException_OnInvalidPaletteSize(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.Throws(() => { @@ -409,7 +409,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Rgb24jpeg, PixelTypes.Rgba32)] [WithFile(Rgb24png, PixelTypes.Rgba32)] public void BmpDecoder_ThrowsNotSupportedException_OnUnsupportedBitmaps(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.Throws(() => { @@ -422,7 +422,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Rgb32h52AdobeV3, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeAdobeBmpv3(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -434,7 +434,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Rgba32bf56AdobeV3, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeAdobeBmpv3_WithAlpha(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -446,7 +446,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(WinBmpv4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBmpv4(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -459,7 +459,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(WinBmpv5, PixelTypes.Rgba32)] [WithFile(V5Header, PixelTypes.Rgba32)] public void BmpDecoder_CanDecodeBmpv5(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -471,7 +471,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Pal8Offset, PixelTypes.Rgba32)] public void BmpDecoder_RespectsFileHeaderOffset(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -483,7 +483,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(F, CommonNonDefaultPixelTypes)] public void BmpDecoder_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -495,7 +495,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit8Palette4, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode4BytePerEntryPalette(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -570,7 +570,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Os2v2Short, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_Os2v2XShortHeader(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -584,7 +584,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Os2v2, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_Os2v2Header(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { @@ -608,7 +608,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(Os2BitmapArrayWarpd, PixelTypes.Rgba32)] [WithFile(Os2BitmapArrayPines, PixelTypes.Rgba32)] public void BmpDecoder_CanDecode_Os2BitmapArray(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(BmpDecoder)) { diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 85d5ca1b8..235ecabf2 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithTestPatternImages(nameof(BitsPerPixel), 24, 24, PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24)] public void Encode_IsNotBoundToSinglePixelType(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel); [Theory] [WithTestPatternImages(nameof(BitsPerPixel), 48, 24, PixelTypes.Rgba32)] @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithSolidFilledImages(nameof(BitsPerPixel), 1, 1, 255, 100, 50, 255, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(BitsPerPixel), 7, 5, PixelTypes.Rgba32)] public void Encode_WorksWithDifferentSizes(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel); [Theory] [WithFile(Bit32Rgb, PixelTypes.Rgba32 | PixelTypes.Rgb24, BmpBitsPerPixel.Pixel32)] @@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void Encode_32Bit_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) // If supportTransparency is false, a v3 bitmap header will be written. - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); [Theory] [WithFile(Bit32Rgb, PixelTypes.Rgba32 | PixelTypes.Rgb24, BmpBitsPerPixel.Pixel32)] @@ -126,48 +126,48 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(WinBmpv4, PixelTypes.Rgba32 | PixelTypes.Rgb24, BmpBitsPerPixel.Pixel32)] [WithFile(WinBmpv5, PixelTypes.Rgba32 | PixelTypes.Rgb24, BmpBitsPerPixel.Pixel32)] public void Encode_32Bit_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] [WithFile(WinBmpv3, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel24)] // WinBmpv3 is a 24 bits per pixel image. [WithFile(F, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel24)] public void Encode_24Bit_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); [Theory] [WithFile(WinBmpv3, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel24)] [WithFile(F, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel24)] public void Encode_24Bit_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] [WithFile(Rgb16, PixelTypes.Bgra5551, BmpBitsPerPixel.Pixel16)] [WithFile(Bit16, PixelTypes.Bgra5551, BmpBitsPerPixel.Pixel16)] public void Encode_16Bit_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); [Theory] [WithFile(Rgb16, PixelTypes.Bgra5551, BmpBitsPerPixel.Pixel16)] [WithFile(Bit16, PixelTypes.Bgra5551, BmpBitsPerPixel.Pixel16)] public void Encode_16Bit_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] [WithFile(WinBmpv5, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel8)] [WithFile(Bit8Palette4, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel8)] public void Encode_8Bit_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: false); [Theory] [WithFile(WinBmpv5, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel8)] [WithFile(Bit8Palette4, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel8)] public void Encode_8Bit_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] [WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)] public void Encode_8BitGray_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => TestBmpEncoderCore( provider, bitsPerPixel, @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)] public void Encode_8BitGray_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => TestBmpEncoderCore( provider, bitsPerPixel, @@ -185,7 +185,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit32Rgb, PixelTypes.Rgba32)] public void Encode_8BitColor_WithWuQuantizer(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.Is64BitProcess) { @@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Theory] [WithFile(Bit32Rgb, PixelTypes.Rgba32)] public void Encode_8BitColor_WithOctreeQuantizer(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.Is64BitProcess) { @@ -238,13 +238,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [WithFile(TestImages.Png.GrayAlpha2BitInterlaced, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel32)] [WithFile(Bit32Rgba, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel32)] public void Encode_PreservesAlpha(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); + where TPixel : unmanaged, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] [WithFile(Car, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel32)] [WithFile(V5Header, PixelTypes.Rgba32, BmpBitsPerPixel.Pixel32)] public void Encode_WorksWithDiscontiguousBuffers(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InBytesSqrt(100); TestBmpEncoderCore(provider, bitsPerPixel); @@ -255,7 +255,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp BmpBitsPerPixel bitsPerPixel, bool supportTransparency = true, ImageComparer customComparer = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index ff91c0e82..e6b6e43c1 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] public void ResolutionShouldChange(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Png.CalliphoraPartial, nameof(QuantizerNames), PixelTypes.Rgba32)] [WithFile(TestImages.Png.Bike, nameof(QuantizerNames), PixelTypes.Rgba32)] public void QuantizeImageShouldPreserveMaximumColorPrecision(TestImageProvider provider, string quantizerName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Configuration.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 45c768892..fa2899372 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFileCollection(nameof(MultiFrameTestFiles), PixelTypes.Rgba32)] public void Decode_VerifyAllFrames(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFile(TestImages.Gif.Trans, TestPixelTypes)] public void GifDecoder_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFileCollection(nameof(BasicVerificationFiles), PixelTypes.Rgba32)] public void Decode_VerifyRootFrameAndFrameCount(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!BasicVerificationFrameCount.TryGetValue(provider.SourceFileOrDescription, out int expectedFrameCount)) { @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void CanDecodeJustOneFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new GifDecoder { DecodingMode = FrameDecodingMode.First })) { @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void CanDecodeAllFrames(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new GifDecoder { DecodingMode = FrameDecodingMode.All })) { @@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)] public void GifDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); ImageFormatException ex = Assert.Throws(() => provider.GetImage(GifDecoder)); @@ -184,7 +184,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)] public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 1519bc801..588f65254 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [WithTestPatternImages(100, 100, TestPixelTypes, false)] [WithTestPatternImages(100, 100, TestPixelTypes, false)] public void EncodeGeneratedPatterns(TestImageProvider provider, bool limitAllocationBuffer) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (limitAllocationBuffer) { @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Theory] [WithFile(TestImages.Gif.Cheers, PixelTypes.Rgba32)] public void EncodeGlobalPaletteReturnsSmallerFile(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs index 38b33e842..978ee7b2a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public class GenericBlock8x8Tests { public static Image CreateTestImage() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var image = new Image(10, 10); Buffer2D pixels = image.GetRootFramePixelBuffer(); @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgb24 | PixelTypes.Rgba32 /* | PixelTypes.Rgba32 | PixelTypes.Argb32*/)] public void LoadAndStretchCorners_FromOrigo(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image s = provider.GetImage()) { @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgb24 | PixelTypes.Rgba32)] public void LoadAndStretchCorners_WithOffset(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image s = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs index 6ea61892c..cf2e5c81b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithFile(TestImages.Jpeg.Baseline.Calliphora, PixelTypes.Rgba32, true)] [WithFile(TestImages.Jpeg.Baseline.Turtle420, PixelTypes.Rgba32, true)] public void DecodeBaselineJpeg(TestImageProvider provider, bool enforceDiscontiguousBuffers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { @@ -53,6 +53,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithFileCollection(nameof(UnrecoverableTestJpegs), PixelTypes.Rgba32)] public void UnrecoverableImage_Throws_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel => Assert.Throws(provider.GetImage); + where TPixel : unmanaged, IPixel => Assert.Throws(provider.GetImage); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs index b8a791278..4ecf987e9 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32, false)] [WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32, true)] public void DecodeProgressiveJpeg(TestImageProvider provider, bool enforceDiscontiguousBuffers) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 32060df9a..103c9d077 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } private static ImageComparer GetImageComparer(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string file = provider.SourceFileOrDescription; @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithFile(TestImages.Jpeg.Baseline.Calliphora, CommonNonDefaultPixelTypes)] public void JpegDecoder_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(JpegDecoder); image.DebugSave(provider); @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithFile(TestImages.Jpeg.Baseline.Floorplan, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.Progressive.Festzug, PixelTypes.Rgba32)] public void DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InBytesSqrt(10); ImageFormatException ex = Assert.Throws(() => provider.GetImage(JpegDecoder)); @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void ValidateProgressivePdfJsOutput( TestImageProvider provider, string pdfJsOriginalResultImage) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // tests\ImageSharp.Tests\Formats\Jpg\pdfjs\jpeg-converter.htm string pdfJsOriginalResultPath = Path.Combine( diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index b62a555b8..bb79abf54 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -74,12 +74,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithTestPatternImages(nameof(BitsPerPixel_Quality), 7, 5, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(BitsPerPixel_Quality), 600, 400, PixelTypes.Rgba32)] public void EncodeBaseline_WorksWithDifferentSizes(TestImageProvider provider, JpegSubsample subsample, int quality) - where TPixel : struct, IPixel => TestJpegEncoderCore(provider, subsample, quality); + where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, subsample, quality); [Theory] [WithTestPatternImages(nameof(BitsPerPixel_Quality), 48, 48, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void EncodeBaseline_IsNotBoundToSinglePixelType(TestImageProvider provider, JpegSubsample subsample, int quality) - where TPixel : struct, IPixel => TestJpegEncoderCore(provider, subsample, quality); + where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, subsample, quality); [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32, JpegSubsample.Ratio444)] @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithTestPatternImages(677, 683, PixelTypes.Bgra32, JpegSubsample.Ratio420)] [WithSolidFilledImages(400, 400, "Red", PixelTypes.Bgr24, JpegSubsample.Ratio420)] public void EncodeBaseline_WorksWithDiscontiguousBuffers(TestImageProvider provider, JpegSubsample subsample) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ImageComparer comparer = subsample == JpegSubsample.Ratio444 ? ImageComparer.TolerantPercentage(0.1f) @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg JpegSubsample subsample, int quality = 100, ImageComparer comparer = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs index 86128e002..32481e1f5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg private ITestOutputHelper Output { get; } private static void SaveBuffer(JpegComponentPostProcessor cp, TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = cp.ColorBuffer.ToGrayscaleImage(1f / 255f)) { @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithFile(TestImages.Jpeg.Baseline.Calliphora, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.Baseline.Testorig420, PixelTypes.Rgba32)] public void DoProcessorStep(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string imageFile = provider.SourceFileOrDescription; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] public void PostProcess(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string imageFile = provider.SourceFileOrDescription; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs index 9ccfed97d..a6f80f558 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [WithFile(TestImages.Jpeg.Baseline.Calliphora, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)] public void ExtractSpectralData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.IsWindows) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index c69740ede..3e125adac 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory(Skip = "Debug only, enable manually!")] [WithFileCollection(nameof(AllTestJpegs), PixelTypes.Rgba32)] public void Decoder_ParseStream_SaveSpectralResult(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var decoder = new JpegDecoderCore(Configuration.Default, new JpegDecoder()); @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithFileCollection(nameof(AllTestJpegs), PixelTypes.Rgba32)] public void VerifySpectralCorrectness(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.IsWindows) { @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg private void VerifySpectralCorrectnessImpl( TestImageProvider provider, LibJpegTools.SpectralData imageSharpData) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { LibJpegTools.SpectralData libJpegData = LibJpegTools.ExtractSpectralData(provider.SourceFileOrDescription); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index 9f22a7cb8..13685c8e8 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils TestImageProvider provider, LibJpegTools.SpectralData data, ITestOutputHelper output = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (LibJpegTools.ComponentData comp in data.Components) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index bf767e811..030992771 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] public void Decode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.Interlaced, PixelTypes.Rgba32)] public void Decode_Interlaced_ImageIsCorrect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImages48Bpp), PixelTypes.Rgb48)] public void Decode_48Bpp(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImages64Bpp), PixelTypes.Rgba64)] public void Decode_64Bpp(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImagesL8BitInterlaced), PixelTypes.Rgba32)] public void Decoder_L8bitInterlaced(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImagesL16Bit), PixelTypes.Rgb48)] public void Decode_L16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImagesGrayAlpha16Bit), PixelTypes.Rgba64)] public void Decode_GrayAlpha16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -188,7 +188,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.GrayA8BitInterlaced, PixelTypes)] public void Decoder_CanDecodeGrey8bitWithAlpha(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -200,7 +200,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.Splash, PixelTypes)] public void Decoder_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(PngDecoder)) { @@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFileCollection(nameof(TestImagesIssue1014), PixelTypes.Rgba32)] public void Issue1014(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { System.Exception ex = Record.Exception( () => @@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)] public void PngDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); ImageFormatException ex = Assert.Throws(() => provider.GetImage(PngDecoder)); @@ -258,7 +258,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)] public void PngDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 390613256..5a31d2d93 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithSolidFilledImages(nameof(PngColorTypes), 1, 1, 255, 100, 50, 255, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(PngColorTypes), 7, 5, PixelTypes.Rgba32)] public void WorksWithDifferentSizes(TestImageProvider provider, PngColorType pngColorType) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TestPngEncoderCore( provider, @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(nameof(PngColorTypes), 24, 24, PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24)] public void IsNotBoundToSinglePixelType(TestImageProvider provider, PngColorType pngColorType) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (PngInterlaceMode interlaceMode in InterlaceMode) { @@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(nameof(PngFilterMethods), 24, 24, PixelTypes.Rgba32)] public void WorksWithAllFilterMethods(TestImageProvider provider, PngFilterMethod pngFilterMethod) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (PngInterlaceMode interlaceMode in InterlaceMode) { @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(nameof(CompressionLevels), 24, 24, PixelTypes.Rgba32)] public void WorksWithAllCompressionLevels(TestImageProvider provider, int compressionLevel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (PngInterlaceMode interlaceMode in InterlaceMode) { @@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithTestPatternImages(24, 24, PixelTypes.Rgba32, PngColorType.GrayscaleWithAlpha, PngBitDepth.Bit8)] [WithTestPatternImages(24, 24, PixelTypes.Rgba64, PngColorType.GrayscaleWithAlpha, PngBitDepth.Bit16)] public void WorksWithAllBitDepths(TestImageProvider provider, PngColorType pngColorType, PngBitDepth pngBitDepth) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO: Investigate WuQuantizer to see if we can reduce memory pressure. if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) @@ -230,7 +230,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithBlankImages(1, 1, PixelTypes.La16, PngColorType.GrayscaleWithAlpha, PngBitDepth.Bit8)] [WithBlankImages(1, 1, PixelTypes.La32, PngColorType.GrayscaleWithAlpha, PngBitDepth.Bit16)] public void InfersColorTypeAndBitDepth(TestImageProvider provider, PngColorType pngColorType, PngBitDepth pngBitDepth) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Stream stream = new MemoryStream()) { @@ -252,7 +252,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.Palette8Bpp, nameof(PaletteLargeOnly), PixelTypes.Rgba32)] public void PaletteColorType_WuQuantizer(TestImageProvider provider, int paletteSize) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO: Investigate WuQuantizer to see if we can reduce memory pressure. if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) @@ -276,7 +276,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32)] public void WritesFileMarker(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) using (var ms = new MemoryStream()) @@ -408,7 +408,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [WithTestPatternImages(587, 821, PixelTypes.Rgba32)] [WithTestPatternImages(677, 683, PixelTypes.Rgba32)] public void Encode_WorksWithDiscontiguousBuffers(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); foreach (PngInterlaceMode interlaceMode in InterlaceMode) @@ -438,7 +438,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png bool appendCompressionLevel = false, bool appendPaletteSize = false, bool appendPngBitDepth = false) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index fe2549724..5f5d5fd3d 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Decoder_CanReadTextData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new PngDecoder())) { @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Encoder_PreservesTextData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var decoder = new PngDecoder(); using (Image input = provider.GetImage(decoder)) @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.InvalidTextData, PixelTypes.Rgba32)] public void Decoder_IgnoresInvalidTextData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(new PngDecoder())) { @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Encode_UseCompression_WhenTextIsGreaterThenThreshold_Works(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var decoder = new PngDecoder(); using (Image input = provider.GetImage(decoder)) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index 0233e0a09..a50b1059f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(300, 300, PixelTypes.Rgba32)] public void GeneralTest(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // does saving a file then reopening mean both files are identical??? using (Image image = provider.GetImage()) @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] public void CanSaveIndexedPng(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // does saving a file then reopening mean both files are identical??? using (Image image = provider.GetImage()) @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(100, 100, PixelTypes.Color)] public void CanSaveIndexedPngTwice(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // does saving a file then reopening mean both files are identical??? using (Image source = provider.GetImage()) @@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Theory] [WithTestPatternImages(300, 300, PixelTypes.Rgba32)] public void Resize(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // does saving a file then reopening mean both files are identical??? using (Image image = provider.GetImage()) diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index 985ccb596..bcd98d714 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Grey, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Uncompressed_MonoChrome(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit15, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Uncompressed_15Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit15Rle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_15Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit16, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Uncompressed_16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit16PalRle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_WithPalette_16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit24, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Uncompressed_24Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit24RleTopLeft, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_WithTopLeftOrigin_24Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit24TopLeft, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Palette_WithTopLeftOrigin_24Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_Uncompressed_32Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(GreyRle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_MonoChrome(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit16Rle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit24Rle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_24Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit32Rle, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_RunLengthEncoded_32Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -177,7 +177,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit16Pal, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithPalette_16Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [Theory] [WithFile(Bit24Pal, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithPalette_24Bit(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage(TgaDecoder)) { @@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [WithFile(Bit24, PixelTypes.Rgba32)] [WithFile(Bit32, PixelTypes.Rgba32)] public void TgaDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); ImageFormatException ex = Assert.Throws(() => provider.GetImage(TgaDecoder)); @@ -214,7 +214,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga [WithFile(Bit24, PixelTypes.Rgba32)] [WithFile(Bit32, PixelTypes.Rgba32)] public void TgaDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string nonContiguousBuffersStr) { diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs index 339945f8b..f123370d1 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs @@ -83,50 +83,50 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga public void Encode_Bit8_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel8) // Using tolerant comparer here. The results from magick differ slightly. Maybe a different ToGrey method is used. The image looks otherwise ok. - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None, useExactComparer: false, compareTolerance: 0.03f); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None, useExactComparer: false, compareTolerance: 0.03f); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit16_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel16) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None, useExactComparer: false); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None, useExactComparer: false); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit24_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel24) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit32_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel32) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.None); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit8_WithRunLengthEncoding_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel8) // Using tolerant comparer here. The results from magick differ slightly. Maybe a different ToGrey method is used. The image looks otherwise ok. - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength, useExactComparer: false, compareTolerance: 0.03f); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength, useExactComparer: false, compareTolerance: 0.03f); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit16_WithRunLengthEncoding_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel16) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength, useExactComparer: false); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength, useExactComparer: false); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit24_WithRunLengthEncoding_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel24) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength); [Theory] [WithFile(Bit32, PixelTypes.Rgba32)] public void Encode_Bit32_WithRunLengthEncoding_Works(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel = TgaBitsPerPixel.Pixel32) - where TPixel : struct, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength); + where TPixel : unmanaged, IPixel => TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength); [Theory] [WithFile(Bit32, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel32)] [WithFile(Bit24, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel24)] public void Encode_WorksWithDiscontiguousBuffers(TestImageProvider provider, TgaBitsPerPixel bitsPerPixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100); TestTgaEncoderCore(provider, bitsPerPixel, TgaCompression.RunLength); @@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga TgaCompression compression = TgaCompression.None, bool useExactComparer = true, float compareTolerance = 0.01f) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs index 090aecb79..cb3986b1f 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga Image image, bool useExactComparer = true, float compareTolerance = 0.01f) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestImageProvider.GetFilePathOrNull(provider); if (path == null) @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } public static Image DecodeWithMagick(Configuration configuration, FileInfo fileInfo) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var magickImage = new MagickImage(fileInfo)) { diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs index 980898ffa..0b2274581 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(10, 10, PixelTypes.Rgba32)] public void CloneFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { @@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(10, 10, PixelTypes.Rgba32)] public void ExtractFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index 08f0de38c..b0008d394 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -146,7 +146,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(10, 10, PixelTypes.Rgba32 | PixelTypes.Bgr24)] public void CloneFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { @@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(10, 10, PixelTypes.Rgba32)] public void ExtractFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { @@ -268,7 +268,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void ConstructGif_FromDifferentPixelTypes(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image source = provider.GetImage()) using (var dest = new Image(source.GetConfiguration(), source.Width, source.Height)) @@ -294,7 +294,7 @@ namespace SixLabors.ImageSharp.Tests } private static void ImportFrameAs(ImageFrameCollection source, ImageFrameCollection destination, int index) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image temp = source.CloneFrame(index)) { diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs index 4c23e4955..e2d370cc0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats [Theory] [MemberData(nameof(BlenderMappings))] public void ReturnsCorrectBlender(TestPixel pixel, Type type, PixelColorBlendingMode mode) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { PixelBlender blender = PixelOperations.Instance.GetPixelBlender(mode, PixelAlphaCompositionMode.SrcOver); Assert.IsType(type, blender); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index 395aba5ac..f41fbc022 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(NormalBlendFunctionData))] public void NormalBlendFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.NormalSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(NormalBlendFunctionData))] public void NormalBlendFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.NormalSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(NormalBlendFunctionData))] public void NormalBlendFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.NormalSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(MultiplyFunctionData))] public void MultiplyFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.MultiplySrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(MultiplyFunctionData))] public void MultiplyFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.MultiplySrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(MultiplyFunctionData))] public void MultiplyFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.MultiplySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(AddFunctionData))] public void AddFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.AddSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(AddFunctionData))] public void AddFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.AddSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(AddFunctionData))] public void AddFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.AddSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(SubtractFunctionData))] public void SubtractFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.SubtractSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(SubtractFunctionData))] public void SubtractFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.SubtractSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(SubtractFunctionData))] public void SubtractFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.SubtractSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(ScreenFunctionData))] public void ScreenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.ScreenSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -207,7 +207,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(ScreenFunctionData))] public void ScreenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.ScreenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(ScreenFunctionData))] public void ScreenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.ScreenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(DarkenFunctionData))] public void DarkenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.DarkenSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(DarkenFunctionData))] public void DarkenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.DarkenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(DarkenFunctionData))] public void DarkenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.DarkenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -278,7 +278,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(LightenFunctionData))] public void LightenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.LightenSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -287,7 +287,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(LightenFunctionData))] public void LightenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.LightenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -296,7 +296,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(LightenFunctionData))] public void LightenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.LightenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -318,7 +318,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(OverlayFunctionData))] public void OverlayFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.OverlaySrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -327,7 +327,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(OverlayFunctionData))] public void OverlayFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.OverlaySrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -336,7 +336,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(OverlayFunctionData))] public void OverlayFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.OverlaySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); @@ -358,7 +358,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(HardLightFunctionData))] public void HardLightFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = PorterDuffFunctions.HardLightSrcOver(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -367,7 +367,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(HardLightFunctionData))] public void HardLightFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel actual = new DefaultPixelBlenders.HardLightSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); VectorAssert.Equal(expected.AsPixel(), actual, 2); @@ -376,7 +376,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [Theory] [MemberData(nameof(HardLightFunctionData))] public void HardLightFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var dest = new Span(new TPixel[1]); new DefaultPixelBlenders.HardLightSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs index 9293333b8..2ff5157b7 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs @@ -47,8 +47,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Configuration configuration, ReadOnlySpan sourcePixels, Span destinationPixels) - where TSourcePixel : struct, IPixel - where TDestinationPixel : struct, IPixel + where TSourcePixel : unmanaged, IPixel + where TDestinationPixel : unmanaged, IPixel { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 40b812279..b2b39b590 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -22,12 +22,12 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations [Theory] [WithBlankImages(1, 1, PixelTypes.All)] public void GetGlobalInstance(TestImageProvider _) - where T : struct, IPixel => Assert.NotNull(PixelOperations.Instance); + where T : unmanaged, IPixel => Assert.NotNull(PixelOperations.Instance); } #pragma warning restore SA1313 // Parameter names should begin with lower-case letter public abstract class PixelOperationsTests : MeasureFixture - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { public const string SkipProfilingBenchmarks = #if true @@ -288,7 +288,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations [Theory] [MemberData(nameof(Generic_To_Data))] public void Generic_To(TestPixel dummy) - where TDestPixel : struct, IPixel + where TDestPixel : unmanaged, IPixel { const int Count = 2134; TPixel[] source = CreatePixelTestData(Count); diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 7ae14d61a..3f11b4631 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -14,27 +14,27 @@ namespace SixLabors.ImageSharp.Tests.Processing private readonly List imageOperators = new List(); public bool HasCreated(Image source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return this.Created(source).Any(); } public IEnumerable> Created(Image source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return this.imageOperators.OfType>() .Where(x => x.Source == source); } public IEnumerable.AppliedOperation> AppliedOperations(Image source) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return this.Created(source) .SelectMany(x => x.Applied); } public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var op = new FakeImageOperations(configuration, source, mutate); this.imageOperators.Add(op); @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing } public class FakeImageOperations : IInternalImageProcessingContext - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { public FakeImageOperations(Configuration configuration, Image source, bool mutate) { diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index b07545a36..5e2b7062e 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization [Theory] [WithFile(TestImages.Jpeg.Baseline.LowContrast, PixelTypes.Rgba32)] public void Adaptive_SlidingWindow_15Tiles_WithClipping(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization [Theory] [WithFile(TestImages.Jpeg.Baseline.LowContrast, PixelTypes.Rgba32)] public void Adaptive_TileInterpolation_10Tiles_WithClipping(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization [WithTestPatternImages(110, 110, PixelTypes.Rgb24)] [WithTestPatternImages(170, 170, PixelTypes.Rgb24)] public void Issue984(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 9cb7e0409..e718df4a2 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), PixelTypes.Rgba32)] [WithTestPatternImages(nameof(OrderedDitherers), 100, 100, PixelTypes.Rgba32)] public void BinaryDitherFilter_WorksWithAllDitherers(TestImageProvider provider, string name, IDither ditherer) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [WithFileCollection(nameof(CommonTestImages), nameof(ErrorDiffusers), PixelTypes.Rgba32)] [WithTestPatternImages(nameof(ErrorDiffusers), 100, 100, PixelTypes.Rgba32)] public void DiffusionFilter_WorksWithAllErrorDiffusers(TestImageProvider provider, string name, IDither diffuser) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.Bike, TestPixelTypes)] public void BinaryDitherFilter_ShouldNotDependOnSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.Bike, TestPixelTypes)] public void DiffusionFilter_ShouldNotDependOnSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void ApplyDitherFilterInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image source = provider.GetImage()) using (Image image = source.Clone()) @@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void ApplyDiffusionFilterInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image source = provider.GetImage()) using (Image image = source.Clone()) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index 54ff77f93..3801a4888 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(BinaryThresholdValues), PixelTypes.Rgba32)] public void ImageShouldApplyBinaryThresholdFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(BinaryThresholdValues), PixelTypes.Rgba32)] public void ImageShouldApplyBinaryThresholdInBox(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image source = provider.GetImage()) using (var image = source.Clone()) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs index cae48c33b..bd574c916 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] public void OnFullImage(TestImageProvider provider, int value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunValidatingProcessorTest( @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] public void InBox(TestImageProvider provider, int value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunRectangleConstrainedValidatingProcessorTest( diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index 2d5971124..ebbecab93 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [WithTestPatternImages(nameof(BokehBlurValues), 23, 31, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(BokehBlurValues), 30, 20, PixelTypes.Rgba32)] public void BokehBlurFilterProcessor(TestImageProvider provider, BokehBlurInfo value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string infoDump) { @@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution */ [WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32)] public void BokehBlurFilterProcessor_WorksWithAllPixelTypes(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump) { @@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32)] public void BokehBlurFilterProcessor_Bounded(TestImageProvider provider, BokehBlurInfo value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { static void RunTest(string providerDump, string infoDump) { @@ -200,7 +200,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithTestPatternImages(100, 300, PixelTypes.Bgr24)] public void WorksWithDiscoBuffers(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunBufferCapacityLimitProcessorTest(41, c => c.BokehBlur()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index cfa733423..b324b745c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(TestImages), PixelTypes.Rgba32)] public void DetectEdges_WorksOnWrappedMemoryImage(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTestOnWrappedMemoryImage( ctx => @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [WithTestPatternImages(nameof(DetectEdgesFilters), 100, 100, PixelTypes.Rgba32)] [WithFileCollection(nameof(TestImages), nameof(DetectEdgesFilters), PixelTypes.Rgba32)] public void DetectEdges_WorksWithAllFilters(TestImageProvider provider, EdgeDetectionOperators detector) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(TestImages), CommonNonDefaultPixelTypes)] public void DetectEdges_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFile(Tests.TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void DetectEdges_IsAppliedToAllFrames(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFileCollection(nameof(TestImages), PixelTypes.Rgba32)] public void DetectEdges_InBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution [Theory] [WithFile(Tests.TestImages.Png.Bike, nameof(DetectEdgesFilters), PixelTypes.Rgba32)] public void WorksWithDiscoBuffers(TestImageProvider provider, EdgeDetectionOperators detector) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunBufferCapacityLimitProcessorTest( 41, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index fa3e3637f..2ae926392 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void ApplyDiffusionFilterInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void ApplyDitherFilterInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.Filter0, CommonNonDefaultPixelTypes)] public void DiffusionFilter_ShouldNotDependOnSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization TestImageProvider provider, IDither diffuser, string name) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization [Theory] [WithFile(TestImages.Png.Filter0, CommonNonDefaultPixelTypes)] public void DitherFilter_ShouldNotDependOnSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization TestImageProvider provider, IDither ditherer, string name) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllDitherTests) { @@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization public void CommonDitherers_WorkWithDiscoBuffers( TestImageProvider provider, string name) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IDither dither = TestUtils.GetDither(name); if (SkipAllDitherTests) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs index a0ee57682..88ebec4e2 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] public void FullImage(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.BackgroundColor(Color.HotPink)); } @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] public void InBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( (x, rect) => x.BackgroundColor(Color.HotPink, rect)); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 8b03106da..7070e555a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFileCollection(nameof(InputImages), nameof(OilPaintValues), PixelTypes.Rgba32)] public void FullImage(TestImageProvider provider, int levels, int brushSize) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest( x => x.OilPaint(levels, brushSize), @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [WithFileCollection(nameof(InputImages), nameof(OilPaintValues), PixelTypes.Rgba32)] [WithTestPatternImages(nameof(OilPaintValues), 100, 100, PixelTypes.Rgba32)] public void InBox(TestImageProvider provider, int levels, int brushSize) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( (x, rect) => x.OilPaint(levels, brushSize, rect), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index 00a45a94e..dd4abfc76 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void FullImage(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest( x => x.ProcessPixelRowsAsVector4( @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void InBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( (x, rect) => x.ProcessPixelRowsAsVector4( @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void PositionAwareFullImage(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest( c => c.ProcessPixelRowsAsVector4( @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void PositionAwareInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( (c, rect) => c.ProcessPixelRowsAsVector4( diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index e95452ffb..d7cee311d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithFile(TestImages.Png.Ducky, nameof(PixelateValues), PixelTypes.Rgba32)] public void FullImage(TestImageProvider provider, int value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Pixelate(value), value, appendPixelTypeToFileName: false); } @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [WithTestPatternImages(nameof(PixelateValues), 320, 240, PixelTypes.Rgba32)] [WithFile(TestImages.Png.CalliphoraPartial, nameof(PixelateValues), PixelTypes.Rgba32)] public void InBox(TestImageProvider provider, int value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest((x, rect) => x.Pixelate(value, rect), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs index 64aeae053..86518b015 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyBlackWhiteFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(ctx => ctx.BlackWhite(), comparer: ImageComparer.TolerantPercentage(0.002f)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 4ad601583..bb52731bb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -25,6 +25,6 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithTestPatternImages(nameof(BrightnessValues), 48, 48, PixelTypes.Rgba32)] public void ApplyBrightnessFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel => provider.RunValidatingProcessorTest(ctx => ctx.Brightness(value), value, this.imageComparer); + where TPixel : unmanaged, IPixel => provider.RunValidatingProcessorTest(ctx => ctx.Brightness(value), value, this.imageComparer); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index 8ac56655e..5c6a29822 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -31,6 +31,6 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(nameof(ColorBlindnessFilters), 48, 48, PixelTypes.Rgba32)] public void ApplyColorBlindnessFilter(TestImageProvider provider, ColorBlindnessMode colorBlindness) - where TPixel : struct, IPixel => provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString(), this.imageComparer); + where TPixel : unmanaged, IPixel => provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString(), this.imageComparer); } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index d822def91..1758db8dd 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithTestPatternImages(nameof(ContrastValues), 48, 48, PixelTypes.Rgba32)] public void ApplyContrastFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Contrast(value), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs index 9b5a5bfd2..ae9abed7f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void ApplyFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ColorMatrix m = CreateCombinedTestFilterMatrix(); @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyFilterInBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ColorMatrix m = CreateCombinedTestFilterMatrix(); @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(70, 120, PixelTypes.Rgba32)] public void FilterProcessor_WorksWithDiscoBuffers(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { ColorMatrix m = CreateCombinedTestFilterMatrix(); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index 32fc47a80..2352a4dce 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(nameof(GrayscaleModeTypes), 48, 48, PixelTypes.Rgba32)] public void ApplyGrayscaleFilter(TestImageProvider provider, GrayscaleMode value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Grayscale(value), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index 0ede3cef8..9b96653b8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(nameof(HueValues), 48, 48, PixelTypes.Rgba32)] public void ApplyHueFilter(TestImageProvider provider, int value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Hue(value), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs index 1b4c70646..cb7a403f9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyInvertFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Invert()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs index b7b635c2d..04e86c955 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyKodachromeFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Kodachrome()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs index 8934816ac..8b77f902d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs @@ -25,6 +25,6 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithTestPatternImages(nameof(LightnessValues), 48, 48, PixelTypes.Rgba32)] public void ApplyLightnessFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel => provider.RunValidatingProcessorTest(ctx => ctx.Lightness(value), value, this.imageComparer); + where TPixel : unmanaged, IPixel => provider.RunValidatingProcessorTest(ctx => ctx.Lightness(value), value, this.imageComparer); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs index 013ec3874..65e616dca 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyLomographFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Lomograph()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index dfc67324c..bd7336119 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects [Theory] [WithTestPatternImages(nameof(AlphaValues), 48, 48, PixelTypes.Rgba32)] public void ApplyAlphaFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Opacity(value), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs index 3b39542a5..26dac7532 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplyPolaroidFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Polaroid()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 17ffc80de..4be11a72c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(nameof(SaturationValues), 48, 48, PixelTypes.Rgba32)] public void ApplySaturationFilter(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Saturate(value), value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs index b7d381f5f..fa43cb15a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters [Theory] [WithTestPatternImages(48, 48, PixelTypes.Rgba32)] public void ApplySepiaFilter(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Sepia()); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs index d959fdf67..88cd6688a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays [Theory] [WithFileCollection(nameof(InputImages), nameof(ColorNames), PixelTypes.Rgba32)] public void FullImage_ApplyColor(TestImageProvider provider, string colorName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Utility.TestGroupName = this.GetType().Name; Color color = TestUtils.GetColorByName(colorName); @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] public void FullImage_ApplyRadius(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunValidatingProcessorTest( @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] public void InBox(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Utility.TestGroupName = this.GetType().Name; provider.RunRectangleConstrainedValidatingProcessorTest(this.Apply); @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays [Theory] [WithTestPatternImages(70, 120, PixelTypes.Rgba32)] public void WorksWithDiscoBuffers(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunBufferCapacityLimitProcessorTest(37, c => this.Apply(c, Color.DarkRed)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs index 70a07f74f..4ea01c94c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Quantizers), PixelTypes.Rgba32)] public void ApplyQuantizationInBox(TestImageProvider provider, IQuantizer quantizer) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllQuantizerTests) { @@ -177,7 +177,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization [Theory] [WithFileCollection(nameof(CommonTestImages), nameof(Quantizers), PixelTypes.Rgba32)] public void ApplyQuantization(TestImageProvider provider, IQuantizer quantizer) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllQuantizerTests) { @@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization [Theory] [WithFile(TestImages.Png.David, nameof(DitherScaleQuantizers), PixelTypes.Rgba32)] public void ApplyQuantizationWithDitheringScale(TestImageProvider provider, IQuantizer quantizer) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (SkipAllQuantizerTests) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index 9a4e7c618..cdc77d321 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithSolidFilledImages(nameof(Transform_DoesNotCreateEdgeArtifacts_ResamplerNames), 5, 5, 255, 255, 255, 255, PixelTypes.Rgba32)] public void Transform_DoesNotCreateEdgeArtifacts(TestImageProvider provider, string resamplerName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IResampler resampler = GetResampler(resamplerName); using (Image image = provider.GetImage()) @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms float sy, float tx, float ty) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(96, 96, PixelTypes.Rgba32, 50, 0.8f)] public void Transform_RotateScale_ManuallyCentered(TestImageProvider provider, float angleDeg, float s) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(96, 48, PixelTypes.Rgba32)] public void Transform_FromSourceRectangle1(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var rectangle = new Rectangle(48, 0, 48, 24); @@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(96, 48, PixelTypes.Rgba32)] public void Transform_FromSourceRectangle2(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var rectangle = new Rectangle(0, 24, 48, 24); @@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(nameof(ResamplerNames), 150, 150, PixelTypes.Rgba32)] public void Transform_WithSampler(TestImageProvider provider, string resamplerName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IResampler sampler = GetResampler(resamplerName); using (Image image = provider.GetImage()) @@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32, 21)] public void WorksWithDiscoBuffers(TestImageProvider provider, int bufferCapacityInPixelRows) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { AffineTransformBuilder builder = new AffineTransformBuilder() .AppendRotationDegrees(50) @@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms } private static void VerifyAllPixelsAreWhiteOrTransparent(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span data = image.Frames.RootFrame.GetPixelSpan(); var white = new Rgb24(255, 255, 255); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 68852a939..a4fec9fd9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFile(FlipTestFile, nameof(ExifOrientationValues), PixelTypes.Rgba32)] public void AutoOrient_WorksForAllExifOrientations(TestImageProvider provider, ushort orientation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFile(FlipTestFile, nameof(InvalidOrientationValues), PixelTypes.Rgba32)] public void AutoOrient_WorksWithCorruptExifData(TestImageProvider provider, ExifDataType dataType, byte[] orientation) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var profile = new ExifProfile(); profile.SetValue(ExifTag.JPEGTables, orientation); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index b49ac3ea9..f0eef3afd 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(70, 30, PixelTypes.Rgba32, 0, 0, 70, 30)] [WithTestPatternImages(30, 70, PixelTypes.Rgba32, 7, 13, 20, 50)] public void Crop(TestImageProvider provider, int x, int y, int w, int h) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var rect = new Rectangle(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index d20e6fa35..a9b982cf8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(InputImages), nameof(EntropyCropValues), PixelTypes.Rgba32)] public void EntropyCrop(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.EntropyCrop(value), value, appendPixelTypeToFileName: false); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs index d1208d955..ae53afd67 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(nameof(FlipValues), 53, 37, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(FlipValues), 17, 32, PixelTypes.Rgba32)] public void Flip(TestImageProvider provider, FlipMode flipMode) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest( ctx => ctx.Flip(flipMode), @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(nameof(FlipValues), 53, 37, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(FlipValues), 17, 32, PixelTypes.Rgba32)] public void Flip_WorksOnWrappedMemoryImage(TestImageProvider provider, FlipMode flipMode) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTestOnWrappedMemoryImage( ctx => ctx.Flip(flipMode), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index dbaff43f0..28833248c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] public void ImageShouldPad(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] public void ImageShouldPadWithBackgroundColor(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var color = Color.Red; TPixel expected = color.ToPixel(); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 2cbffef47..3d9a3c6b8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(3032, 3032, PixelTypes.Rgba32, 400, 1024)] [WithTestPatternImages(3032, 3032, PixelTypes.Rgba32, 400, 128)] public void LargeImage(TestImageProvider provider, int destSize, int workingBufferSizeHintInKilobytes) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.Is64BitProcess) { @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithBasicTestPatternImages(2, 256, PixelTypes.Rgba32, 1, 1, 1, 8)] [WithBasicTestPatternImages(2, 32, PixelTypes.Rgba32, 1, 1, 1, 2)] public void Resize_BasicSmall(TestImageProvider provider, int wN, int wD, int hN, int hD) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Basic test case, very helpful for debugging // [WithBasicTestPatternImages(15, 12, PixelTypes.Rgba32, 2, 3, 1, 2)] means: @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void WorkingBufferSizeHintInBytes_IsAppliedCorrectly( TestImageProvider provider, int workingBufferLimitInRows) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image0 = provider.GetImage()) { @@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms TestImageProvider provider, int workingBufferLimitInRows, int bufferCapacityInRows) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using Image expected = provider.GetImage(); int width = expected.Width; @@ -189,7 +189,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(100, 100, DefaultPixelType)] public void Resize_Compand(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -204,7 +204,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithFile(TestImages.Png.Kaboom, DefaultPixelType, false)] [WithFile(TestImages.Png.Kaboom, DefaultPixelType, true)] public void Resize_DoesNotBleedAlphaPixels(TestImageProvider provider, bool compand) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string details = compand ? "Compand" : string.Empty; @@ -218,7 +218,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFile(TestImages.Gif.Giphy, DefaultPixelType)] public void Resize_IsAppliedToAllFrames(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -232,7 +232,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(50, 50, CommonNonDefaultPixelTypes)] public void Resize_IsNotBoundToSinglePixelType(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(x => x.Resize(x.GetCurrentSize() / 2), comparer: ValidatorComparer); } @@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void Resize_ThrowsForWrappedMemoryImage(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image0 = provider.GetImage()) { @@ -262,7 +262,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void Resize_WorksWithAllParallelismLevels( TestImageProvider provider, int maxDegreeOfParallelism) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.Configuration.MaxDegreeOfParallelism = maxDegreeOfParallelism > 0 ? maxDegreeOfParallelism : Environment.ProcessorCount; @@ -304,7 +304,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms float? ratio, int? specificDestWidth, int? specificDestHeight) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IResampler sampler = TestUtils.GetResampler(samplerName); @@ -356,7 +356,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeFromSourceRectangle(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -384,7 +384,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeHeightAndKeepAspect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -398,7 +398,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(10, 100, DefaultPixelType)] public void ResizeHeightCannotKeepAspectKeepsOnePixel(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWidthAndKeepAspect(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -425,7 +425,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(100, 10, DefaultPixelType)] public void ResizeWidthCannotKeepAspectKeepsOnePixel(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -438,7 +438,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithBoxPadMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -458,7 +458,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithCropHeightMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -474,7 +474,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithCropWidthMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -490,7 +490,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFile(TestImages.Jpeg.Issues.IncorrectResize1006, DefaultPixelType)] public void CanResizeLargeImageWithCropMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -510,7 +510,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithMaxMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -526,7 +526,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithMinMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -548,7 +548,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithPadMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -568,7 +568,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] public void ResizeWithStretchMode(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -590,7 +590,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithFile(TestImages.Jpeg.Issues.ExifGetString750Transform, DefaultPixelType)] [WithFile(TestImages.Jpeg.Issues.ExifResize1049, DefaultPixelType)] public void CanResizeExifIssueImages(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Test images are large so skip on 32bit for now. if (!TestEnvironment.Is64BitProcess) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index 1e08836c1..04647c019 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(nameof(RotateFlipValues), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateFlipValues), 50, 100, PixelTypes.Rgba32)] public void RotateFlip(TestImageProvider provider, RotateMode rotateType, FlipMode flipType) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index 7801c7143..cf7c0c54b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(nameof(RotateAngles), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateAngles), 50, 100, PixelTypes.Rgba32)] public void Rotate_WithAngle(TestImageProvider provider, float value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); } @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [WithTestPatternImages(nameof(RotateEnumValues), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateEnumValues), 50, 100, PixelTypes.Rgba32)] public void Rotate_WithRotateTypeEnum(TestImageProvider provider, RotateMode value) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs index ad77027f0..0720bcfa2 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(nameof(SkewValues), 100, 50, CommonPixelTypes)] public void Skew_IsNotBoundToSinglePixelType(TestImageProvider provider, float x, float y) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.RunValidatingProcessorTest(ctx => ctx.Skew(x, y), $"{x}_{y}", ValidatorComparer); } @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithFile(TestImages.Png.Ducky, nameof(ResamplerNames), PixelTypes.Rgba32)] public void Skew_WorksWithAllResamplers(TestImageProvider provider, string resamplerName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IResampler sampler = TestUtils.GetResampler(resamplerName); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index 7c3025686..c702aebe4 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithTestPatternImages(nameof(ResamplerNames), 150, 150, PixelTypes.Rgba32)] public void Transform_WithSampler(TestImageProvider provider, string resamplerName) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { IResampler sampler = GetResampler(resamplerName); using (Image image = provider.GetImage()) @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithSolidFilledImages(nameof(TaperMatrixData), 30, 30, nameof(Color.Red), PixelTypes.Rgba32)] public void Transform_WithTaperMatrix(TestImageProvider provider, TaperSide taperSide, TaperCorner taperCorner) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithSolidFilledImages(100, 100, 0, 0, 255, PixelTypes.Rgba32)] public void RawTransformMatchesDocumentedExample(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Printing some extra output to help investigating rounding errors: this.Output.WriteLine($"Vector.IsHardwareAccelerated: {Vector.IsHardwareAccelerated}"); @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms [Theory] [WithSolidFilledImages(290, 154, 0, 0, 255, PixelTypes.Rgba32)] public void PerspectiveTransformMatchesCSS(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // https://jsfiddle.net/dFrHS/545/ // https://github.com/SixLabors/ImageSharp/issues/787 diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 92e14b6a1..cd93ab0cf 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests public void OctreeQuantizerYieldsCorrectTransparentPixel( TestImageProvider provider, bool dither) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, true)] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32, false)] public void WuQuantizerYieldsCorrectTransparentPixel(TestImageProvider provider, bool dither) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests } private int GetTransparentIndex(QuantizedFrame quantized) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // Transparent pixels are much more likely to be found at the end of a palette int index = -1; diff --git a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs index d41d133fa..f3bcd0b95 100644 --- a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Quantization [Theory] [WithFile(TestImages.Png.LowColorVariance, PixelTypes.Rgba32)] public void LowVariance(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // See https://github.com/SixLabors/ImageSharp/issues/866 using (Image image = provider.GetImage()) diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 5a791e5a1..783d6fa48 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests } public void VerifySpecificDecodeCall(byte[] marker, Configuration config) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { DecodeOperation[] discovered = this.DecodeCalls.Where(x => x.IsMatch(marker, config, typeof(TPixel))).ToArray(); @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests } public Image Sample() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { lock (this.sampleImages) { @@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.Tests public int HeaderSize => this.testFormat.HeaderSize; public Image Decode(Configuration config, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var ms = new MemoryStream(); stream.CopyTo(ms); @@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Tests public IEnumerable FileExtensions => this.testFormat.SupportedExtensions; public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { // TODO record this happened so we can verify it. } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 31c13ac1f..76c018f06 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -34,8 +34,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison public abstract ImageSimilarityReport CompareImagesOrFrames( ImageFrame expected, ImageFrame actual) - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel; + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel; } public static class ImageComparerExtensions @@ -44,8 +44,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison this ImageComparer comparer, Image expected, Image actual) - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel { return comparer.CompareImagesOrFrames(expected.Frames.RootFrame, actual.Frames.RootFrame); } @@ -54,8 +54,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison this ImageComparer comparer, Image expected, Image actual) - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel { var result = new List>(); @@ -80,8 +80,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison this ImageComparer comparer, Image expected, Image actual) - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel { if (expected.Size() != actual.Size()) { @@ -105,8 +105,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison Image expected, Image actual, Rectangle ignoredRegion) - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel { if (expected.Size() != actual.Size()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index f054ce8f9..2faeacf68 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs @@ -88,8 +88,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison } public class ImageSimilarityReport : ImageSimilarityReport - where TPixelA : struct, IPixel - where TPixelB : struct, IPixel + where TPixelA : unmanaged, IPixel + where TPixelB : unmanaged, IPixel { public ImageSimilarityReport( ImageFrame expectedImage, diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index 89b841a01..b8ad5c506 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -8,7 +8,7 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { public abstract partial class TestImageProvider : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private class BlankProvider : TestImageProvider, IXunitSerializable { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index d94e21609..48d7b80fb 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -14,7 +14,7 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { public abstract partial class TestImageProvider : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private class FileProvider : TestImageProvider, IXunitSerializable { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs index f8ce3e246..45cf57064 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests /// /// The pixel format of the image public abstract partial class TestImageProvider : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private class MemberMethodProvider : TestImageProvider { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index f8aa04827..131647301 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests /// /// The pixel format of the image public abstract partial class TestImageProvider : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { private class SolidProvider : BlankProvider { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index e307fb5b0..c652b32af 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests /// /// The pixel format of the image. public abstract partial class TestImageProvider : ITestImageProvider, IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { public PixelTypes PixelType { get; private set; } = typeof(TPixel).GetPixelType(); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs index eed9bdd3f..47b647329 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs @@ -12,7 +12,7 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests { public abstract partial class TestImageProvider : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { /// /// A test image provider that produces test patterns. diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index cce0c8712..e08dff525 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.Tests IImageEncoder encoder = null, object testOutputDetails = null, bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { encoder = encoder ?? TestEnvironment.GetReferenceEncoder($"foo.{extension}"); @@ -276,10 +276,10 @@ namespace SixLabors.ImageSharp.Tests } public static void ModifyPixel(Image img, int x, int y, byte perChannelChange) - where TPixel : struct, IPixel => ModifyPixel(img.Frames.RootFrame, x, y, perChannelChange); + where TPixel : unmanaged, IPixel => ModifyPixel(img.Frames.RootFrame, x, y, perChannelChange); public static void ModifyPixel(ImageFrame img, int x, int y, byte perChannelChange) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel pixel = img[x, y]; Rgba64 rgbaPixel = default; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs index 576ae1d9f..4708d70b0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs public static MagickReferenceDecoder Instance { get; } = new MagickReferenceDecoder(); private static void FromRgba32Bytes(Configuration configuration, Span rgbaBytes, IMemoryGroup destinationGroup) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (Memory m in destinationGroup) { @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs } private static void FromRgba64Bytes(Configuration configuration, Span rgbaBytes, IMemoryGroup destinationGroup) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (Memory m in destinationGroup) { @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs } public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using var magickImage = new MagickImage(stream); var result = new Image(configuration, magickImage.Width, magickImage.Height); diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 590233420..eb6f5e8c5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs /// The input bitmap. /// Thrown if the image pixel format is not of type internal static unsafe Image From32bppArgbSystemDrawingBitmap(Bitmap bmp) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int w = bmp.Width; int h = bmp.Height; @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs /// The input bitmap. /// Thrown if the image pixel format is not of type internal static unsafe Image From24bppRgbSystemDrawingBitmap(Bitmap bmp) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int w = bmp.Width; int h = bmp.Height; @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs } internal static unsafe Bitmap To32bppArgbSystemDrawingBitmap(Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Configuration configuration = image.GetConfiguration(); int w = image.Width; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs index 286ab9cae..254112339 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs public static SystemDrawingReferenceDecoder Instance { get; } = new SystemDrawingReferenceDecoder(); public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var sourceBitmap = new System.Drawing.Bitmap(stream)) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs index 46dae17a1..563fe2cb3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs public static SystemDrawingReferenceEncoder Bmp { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Bmp); public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (System.Drawing.Bitmap sdBitmap = SystemDrawingBridge.To32bppArgbSystemDrawingBitmap(image)) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 502a5bf46..0b78138ac 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests object testOutputDetails = null, string extension = "png", bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (TestEnvironment.RunsOnCI) { @@ -148,7 +148,7 @@ namespace SixLabors.ImageSharp.Tests bool grayscale = false, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return image.CompareToReferenceOutput( provider, @@ -180,7 +180,7 @@ namespace SixLabors.ImageSharp.Tests bool grayscale = false, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return CompareToReferenceOutput( image, @@ -201,7 +201,7 @@ namespace SixLabors.ImageSharp.Tests string extension = "png", bool grayscale = false, bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return image.CompareToReferenceOutput( comparer, @@ -237,7 +237,7 @@ namespace SixLabors.ImageSharp.Tests bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true, IImageDecoder decoder = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image referenceImage = GetReferenceOutputImage( provider, @@ -262,7 +262,7 @@ namespace SixLabors.ImageSharp.Tests bool grayscale = false, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return image.CompareFirstFrameToReferenceOutput( comparer, @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Tests bool grayscale = false, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (var firstFrameOnlyImage = new Image(image.Width, image.Height)) using (Image referenceImage = GetReferenceOutputImage( @@ -310,7 +310,7 @@ namespace SixLabors.ImageSharp.Tests string extension = "png", bool grayscale = false, bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image referenceImage = GetReferenceOutputImageMultiFrame( provider, @@ -332,7 +332,7 @@ namespace SixLabors.ImageSharp.Tests bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true, IImageDecoder decoder = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string referenceOutputFile = provider.Utility.GetReferenceOutputFileName( extension, @@ -356,7 +356,7 @@ namespace SixLabors.ImageSharp.Tests object testOutputDetails = null, string extension = "png", bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string[] frameFiles = provider.Utility.GetReferenceOutputFileNamesMultiFrame( frameCount, @@ -401,7 +401,7 @@ namespace SixLabors.ImageSharp.Tests object testOutputDetails = null, string extension = "png", bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image referenceImage = provider.GetReferenceOutputImage( testOutputDetails, @@ -415,7 +415,7 @@ namespace SixLabors.ImageSharp.Tests public static Image ComparePixelBufferTo( this Image image, Span expectedPixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span actualPixels = image.GetPixelSpan(); @@ -444,7 +444,7 @@ namespace SixLabors.ImageSharp.Tests /// The pixel type of the image. /// The image. public static Image ComparePixelBufferTo(this Image image, TPixel expectedPixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (ImageFrame imageFrame in image.Frames) { @@ -460,7 +460,7 @@ namespace SixLabors.ImageSharp.Tests /// The pixel type of the image. /// The image. public static Image ComparePixelBufferTo(this Image image, Color expectedPixelColor) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { foreach (ImageFrame imageFrame in image.Frames) { @@ -476,7 +476,7 @@ namespace SixLabors.ImageSharp.Tests /// The pixel type of the image. /// The image. public static ImageFrame ComparePixelBufferTo(this ImageFrame imageFrame, TPixel expectedPixel) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span actualPixels = imageFrame.GetPixelSpan(); @@ -491,7 +491,7 @@ namespace SixLabors.ImageSharp.Tests public static ImageFrame ComparePixelBufferTo( this ImageFrame image, Span expectedPixels) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Span actual = image.GetPixelSpan(); @@ -509,7 +509,7 @@ namespace SixLabors.ImageSharp.Tests this Image image, ITestImageProvider provider, IImageDecoder referenceDecoder = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return CompareToOriginal(image, provider, ImageComparer.Tolerant(), referenceDecoder); } @@ -519,7 +519,7 @@ namespace SixLabors.ImageSharp.Tests ITestImageProvider provider, ImageComparer comparer, IImageDecoder referenceDecoder = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestImageProvider.GetFilePathOrNull(provider); if (path == null) @@ -552,7 +552,7 @@ namespace SixLabors.ImageSharp.Tests FormattableString testOutputDetails, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -585,7 +585,7 @@ namespace SixLabors.ImageSharp.Tests FormattableString testOutputDetails, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.VerifyOperation( ImageComparer.Tolerant(), @@ -607,7 +607,7 @@ namespace SixLabors.ImageSharp.Tests Action> operation, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.VerifyOperation( comparer, @@ -628,7 +628,7 @@ namespace SixLabors.ImageSharp.Tests Action> operation, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { provider.VerifyOperation(operation, $"", appendPixelTypeToFileName, appendSourceFileOrDescription); } @@ -647,7 +647,7 @@ namespace SixLabors.ImageSharp.Tests bool appendPixelTypeToFileName = true, string referenceImageExtension = null, IImageDecoder referenceDecoder = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string actualOutputFile = provider.Utility.SaveTestOutputFile( image, @@ -667,7 +667,7 @@ namespace SixLabors.ImageSharp.Tests internal static AllocatorBufferCapacityConfigurator LimitAllocatorBufferCapacity( this TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var allocator = (ArrayPoolMemoryAllocator)provider.Configuration.MemoryAllocator; return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf()); @@ -694,12 +694,12 @@ namespace SixLabors.ImageSharp.Tests private class MakeOpaqueProcessor : IImageProcessor { public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel => new MakeOpaqueProcessor(configuration, source, sourceRectangle); } private class MakeOpaqueProcessor : ImageProcessor - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { public MakeOpaqueProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index 1dea51ee1..ba146b9e4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -10,7 +10,7 @@ using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.TestUtilities { public class TestPixel : IXunitSerializable - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { public TestPixel() { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index b5bfec17f..3a1fbd195 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag; public static bool IsEquivalentTo(this Image a, Image b, bool compareAlpha = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (a.Width != b.Width || a.Height != b.Height) { @@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.Tests } internal static TPixel GetPixelOfNamedColor(string colorName) - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => GetColorByName(colorName).ToPixel(); internal static void RunBufferCapacityLimitProcessorTest( @@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests Action process, object testOutputDetails = null, ImageComparer comparer = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { comparer??= ImageComparer.Exact; using Image expected = provider.GetImage(); @@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests ImageComparer comparer = null, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (comparer == null) { @@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests ImageComparer comparer = null, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (comparer == null) { @@ -268,7 +268,7 @@ namespace SixLabors.ImageSharp.Tests string useReferenceOutputFrom = null, bool appendPixelTypeToFileName = true, bool appendSourceFileOrDescription = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (comparer == null) { @@ -320,7 +320,7 @@ namespace SixLabors.ImageSharp.Tests object testOutputDetails = null, ImageComparer comparer = null, bool appendPixelTypeToFileName = true) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (comparer == null) { @@ -343,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests this TestImageProvider provider, Action process, object testOutputDetails = null) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs index a29f16f57..f411e9b08 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/GroupOutputTests.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32)] public void OutputSubfolderName_ValueIsTakeFromGroupOutputAttribute(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.Equal("Foo", provider.Utility.OutputSubfolderName); } @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32)] public void GetTestOutputDir_ShouldDefineSubfolder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string expected = $"{Path.DirectorySeparatorChar}Foo{Path.DirectorySeparatorChar}"; Assert.Contains(expected, provider.Utility.GetTestOutputDir()); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 24c4d1b47..b977ca022 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests TestImageProvider provider, float imageThreshold, int pixelThreshold) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(110, 110, PixelTypes.Rgba32)] public void TolerantImageComparer_ApprovesSimilarityBelowTolerance(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] public void TolerantImageComparer_DoesNotApproveSimilarityAboveTolerance(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba64)] public void TolerantImageComparer_TestPerPixelThreshold(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests [WithTestPatternImages(100, 100, PixelTypes.Rgba32, 99, 100)] [WithTestPatternImages(100, 100, PixelTypes.Rgba32, 100, 99)] public void VerifySimilarity_ThrowsOnSizeMismatch(TestImageProvider provider, int w, int h) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void VerifySimilarity_WhenAnImageFrameIsDifferent_Reports(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] public void ExactComparer_ApprovesExactEquality(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] public void ExactComparer_DoesNotTolerateAnyPixelDifference(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs index e9843b2b7..6083b1fae 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [WithBlankImages(1, 1, PixelTypesToTest32, TestImages.Png.Splash)] [WithBlankImages(1, 1, PixelTypesToTest32, TestImages.Png.Indexed)] public void MagickDecode_8BitDepthImage_IsEquivalentTo_SystemDrawingResult(TestImageProvider dummyProvider, string testImage) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestFile.GetInputFileFullPath(testImage); @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.Rgb48BppTrans)] [WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.L16Bit)] public void MagickDecode_16BitDepthImage_IsApproximatelyEquivalentTo_SystemDrawingResult(TestImageProvider dummyProvider, string testImage) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestFile.GetInputFileFullPath(testImage); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 90d0835e8..9f9ea44f9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory(Skip = SkipBenchmarks)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32)] public void BenchmarkMagickPngDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Png"); } @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory(Skip = SkipBenchmarks)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32)] public void BenchmarkSystemDrawingPngDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Png"); } @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory(Skip = SkipBenchmarks)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32)] public void BenchmarkMagickBmpDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Bmp"); } @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory(Skip = SkipBenchmarks)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32)] public void BenchmarkSystemDrawingBmpDecoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Bmp"); } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 4a02d280e..4c0d5758f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithTestPatternImages(20, 20, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void To32bppArgbSystemDrawingBitmap(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void From32bppArgbSystemDrawingBitmap(TestImageProvider dummyProvider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests } private static string SavePng(TestImageProvider provider, PngColorType pngColorType) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image sourceImage = provider.GetImage()) { @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] public void From32bppArgbSystemDrawingBitmap2(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (TestEnvironment.IsLinux) { @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithTestPatternImages(100, 100, PixelTypes.Rgb24)] public void From24bppRgbSystemDrawingBitmap(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = SavePng(provider, PngColorType.Rgb); @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void OpenWithReferenceDecoder(TestImageProvider dummyProvider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); using (var image = Image.Load(path, SystemDrawingReferenceDecoder.Instance)) @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests [Theory] [WithTestPatternImages(20, 20, PixelTypes.Rgba32 | PixelTypes.Argb32)] public void SaveWithReferenceEncoder(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageExtensionsTests.cs index adb51e723..30f7f1f16 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageExtensionsTests.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests [WithSolidFilledImages(10, 10, 0, 0, 255, PixelTypes.Rgba32)] public void CompareToReferenceOutput_WhenReferenceOutputMatches_ShouldNotThrow( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests [WithSolidFilledImages(10, 10, 0, 0, 255, PixelTypes.Rgba32)] public void CompareToReferenceOutput_WhenReferenceOutputDoesNotMatch_Throws( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests [WithSolidFilledImages(10, 10, 0, 0, 255, PixelTypes.Rgba32)] public void CompareToReferenceOutput_DoNotAppendPixelType( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithSolidFilledImages(10, 10, 0, 0, 255, PixelTypes.Rgba32)] public void CompareToReferenceOutput_WhenReferenceFileMissing_Throws(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void CompareToOriginal_WhenSimilar(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgba32)] public void CompareToOriginal_WhenDifferent_Throws(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(10, 10, PixelTypes.Rgba32)] public void CompareToOriginal_WhenInputIsNotFromFile_Throws(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index bcd5e844a..498f3edca 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -42,13 +42,13 @@ namespace SixLabors.ImageSharp.Tests /// The pixel type of the image. /// A test image. public static Image CreateTestImage() - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => new Image(3, 3); [Theory] [MemberData(nameof(BasicData))] public void Blank_MemberData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image img = provider.GetImage(); @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [MemberData(nameof(FileData))] public void File_MemberData(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.Output.WriteLine("SRC: " + provider.Utility.SourceFileOrDescription); this.Output.WriteLine("OUT: " + provider.Utility.GetTestOutputFileName()); @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Bmp.F, PixelTypes.Rgba32)] public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.Is64BitProcess) { @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Bmp.F, PixelTypes.Rgba32)] public void GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.NotNull(provider.Utility.SourceFileOrDescription); @@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Bmp.F, PixelTypes.Rgba32)] public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual( TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!TestEnvironment.Is64BitProcess) { @@ -163,7 +163,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32)] public void NoOutputSubfolderIsPresentByDefault(TestImageProvider provider) - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => Assert.Empty(provider.Utility.OutputSubfolderName); [Theory] @@ -171,13 +171,13 @@ namespace SixLabors.ImageSharp.Tests [WithBlankImages(1, 1, PixelTypes.A8, PixelTypes.A8)] [WithBlankImages(1, 1, PixelTypes.Argb32, PixelTypes.Argb32)] public void PixelType_PropertyValueIsCorrect(TestImageProvider provider, PixelTypes expected) - where TPixel : struct, IPixel => + where TPixel : unmanaged, IPixel => Assert.Equal(expected, provider.PixelType); [Theory] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] public void SaveTestOutputFileMultiFrame(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image image = provider.GetImage()) { @@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp.Tests [WithBasicTestPatternImages(49, 17, PixelTypes.Rgba32)] [WithBasicTestPatternImages(20, 10, PixelTypes.Rgba32)] public void Use_WithBasicTestPatternImages(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { @@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.Tests public void Use_WithBlankImagesAttribute_WithAllPixelTypes( TestImageProvider provider, string message) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image img = provider.GetImage(); @@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(42, 666, PixelTypes.Rgba32 | PixelTypes.Argb32 | PixelTypes.HalfSingle, "hello")] public void Use_WithEmptyImageAttribute(TestImageProvider provider, string message) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image img = provider.GetImage(); @@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Bmp.Car, PixelTypes.All, 123)] [WithFile(TestImages.Bmp.F, PixelTypes.All, 123)] public void Use_WithFileAttribute(TestImageProvider provider, int yo) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.NotNull(provider.Utility.SourceFileOrDescription); using (Image img = provider.GetImage()) @@ -252,7 +252,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFile(TestImages.Jpeg.Baseline.Testorig420, PixelTypes.Rgba32)] public void Use_WithFileAttribute_CustomConfig(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { EnsureCustomConfigurationIsApplied(provider); } @@ -260,7 +260,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.Argb32)] public void Use_WithFileCollection(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Assert.NotNull(provider.Utility.SourceFileOrDescription); using (Image image = provider.GetImage()) @@ -272,7 +272,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.All)] public void Use_WithMemberFactoryAttribute(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image img = provider.GetImage(); Assert.Equal(3, img.Width); @@ -285,7 +285,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithSolidFilledImages(10, 20, 255, 100, 50, 200, PixelTypes.Rgba32 | PixelTypes.Argb32)] public void Use_WithSolidFilledImagesAttribute(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image img = provider.GetImage(); Assert.Equal(10, img.Width); @@ -310,7 +310,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(49, 20, PixelTypes.Rgba32)] public void Use_WithTestPatternImages(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (Image img = provider.GetImage()) { @@ -321,13 +321,13 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithTestPatternImages(20, 20, PixelTypes.Rgba32)] public void Use_WithTestPatternImages_CustomConfiguration(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { EnsureCustomConfigurationIsApplied(provider); } private static void EnsureCustomConfigurationIsApplied(TestImageProvider provider) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { using (provider.GetImage()) { @@ -362,7 +362,7 @@ namespace SixLabors.ImageSharp.Tests } public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { InvocationCounts[this.callerName]++; return new Image(42, 42); @@ -401,7 +401,7 @@ namespace SixLabors.ImageSharp.Tests } public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { InvocationCounts[this.callerName]++; return new Image(42, 42); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 003e708f4..821370b7a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests private ITestOutputHelper Output { get; } public static Image CreateTestImage() - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var image = new Image(10, 10); @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, true)] [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, false)] public void IsEquivalentTo_WhenFalse(TestImageProvider provider, bool compareAlpha) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image a = provider.GetImage(); Image b = provider.GetImage(x => x.OilPaint(3, 2)); @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32 | PixelTypes.Bgr565, true)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32 | PixelTypes.Bgr565, false)] public void IsEquivalentTo_WhenTrue(TestImageProvider provider, bool compareAlpha) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Image a = provider.GetImage(); Image b = provider.GetImage(); diff --git a/tests/ImageSharp.Tests/VectorAssert.cs b/tests/ImageSharp.Tests/VectorAssert.cs index a32e168af..ba82eb1ac 100644 --- a/tests/ImageSharp.Tests/VectorAssert.cs +++ b/tests/ImageSharp.Tests/VectorAssert.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests public static class VectorAssert { public static void Equal(TPixel expected, TPixel actual, int precision = int.MaxValue) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Equal(expected.ToVector4(), actual.ToVector4(), precision); }