From 270a073fc6fb3e96012d61b6bfd9975e71c41599 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 12 Aug 2019 01:35:03 +1000 Subject: [PATCH 01/11] Cleanup (#965) * redundant () * redundant stirng interpolation * use method groups * redundant unsafe * redundant qualifiers * redundant () * redundant init * redundant init * redundant casts * redundant casts --- .../Drawing/FillRegionProcessor{TPixel}.cs | 4 ++-- .../Text/DrawTextProcessor{TPixel}.cs | 17 ++++++------- .../Extensions/ConfigurationExtensions.cs | 6 ++--- src/ImageSharp/Common/Helpers/Guard.cs | 4 ++-- .../Common/ParallelUtils/ParallelHelper.cs | 8 +++---- src/ImageSharp/Formats/Bmp/BmpFileHeader.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs | 2 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 +- .../Components/Decoder/HuffmanScanDecoder.cs | 6 ++--- src/ImageSharp/Formats/Png/PngConstants.cs | 2 +- src/ImageSharp/Image.FromBytes.cs | 8 +++---- src/ImageSharp/ImageFrame{TPixel}.cs | 4 ++-- src/ImageSharp/Memory/Buffer2DExtensions.cs | 4 ++-- .../MetaData/Profiles/Exif/ExifWriter.cs | 10 ++++---- src/ImageSharp/Primitives/ColorMatrix.cs | 6 ++--- .../Processing/KnownFilterMatrices.cs | 4 ++-- ...eHistogramEqualizationProcessor{TPixel}.cs | 4 ++-- ...alizationSlidingWindowProcessor{TPixel}.cs | 2 +- .../Jpeg/BlockOperations/Block8x8F_Round.cs | 6 ++--- .../Codecs/Jpeg/DecodeJpegParseStreamOnly.cs | 6 ++--- .../Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs | 4 ++-- .../ImageSharp.Benchmarks/Color/RgbToYCbCr.cs | 10 ++++---- .../General/CopyBuffers.cs | 4 ++-- .../General/Vector4Constants.cs | 4 ++-- .../Vectorization/SIMDBenchmarkBase.cs | 4 ++-- .../Drawing/FillSolidBrushTests.cs | 6 ++--- .../Drawing/Paths/ShapeRegionTests.cs | 6 ++--- .../Drawing/Utils/QuickSortTests.cs | 6 ++--- .../FakeImageOperationsProvider.cs | 8 +++---- .../Formats/Bmp/BmpDecoderTests.cs | 12 +++++----- .../Formats/Bmp/BmpMetaDataTests.cs | 2 +- .../Formats/GeneralFormatTests.cs | 6 ++--- .../Formats/Gif/GifEncoderTests.cs | 4 ++-- .../Formats/Gif/GifFrameMetaDataTests.cs | 4 ++-- .../Formats/Gif/GifMetaDataTests.cs | 5 ++-- .../Formats/Jpg/Block8x8FTests.cs | 10 ++++---- .../Formats/Jpg/Block8x8Tests.cs | 6 ++--- .../ImageSharp.Tests/Formats/Jpg/DCTTests.cs | 16 ++++++------- .../Formats/Jpg/GenericBlock8x8Tests.cs | 6 ++--- .../Formats/Jpg/JpegDecoderTests.Baseline.cs | 4 ++-- .../Formats/Jpg/JpegDecoderTests.MetaData.cs | 2 +- .../Formats/Jpg/JpegEncoderTests.cs | 6 ++--- .../Formats/Jpg/JpegMetaDataTests.cs | 6 ++--- .../Formats/Jpg/ParseStreamTests.cs | 2 +- ...ferenceImplementationsTests.AccurateDCT.cs | 4 ++-- ...plementationsTests.FastFloatingPointDCT.cs | 10 ++++---- ...ImplementationsTests.StandardIntegerDCT.cs | 6 ++--- .../Jpg/Utils/LibJpegTools.ComponentData.cs | 6 ++--- .../Formats/Jpg/Utils/LibJpegTools.cs | 4 ++-- .../ReferenceImplementations.AccurateDCT.cs | 16 ++++++------- ...ceImplementations.LLM_FloatingPoint_DCT.cs | 10 ++++---- .../Formats/Jpg/Utils/SpanExtensions.cs | 6 ++--- .../Formats/Png/PngMetaDataTests.cs | 10 ++++---- .../Helpers/ParallelHelperTests.cs | 24 +++++++++---------- .../ImageFrameCollectionTests.NonGeneric.cs | 6 ++--- .../ImageSharp.Tests/Image/ImageSaveTests.cs | 4 ++-- tests/ImageSharp.Tests/ImageOperationTests.cs | 2 +- .../ImageSharp.Tests/Memory/Buffer2DTests.cs | 4 ++-- .../Profiles/Exif/ExifProfileTests.cs | 2 +- .../MetaData/Profiles/ICC/IccWriterTests.cs | 4 ++-- .../PixelFormats/Bgr24Tests.cs | 4 ++-- .../PixelFormats/Bgra32Tests.cs | 4 ++-- .../PixelFormats/Gray8Tests.cs | 6 ++--- .../PixelBlenders/PorterDuffFunctionsTests.cs | 18 +++++++------- .../PorterDuffFunctionsTests_TPixel.cs | 20 ++++++++-------- .../PixelOperationsTests.Blender.cs | 8 +++---- .../PixelFormats/Rgb24Tests.cs | 4 ++-- .../Processing/Dithering/DitherTest.cs | 6 ++--- .../HistogramEqualizationTests.cs | 8 +++---- .../Processors/Overlays/OverlayTestBase.cs | 10 ++++---- .../Processors/Transforms/AutoOrientTests.cs | 8 +++---- tests/ImageSharp.Tests/TestFont.cs | 4 ++-- .../ImageDimensionsMismatchException.cs | 4 ++-- .../Tests/ReferenceDecoderBenchmarks.cs | 12 +++++----- .../Tests/SystemDrawingReferenceCodecTests.cs | 4 ++-- .../Tests/TestImageProviderTests.cs | 16 ++++++------- 76 files changed, 252 insertions(+), 252 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs index f3196a8e8..347d243ae 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing } float yPlusOne = y + 1; - for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) + for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction) { int pointsFound = region.Scan(subPixel + offset, buffer, configuration); if (pointsFound == 0) @@ -192,4 +192,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing return this.definition.Options.IsOpaqueColorWithoutBlending(solidBrush.Color); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs index 0c8d23c69..b3c336c88 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs @@ -135,21 +135,22 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text private readonly PathBuilder builder; - private Point currentRenderPosition = default; - private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams = default; - private readonly int offset = 0; - private PointF currentPoint = default(PointF); + private Point currentRenderPosition; + private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams; + private readonly int offset; + private PointF currentPoint; private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData> glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>(); - private readonly bool renderOutline = false; - private readonly bool renderFill = false; - private bool rasterizationRequired = false; + private readonly bool renderOutline; + private readonly bool renderFill; + private bool rasterizationRequired; public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill) { this.MemoryAllocator = memoryAllocator; + this.currentRenderPosition = default; this.Pen = pen; this.renderFill = renderFill; this.renderOutline = pen != null; @@ -326,7 +327,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text bool scanlineDirty = false; float yPlusOne = y + 1; - for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) + for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction) { var start = new PointF(path.Bounds.Left - 1, subPixel); var end = new PointF(path.Bounds.Right + 1, subPixel); diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs index 6bb5adc06..64532af27 100644 --- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs +++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Threading.Tasks; @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp /// public static ParallelOptions GetParallelOptions(this Configuration configuration) { - return new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index 310765f69..a39d10b6b 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp { if (destination.Length < source.Length) { - ThrowArgumentException($"Destination span is too short!", destinationParamName); + ThrowArgumentException("Destination span is too short!", destinationParamName); } } @@ -251,7 +251,7 @@ namespace SixLabors.ImageSharp { if (destination.Length < source.Length) { - ThrowArgumentException($"Destination span is too short!", destinationParamName); + ThrowArgumentException("Destination span is too short!", destinationParamName); } } diff --git a/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs b/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs index 2c2d045a5..1e7299720 100644 --- a/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs +++ b/src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.ParallelUtils int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; Parallel.For( 0, @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.ParallelUtils int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; Parallel.For( 0, @@ -158,4 +158,4 @@ namespace SixLabors.ImageSharp.ParallelUtils $"{nameof(rectangle)}.{nameof(rectangle.Height)}"); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs b/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs index 661275fc9..16421cfb0 100644 --- a/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp return MemoryMarshal.Cast(data)[0]; } - public unsafe void WriteTo(Span buffer) + public void WriteTo(Span buffer) { ref BmpFileHeader dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); diff --git a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs index 4d7f78100..9ede66070 100644 --- a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs +++ b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs @@ -447,7 +447,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// Writes a complete Bitmap V4 header to a buffer. /// /// The buffer to write to. - public unsafe void WriteV4Header(Span buffer) + public void WriteV4Header(Span buffer) { ref BmpInfoHeader dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index b756427cc..912e6c04d 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Formats.Gif bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global; // Quantize the image returning a palette. - IQuantizedFrame quantized = null; + IQuantizedFrame quantized; using (IFrameQuantizer frameQuantizer = this.quantizer.CreateFrameQuantizer(image.GetConfiguration())) { quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index c50812e25..e8a298c5a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder } } - private unsafe void ParseBaselineDataInterleaved() + private void ParseBaselineDataInterleaved() { // Interleaved int mcu = 0; @@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder } } - private unsafe void ParseBaselineDataNonInterleaved() + private void ParseBaselineDataNonInterleaved() { JpegComponent component = this.components[this.frame.ComponentOrder[0]]; ref HuffmanScanBuffer buffer = ref this.scanBuffer; @@ -366,7 +366,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder } } - private unsafe void ParseProgressiveDataNonInterleaved() + private void ParseProgressiveDataNonInterleaved() { JpegComponent component = this.components[this.frame.ComponentOrder[0]]; ref HuffmanScanBuffer buffer = ref this.scanBuffer; diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 5a846ac3e..632460ec4 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// The dictionary of available color types. /// - public static readonly Dictionary ColorTypes = new Dictionary() + public static readonly Dictionary ColorTypes = new Dictionary { [PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 }, [PngColorType.Rgb] = new byte[] { 8, 16 }, diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 25dc5a1e0..465139b2e 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp /// The configuration. /// The byte array containing encoded image data to read the header from. /// The mime type or null if none found. - public static unsafe IImageFormat DetectFormat(Configuration config, ReadOnlySpan data) + public static IImageFormat DetectFormat(Configuration config, ReadOnlySpan data) { int maxHeaderSize = config.MaxHeaderSize; if (maxHeaderSize <= 0) @@ -351,7 +351,7 @@ namespace SixLabors.ImageSharp /// The configuration options. /// The byte span containing image data. /// A new . - public static unsafe Image Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _); + public static Image Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _); /// /// Load a new instance of from the given encoded byte span. @@ -395,4 +395,4 @@ namespace SixLabors.ImageSharp } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index 982f8d8f2..ef1066d49 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp ParallelHelper.IterateRows( this.Bounds(), configuration, - (rows) => + rows => { for (int y = rows.Min; y < rows.Max; y++) { diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index 096493f2b..59247aa2d 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Memory fixed (byte* ptr = span) { - byte* basePtr = (byte*)ptr; + byte* basePtr = ptr; for (int y = 0; y < buffer.Height; y++) { byte* sPtr = basePtr + sOffset; @@ -184,4 +184,4 @@ namespace SixLabors.ImageSharp.Memory } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index 93fe7fbbe..77af1717d 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -53,12 +53,12 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif if (this.exifIndexes.Count > 0) { - exifIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset); + exifIndex = this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset); } if (this.gpsIndexes.Count > 0) { - gpsIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset); + gpsIndex = this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset); } uint ifdLength = 2 + this.GetLength(this.ifdIndexes) + 4; @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif i = this.WriteData(startIndex, this.gpsIndexes, result, i); } - WriteUInt16((ushort)0, result, i); + WriteUInt16(0, result, i); return result; } @@ -373,4 +373,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif return this.WriteValue(value.DataType, value.Value, destination, offset); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Primitives/ColorMatrix.cs b/src/ImageSharp/Primitives/ColorMatrix.cs index af2e9465a..11886c9c2 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #pragma warning disable SA1117 // Parameters should be on same line or separate lines @@ -269,7 +269,7 @@ namespace SixLabors.ImageSharp.Primitives /// /// The source matrix. /// The negated matrix. - public static unsafe ColorMatrix operator -(ColorMatrix value) + public static ColorMatrix operator -(ColorMatrix value) { ColorMatrix m; @@ -456,4 +456,4 @@ namespace SixLabors.ImageSharp.Primitives this.M51.ToString(ci), this.M52.ToString(ci), this.M53.ToString(ci), this.M54.ToString(ci)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index a17c8dcac..1f36e2593 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Gets an approximated black and white filter /// - public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix() + public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix { M11 = 1.5F, M12 = 1.5F, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 7d8ba6208..dd2f09bcd 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization Parallel.For( 0, tileYStartPositions.Count, - new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, + new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, index => { int cdfX = 0; @@ -470,7 +470,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization Parallel.For( 0, this.tileYStartPositions.Count, - new ParallelOptions() { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, + new ParallelOptions { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, index => { int cdfX = 0; diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index b9d867a93..377af5135 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization { MemoryAllocator memoryAllocator = configuration.MemoryAllocator; - var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; int tileWidth = source.Width / this.Tiles; int tileHeight = tileWidth; int pixelInTile = tileWidth * tileHeight; diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index c7b5802c4..09e25827c 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // ReSharper disable InconsistentNaming @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations { public class Block8x8F_Round { - private Block8x8F block = default(Block8x8F); + private Block8x8F block; [GlobalSetup] public void Setup() @@ -66,4 +66,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations row7 = SimdUtils.FastRound(row7); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs index 5a4a9ab17..f40c15cc1 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using BenchmarkDotNet.Attributes; @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg { using (var memoryStream = new MemoryStream(this.jpegBytes)) { - var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder() { IgnoreMetadata = true }); + var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder { IgnoreMetadata = true }); decoder.ParseStream(memoryStream); decoder.Dispose(); } @@ -65,4 +65,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg // | 'System.Drawing FULL' | Core | Core | Jpg/b(...)f.jpg [28] | 17.68 ms | 2.711 ms | 0.1486 ms | 1.00 | 0.00 | 343.7500 | - | - | 757.04 KB | // | JpegDecoderCore.ParseStream | Core | Core | Jpg/b(...)f.jpg [28] | 14.27 ms | 3.671 ms | 0.2012 ms | 0.81 | 0.00 | - | - | - | 11.76 KB | } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 62742f729..99b071e59 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Drawing; @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg { using (var memoryStream = new MemoryStream(this.jpegBytes)) { - using (var image = Image.Load(memoryStream, new JpegDecoder() { IgnoreMetadata = true })) + using (var image = Image.Load(memoryStream, new JpegDecoder { IgnoreMetadata = true })) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs index b8235fac8..16fdf1830 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Benchmarks public static Byte Create(byte[] data) { - Byte result = default(Byte); + Byte result = default; for (int i = 0; i < data.Length; i++) { result.Data[i] = data[i]; @@ -113,9 +113,9 @@ namespace SixLabors.ImageSharp.Benchmarks // The operation is defined as "RGBA -> YCbCr Transform a stream of bytes into a stream of floats" // We need to benchmark the whole operation, to get true results, not missing any side effects! - private byte[] inputSourceRGB = null; + private byte[] inputSourceRGB; - private int[] inputSourceRGBAsInteger = null; + private int[] inputSourceRGBAsInteger; [GlobalSetup] public void Setup() @@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.Benchmarks OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: - Result result = default(Result); + Result result = default; float* yPtr = (float*)&result.Y; float* cbPtr = (float*)&result.Cb; float* crPtr = (float*)&result.Cr; @@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.Benchmarks OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: - Result result = default(Result); + Result result = default; float* yPtr = (float*)&result.Y; float* cbPtr = (float*)&result.Cb; float* crPtr = (float*)&result.Cr; diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 6af466e42..2c325d184 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General } [Benchmark(Description = "Unsafe.CopyBlock(ref)")] - public unsafe void UnsafeCopyBlockReferences() + public void UnsafeCopyBlockReferences() { Unsafe.CopyBlock(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); } @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General } [Benchmark(Description = "Unsafe.CopyBlockUnaligned(ref)")] - public unsafe void UnsafeCopyBlockUnalignedReferences() + public void UnsafeCopyBlockUnalignedReferences() { Unsafe.CopyBlockUnaligned(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); } diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 3597207ee..02bc5d843 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General private static readonly Vector4 C = new Vector4(5.6f); private static readonly Vector4 D = new Vector4(7.8f); - private Random random = null; + private Random random; private Vector4 parameter; @@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General private float GetRandomFloat() => (float)this.random.NextDouble(); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs index 8fc9d9977..8a14f0245 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs @@ -16,7 +16,7 @@ namespace ImageSharp.Benchmarks.General.Vectorization protected Vector testVector; - protected virtual T GetTestValue() => default(T); + protected virtual T GetTestValue() => default; protected virtual Vector GetTestVector() => new Vector(this.GetTestValue()); @@ -66,4 +66,4 @@ namespace ImageSharp.Benchmarks.General.Vectorization } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 5efaa0633..83f2537e7 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing } public static readonly TheoryData BlendData = - new TheoryData() + new TheoryData { { false, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f }, { false, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f }, @@ -196,4 +196,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index 40c5f950d..69dff7236 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Primitives; @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths public ShapeRegionTests() { - this.pathMock = new Mock() { CallBase = true }; + this.pathMock = new Mock { CallBase = true }; this.bounds = new RectangleF(10.5f, 10, 10, 10); this.pathMock.Setup(x => x.Bounds).Returns(this.bounds); @@ -124,4 +124,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths this.pathMock.Verify(x => x.MaxIntersections); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs b/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs index 6660cd87a..5ad7a1248 100644 --- a/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Tests.Drawing.Utils @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Utils public class QuickSortTests { - public static readonly TheoryData Data = new TheoryData() + public static readonly TheoryData Data = new TheoryData { new float[]{ 3, 2, 1 }, new float[0], @@ -48,4 +48,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Utils Assert.Equal(actual, expected); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs index c3ae0cddf..fb4afc28d 100644 --- a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new AppliedOperation() + this.Applied.Add(new AppliedOperation { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new AppliedOperation() + this.Applied.Add(new AppliedOperation { NonGenericProcessor = processor }); @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Tests { public Rectangle? Rectangle { get; set; } public IImageProcessor GenericProcessor { get; set; } - + public IImageProcessor NonGenericProcessor { get; set; } } } diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index d9fff9ded..ecec6f0a7 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. @@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. @@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); if (TestEnvironment.IsWindows) @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) { image.DebugSave(provider); image.CompareToOriginal(provider, new MagickReferenceDecoder()); @@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) { image.DebugSave(provider); image.CompareToOriginal(provider, new MagickReferenceDecoder()); @@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit(TestImageProvider provider) where TPixel : struct, IPixel { - using (Image image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) + using (Image image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) { image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs index da17dfb98..7045d6450 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp [Fact] public void CloneIsDeep() { - var meta = new BmpMetadata() { BitsPerPixel = BmpBitsPerPixel.Pixel24 }; + var meta = new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Pixel24 }; var clone = (BmpMetadata)meta.DeepClone(); clone.BitsPerPixel = BmpBitsPerPixel.Pixel32; diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index b2f9788ae..62e9acf74 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests using (Image image = provider.GetImage()) { - image.DebugSave(provider, new PngEncoder() { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName); + image.DebugSave(provider, new PngEncoder { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName); } provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); @@ -201,4 +201,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 0605859c2..38cd5bc95 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif { using (Image image = provider.GetImage()) { - var encoder = new GifEncoder() + var encoder = new GifEncoder { // Use the palette quantizer without dithering to ensure results // are consistent @@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif GifMetadata metaData = image.Metadata.GetFormatMetadata(GifFormat.Instance); GifFrameMetadata frameMetaData = image.Frames.RootFrame.Metadata.GetFormatMetadata(GifFormat.Instance); GifColorTableMode colorMode = metaData.ColorTableMode; - var encoder = new GifEncoder() + var encoder = new GifEncoder { ColorTableMode = colorMode, Quantizer = new OctreeQuantizer(frameMetaData.ColorTableLength) diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs index d82bfbf22..b891c8ed2 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Formats.Gif; @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Fact] public void CloneIsDeep() { - var meta = new GifFrameMetadata() + var meta = new GifFrameMetadata { FrameDelay = 1, DisposalMethod = GifDisposalMethod.RestoreToBackground, diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs index 2d554eb62..a5bd6efbb 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs @@ -27,13 +27,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif [Fact] public void CloneIsDeep() { - var meta = new GifMetadata() + var meta = new GifMetadata { RepeatCount = 1, ColorTableMode = GifColorTableMode.Global, GlobalColorTableLength = 2, - Comments = new List() { "Foo" } - + Comments = new List { "Foo" } }; var clone = (GifMetadata)meta.DeepClone(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index 977bc3a8d..93f3f7089 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // Uncomment this to turn unit tests into benchmarks: @@ -426,7 +426,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } @@ -441,14 +441,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg short[] data = Create8x8ShortData(); var source = new Block8x8(data); - + Block8x8F dest = default; dest.LoadFromInt16ExtendedAvx2(ref source); for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index 3df927aeb..da75e059f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public unsafe void Indexer_GetScalarAt_SetScalarAt() { - int sum = 0; + int sum; var block = default(Block8x8); for (int i = 0; i < Block8x8.Size; i++) @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal((float)data[i], dest[i]); + Assert.Equal(data[i], dest[i]); } } @@ -141,4 +141,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(15, d); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 92b92eb10..04e55fad3 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void iDCT2D8x4_LeftPart() { - float[] sourceArray = JpegFixture.Create8x8FloatData(); + float[] sourceArray = Create8x8FloatData(); float[] expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray, expectedDestArray); @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void iDCT2D8x4_RightPart() { - float[] sourceArray = JpegFixture.Create8x8FloatData(); + float[] sourceArray = Create8x8FloatData(); float[] expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray.AsSpan(4), expectedDestArray.AsSpan(4)); @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(3)] public void LLM_TransformIDCT_CompareToNonOptimized(int seed) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed); var source = Block8x8F.Load(sourceArray); @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(3)] public void LLM_TransformIDCT_CompareToAccurate(int seed) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed); var source = Block8x8F.Load(sourceArray); @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2)] public void FDCT8x4_LeftPart(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2)] public void FDCT8x4_RightPart(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2)] public void TransformFDCT(int seed) { - Span src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed); + Span src = Create8x8RoundedRandomFloatData(-200, 200, seed); var srcBlock = new Block8x8F(); srcBlock.LoadFrom(src); @@ -177,4 +177,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs index 341d67f0f..7c42af596 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { for (int j = 0; j < 10; j++) { - var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), (byte)200, (byte)255); + var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), 200, 255); var color = default(TPixel); color.FromRgba32(rgba); @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgb24 | PixelTypes.Rgba32)] - public unsafe void LoadAndStretchCorners_WithOffset(TestImageProvider provider) + public void LoadAndStretchCorners_WithOffset(TestImageProvider provider) where TPixel : struct, IPixel { using (Image s = provider.GetImage()) @@ -121,4 +121,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(expected77, block[7, 7]); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs index 31a5a0eeb..2485561f1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs @@ -36,6 +36,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Theory] [WithFileCollection(nameof(UnrecoverableTestJpegs), PixelTypes.Rgba32)] public void UnrecoverableImagesShouldThrowCorrectError(TestImageProvider provider) - where TPixel : struct, IPixel => Assert.Throws(() => provider.GetImage()); + where TPixel : struct, IPixel => Assert.Throws(provider.GetImage); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs index 8d8d31693..1d5c3e27a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs @@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(true)] public void IgnoreMetaData_ControlsWhetherMetaDataIsParsed(bool ignoreMetaData) { - var decoder = new JpegDecoder() { IgnoreMetadata = ignoreMetaData }; + var decoder = new JpegDecoder { IgnoreMetadata = ignoreMetaData }; // Snake.jpg has both Exif and ICC profiles defined: var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index d9013b507..639ec520e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; @@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg // There is no alpha in Jpeg! image.Mutate(c => c.MakeOpaque()); - var encoder = new JpegEncoder() + var encoder = new JpegEncoder { Subsample = subsample, Quality = quality @@ -198,4 +198,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs index 793bdd522..59ad571f4 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Formats.Jpeg; @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void CloneIsDeep() { - var meta = new JpegMetadata() { Quality = 50 }; + var meta = new JpegMetadata { Quality = 50 }; var clone = (JpegMetadata)meta.DeepClone(); clone.Quality = 99; @@ -19,4 +19,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.False(meta.Quality.Equals(clone.Quality)); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index f4f3b83b4..1d7ca746f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg this.Output.WriteLine(sb.ToString()); } - public static readonly TheoryData ComponentVerificationData = new TheoryData() + public static readonly TheoryData ComponentVerificationData = new TheoryData { { TestImages.Jpeg.Baseline.Jpeg444, 3, new Size(1, 1), new Size(1, 1) }, { TestImages.Jpeg.Baseline.Jpeg420Exif, 3, new Size(2, 2), new Size(1, 1) }, diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs index dd2113624..82fcc368f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2)] public void ForwardThenInverse(int seed) { - float[] data = JpegFixture.Create8x8RandomFloatData(-1000, 1000, seed); + float[] data = Create8x8RandomFloatData(-1000, 1000, seed); var b0 = default(Block8x8F); b0.LoadFrom(data); @@ -36,4 +36,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index ce6f0a744..60a019c29 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2, 0)] public void LLM_ForwardThenInverse(int seed, int startAt) { - int[] data = JpegFixture.Create8x8RandomIntData(-1000, 1000, seed); + int[] data = Create8x8RandomIntData(-1000, 1000, seed); float[] original = data.ConvertAllToFloat(); float[] src = data.ConvertAllToFloat(); float[] dest = new float[64]; @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2, 200)] public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) { - float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-range, range, seed); + float[] sourceArray = Create8x8RoundedRandomFloatData(-range, range, seed); var source = Block8x8F.Load(sourceArray); @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2)] public void LLM_FDCT_IsEquivalentTo_AccurateImplementation(int seed) { - float[] floatData = JpegFixture.Create8x8RandomFloatData(-1000, 1000); + float[] floatData = Create8x8RandomFloatData(-1000, 1000); Block8x8F source = default; source.LoadFrom(floatData); @@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2, 200)] public void GT_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range) { - int[] intData = JpegFixture.Create8x8RandomIntData(-range, range, seed); + int[] intData = Create8x8RandomIntData(-range, range, seed); float[] floatSrc = intData.ConvertAllToFloat(); ReferenceImplementations.AccurateDCT.TransformIDCTInplace(intData); @@ -120,4 +120,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs index f299807fc..f16d04bf6 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(2, 0)] public void ForwardThenInverse(int seed, int startAt) { - Span original = JpegFixture.Create8x8RandomIntData(-200, 200, seed); + Span original = Create8x8RandomIntData(-200, 200, seed); Span block = original.AddScalarToAllValues(128); @@ -80,11 +80,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg for (int i = startAt; i < 64; i++) { float expected = original[i]; - float actual = (float)block[i]; + float actual = block[i]; Assert.Equal(expected, actual, new ApproximateFloatComparer(3f)); } } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index e4fcd10c5..91cd80d14 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -52,8 +52,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils internal void MakeBlock(short[] data, int y, int x) { - this.MinVal = Math.Min((short)this.MinVal, data.Min()); - this.MaxVal = Math.Max((short)this.MaxVal, data.Max()); + this.MinVal = Math.Min(this.MinVal, data.Min()); + this.MaxVal = Math.Max(this.MaxVal, data.Max()); this.SpectralBlocks[x, y] = new Block8x8(data); } @@ -189,4 +189,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index 3de4673f5..5a62de034 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { TestFile testFile = TestFile.Create(inputFile); - string outDir = TestEnvironment.CreateOutputDirectory(".Temp", $"JpegCoeffs"); + string outDir = TestEnvironment.CreateOutputDirectory(".Temp", "JpegCoeffs"); string fn = $"{Path.GetFileName(inputFile)}-{new Random().Next(1000)}.dctcoeffs"; string coeffFileFullPath = Path.Combine(outDir, fn); @@ -139,4 +139,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index 2712d1933..46f030580 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -14,12 +14,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils /// /* reference idct taken from "ieeetest.c" /// * Written by Tom Lane (tgl@cs.cmu.edu). /// * Released to public domain 11/22/93. - /// */ + /// */ /// internal static class AccurateDCT { private static double[,] CosLut = InitCosLut(); - + public static Block8x8 TransformIDCT(ref Block8x8 block) { Block8x8F temp = block.AsFloatBlock(); @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils for (v=0; v<8; v++) { tmp2 = 0.0; for (u=0; u<8; u++) { - tmp2 += (double) block[v * 8 + u] * CosLut[x, u]; + tmp2 += block[v * 8 + u] * CosLut[x, u]; } tmp += CosLut[y, v] * tmp2; } @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } return res; } - + public static Block8x8F TransformFDCT(ref Block8x8F block) { int x, y, u, v; @@ -88,14 +88,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils tmp2 = 0.0; for (x = 0; x < 8; x++) { - tmp2 += (double)block[y * 8 + x] * CosLut[x,u]; + tmp2 += block[y * 8 + x] * CosLut[x,u]; } tmp += CosLut[y, v] * tmp2; } res[v * 8 + u] = (float) tmp; } } - + return res; } @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils for (a = 0; a < 8; a++) for (b = 0; b < 8; b++) { - tmp = Math.Cos((double)((a + a + 1) * b) * (3.14159265358979323846 / 16.0)); + tmp = Math.Cos((a + a + 1) * b * (3.14159265358979323846 / 16.0)); if (b == 0) { tmp /= Math.Sqrt(2.0); @@ -119,4 +119,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index 46b9b4366..df5ec9740 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float[] r = new float[8]; for (int i = 0; i < 8; i++) { - r[i] = (float)(Cos((double)i / 16.0 * M_PI) * M_SQRT2); + r[i] = (float)(Cos(i / 16.0 * M_PI) * M_SQRT2); output?.WriteLine($"float r{i} = {r[i]:R}f;"); } return r; @@ -267,13 +267,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static void fDCT8x8_llm_sse(Span s, Span d, Span temp) { - ReferenceImplementations.Transpose8x8(s, temp); + Transpose8x8(s, temp); fDCT2D8x4_32f(temp, d); fDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - ReferenceImplementations.Transpose8x8(d, temp); + Transpose8x8(d, temp); fDCT2D8x4_32f(temp, d); @@ -535,14 +535,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils fDCT1Dllm_32f(sWorker.Slice(j * 8), temp.Slice(j * 8)); } - ReferenceImplementations.Transpose8x8(temp, d); + Transpose8x8(temp, d); for (int j = 0; j < 8; j++) { fDCT1Dllm_32f(d.Slice(j * 8), temp.Slice(j * 8)); } - ReferenceImplementations.Transpose8x8(temp, d); + Transpose8x8(temp, d); if (downscaleBy8) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index e9527e4c3..f604cb1b5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { - result[i] = (float)src[i]; + result[i] = src[i]; } return result; @@ -118,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils return result; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs index 33fd8ead2..dfa7fd292 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs @@ -24,13 +24,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Fact] public void CloneIsDeep() { - var meta = new PngMetadata() + var meta = new PngMetadata { BitDepth = PngBitDepth.Bit16, ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List() { new PngTextData("name", "value", "foo", "bar") } + TextData = new List { new PngTextData("name", "value", "foo", "bar") } }; var clone = (PngMetadata)meta.DeepClone(); @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); - input.Save(memoryStream, new PngEncoder() + input.Save(memoryStream, new PngEncoder { TextCompressionThreshold = 50 }); @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Fact] public void Decode_IgnoreMetadataIsFalse_TextChunkIsRead() { - var options = new PngDecoder() + var options = new PngDecoder { IgnoreMetadata = false }; @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png [Fact] public void Decode_IgnoreMetadataIsTrue_TextChunksAreIgnored() { - var options = new PngDecoder() + var options = new PngDecoder { IgnoreMetadata = true }; diff --git a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs index ee309e0e3..3468c076a 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers public class ParallelHelperTests { private readonly ITestOutputHelper Output; - + public ParallelHelperTests(ITestOutputHelper output) { this.Output = output; @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers /// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength /// public static TheoryData IterateRows_OverMinimumPixelsLimit_Data = - new TheoryData() + new TheoryData { { 1, 0, 100, -1, 100 }, { 2, 0, 9, 5, 4 }, @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers var rectangle = new Rectangle(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; - + ParallelHelper.IterateRows( rectangle, parallelSettings, @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers actualData[y] = y; } }); - + Assert.Equal(expectedData, actualData); } @@ -144,7 +144,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers int step = rows.Max - rows.Min; int expected = rows.Max < maxY ? expectedStepLength : expectedLastStepLength; - + Interlocked.Increment(ref actualNumberOfSteps); Assert.Equal(expected, step); }); @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers } public static TheoryData IterateRows_WithEffectiveMinimumPixelsLimit_Data = - new TheoryData() + new TheoryData { { 2, 200, 50, 2, 1, -1, 2 }, { 2, 200, 200, 1, 1, -1, 1 }, @@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers Configuration.Default.MemoryAllocator); var rectangle = new Rectangle(0, 0, width, height); - + int actualNumberOfSteps = 0; ParallelHelper.IterateRowsWithTempBuffer( rectangle, @@ -277,7 +277,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers } public static readonly TheoryData IterateRectangularBuffer_Data = - new TheoryData() + new TheoryData { { 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox { 2, 582, 453, 10, 10, 291, 226 }, @@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers using (Buffer2D actual = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) { var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); - + void FillRow(int y, Buffer2D buffer) { for (int x = rect.Left; x < rect.Right; x++) @@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers var rect = new Rectangle(0, 0, width, height); ArgumentOutOfRangeException ex = Assert.Throws( - () => ParallelHelper.IterateRows(rect, parallelSettings, (rows) => { })); + () => ParallelHelper.IterateRows(rect, parallelSettings, rows => { })); Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message); } @@ -370,4 +370,4 @@ namespace SixLabors.ImageSharp.Tests.Helpers Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index 50358a9d0..92c5915ff 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, - (Bgra32)Color.Blue)) + Color.Blue)) { this.Collection.AddFrame(sourceImage.Frames.RootFrame); } @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, - (Bgra32)Color.Blue)) + Color.Blue)) { this.Collection.InsertFrame(0, sourceImage.Frames.RootFrame); } @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests ArgumentNullException ex = Assert.Throws( () => { - this.Collection.AddFrame((ImageFrame)null); + this.Collection.AddFrame(null); }); Assert.StartsWith("Value cannot be null.", ex.Message); diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index c4be6fbec..6236d296e 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests this.encoderNotInFormat = new Mock(); this.fileSystem = new Mock(); - var config = new Configuration() + var config = new Configuration { FileSystem = this.fileSystem.Object }; diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index 7f8b13375..c997f9bd0 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests Mock processorMock = new Mock(); this.processorDefinition = processorMock.Object; - this.image = new Image(new Configuration() + this.image = new Image(new Configuration { ImageOperationsProvider = this.provider }, 1, 1); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index 4af3b81e2..abe78e747 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Memory ref T actual = ref MemoryMarshal.GetReference(span); ref T expected = ref Unsafe.Add(ref buffer.GetReference(), bufferOffset); - Assert.True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position"); + True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position"); } } @@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.Tests.Memory } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs index 6fc5142ee..3ae452d7d 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests Png } - private static readonly Dictionary TestProfileValues = new Dictionary() + private static readonly Dictionary TestProfileValues = new Dictionary { { ExifTag.Software, "Software" }, { ExifTag.Copyright, "Copyright" }, diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs index 43c27335a..33ecf53c7 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Metadata.Profiles.Icc; @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Icc { IccWriter writer = CreateWriter(); - IccProfile profile = new IccProfile() + IccProfile profile = new IccProfile { Header = IccTestDataProfiles.Header_Random_Write }; diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index 026670485..7638c5f86 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } public static readonly TheoryData ColorData = - new TheoryData() { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } }; + new TheoryData { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } }; [Theory] [MemberData(nameof(ColorData))] @@ -129,4 +129,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Assert.Equal(255, bgr.B); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 93ce131d1..28c022709 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } public static readonly TheoryData ColorData = - new TheoryData() + new TheoryData { { 1, 2, 3, 4 }, { 4, 5, 6, 7 }, { 0, 255, 42, 0 }, { 1, 2, 3, 255 } }; @@ -141,4 +141,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Assert.Equal(expected, bgra.PackedValue); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs index 74fd903ca..d7b50ee1e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { public class Gray8Tests { - public static readonly TheoryData LuminanceData = new TheoryData() + public static readonly TheoryData LuminanceData = new TheoryData { 0, 1, @@ -279,4 +279,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index f0b27d486..e397f70b0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders { public class PorterDuffFunctionsTests { - public static TheoryData NormalBlendFunctionData = new TheoryData() { + public static TheoryData NormalBlendFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, }; @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders Assert.Equal(expected, actual); } - public static TheoryData MultiplyFunctionData = new TheoryData() { + public static TheoryData MultiplyFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, { @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData AddFunctionData = new TheoryData() { + public static TheoryData AddFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) }, { @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData SubtractFunctionData = new TheoryData() { + public static TheoryData SubtractFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(0,0,0,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1, 1f) }, { @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData ScreenFunctionData = new TheoryData() { + public static TheoryData ScreenFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1, 1f) }, { @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData DarkenFunctionData = new TheoryData() { + public static TheoryData DarkenFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(.6f,.6f,.6f, 1f) }, { @@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData LightenFunctionData = new TheoryData() { + public static TheoryData LightenFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1,1f) }, { @@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData OverlayFunctionData = new TheoryData() { + public static TheoryData OverlayFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1,1f) }, { @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, actual, 5); } - public static TheoryData HardLightFunctionData = new TheoryData() { + public static TheoryData HardLightFunctionData = new TheoryData { { new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) }, { new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f,0.6f,0.6f,1f) }, { diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index 0e270dfda..859be6b20 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders return new Span(new[] { value }); } - public static TheoryData NormalBlendFunctionData = new TheoryData() { + public static TheoryData NormalBlendFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, }; @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void NormalBlendFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)(TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData MultiplyFunctionData = new TheoryData() { + public static TheoryData MultiplyFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, { @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData AddFunctionData = new TheoryData() { + public static TheoryData AddFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(1f, 1f, 1f, 1f) }, { @@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData SubtractFunctionData = new TheoryData() { + public static TheoryData SubtractFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(0,0,0,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(1,1,1, 1f) }, { @@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData ScreenFunctionData = new TheoryData() { + public static TheoryData ScreenFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(1,1,1, 1f) }, { @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData DarkenFunctionData = new TheoryData() { + public static TheoryData DarkenFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(.6f,.6f,.6f, 1f) }, { @@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData LightenFunctionData = new TheoryData() { + public static TheoryData LightenFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(1,1,1,1f) }, { @@ -286,7 +286,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData OverlayFunctionData = new TheoryData() { + public static TheoryData OverlayFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(1,1,1,1f) }, { @@ -325,7 +325,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders VectorAssert.Equal(expected, dest[0], 2); } - public static TheoryData HardLightFunctionData = new TheoryData() { + public static TheoryData HardLightFunctionData = new TheoryData { { new TestPixel(1,1,1,1), new TestPixel(1,1,1,1), 1, new TestPixel(1,1,1,1) }, { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(0.6f,0.6f,0.6f,1f) }, { diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs index eea0b5eac..74360e857 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { public class PixelBlenderTests { - public static TheoryData BlenderMappings = new TheoryData() + public static TheoryData BlenderMappings = new TheoryData { { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelColorBlendingMode.Normal }, { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelColorBlendingMode.Screen }, @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Assert.IsType(type, blender); } - public static TheoryData ColorBlendingExpectedResults = new TheoryData() + public static TheoryData ColorBlendingExpectedResults = new TheoryData { { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Normal, Rgba32.MidnightBlue }, { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Assert.Equal(actualResult.ToVector4(), expectedResult.ToVector4()); } - public static TheoryData AlphaCompositionExpectedResults = new TheoryData() + public static TheoryData AlphaCompositionExpectedResults = new TheoryData { { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, { Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index df459422c..06e3d5948 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public class Rgb24Tests { public static readonly TheoryData ColorData = - new TheoryData() + new TheoryData { { 1, 2, 3 }, { 4, 5, 6 }, @@ -130,4 +130,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Assert.Equal(255, rgb.B); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 03089bc6c..c5d18cbb2 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization { public static void Equal(ReadOnlySpan a, ReadOnlySpan b) { - Xunit.Assert.True(a.SequenceEqual(b)); + True(a.SequenceEqual(b)); } } @@ -112,4 +112,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization Assert.Equal(this.TestPalette, p.Palette); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index fc9a583dd..e5015a6ee 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization }; // Act - image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions() + image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions { LuminanceLevels = luminanceLevels })); @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + var options = new HistogramEqualizationOptions { Method = HistogramEqualizationMethod.AdaptiveSlidingWindow, LuminanceLevels = 256, @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + var options = new HistogramEqualizationOptions { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs index 4da2a832c..c1c6bbd7c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays public static string[] InputImages = { TestImages.Png.Ducky, TestImages.Png.Splash }; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); - + [Theory] [WithFileCollection(nameof(InputImages), nameof(ColorNames), PixelTypes.Rgba32)] public void FullImage_ApplyColor(TestImageProvider provider, string colorName) @@ -52,13 +52,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays where TPixel : struct, IPixel { provider.Utility.TestGroupName = this.GetType().Name; - provider.RunRectangleConstrainedValidatingProcessorTest((x, rect) => this.Apply(x, rect)); + provider.RunRectangleConstrainedValidatingProcessorTest(this.Apply); } protected abstract void Apply(IImageProcessingContext ctx, Color color); - + protected abstract void Apply(IImageProcessingContext ctx, float radiusX, float radiusY); - + protected abstract void Apply(IImageProcessingContext ctx, Rectangle rect); } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 28271bb77..69acf9282 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -23,10 +23,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { ExifDataType.SignedByte, new byte[] { 2 } }, { ExifDataType.SignedShort, BitConverter.GetBytes((short) 3) }, { ExifDataType.Long, BitConverter.GetBytes((uint) 4) }, - { ExifDataType.SignedLong, BitConverter.GetBytes((int) 5) } + { ExifDataType.SignedLong, BitConverter.GetBytes(5) } }; - public static readonly TheoryData ExifOrientationValues = new TheoryData() + public static readonly TheoryData ExifOrientationValues = new TheoryData { 0, 1, @@ -87,4 +87,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestFont.cs b/tests/ImageSharp.Tests/TestFont.cs index a911cd4e8..c01f50f20 100644 --- a/tests/ImageSharp.Tests/TestFont.cs +++ b/tests/ImageSharp.Tests/TestFont.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests AddFormatsDirectoryFromTestAssemblyPath(directories); - string directory = directories.FirstOrDefault(x => Directory.Exists(x)); + string directory = directories.FirstOrDefault(Directory.Exists); if (directory != null) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs index e8f60ade3..024c2ee21 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison public class ImageDimensionsMismatchException : ImagesSimilarityException { public ImageDimensionsMismatchException(Size expectedSize, Size actualSize) - : base((string)$"The image dimensions {actualSize} do not match the expected {expectedSize}!") + : base($"The image dimensions {actualSize} do not match the expected {expectedSize}!") { this.ExpectedSize = expectedSize; this.ActualSize = actualSize; @@ -17,4 +17,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison public Size ExpectedSize { get; } public Size ActualSize { get; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 01cc61484..b0d3b8c7e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests public void BenchmarkMagickPngDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Png"); + this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Png"); } [Theory(Skip = SkipBenchmarks)] @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests public void BenchmarkSystemDrawingPngDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Png"); + this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Png"); } [Theory(Skip = SkipBenchmarks)] @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests public void BenchmarkMagickBmpDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Bmp"); + this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Bmp"); } [Theory(Skip = SkipBenchmarks)] @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests public void BenchmarkSystemDrawingBmpDecoder(TestImageProvider provider) where TPixel : struct, IPixel { - this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Bmp"); + this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Bmp"); } private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) @@ -93,4 +93,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests info); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 3cdb67dbd..4a02d280e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests sourceImage.Mutate(c => c.MakeOpaque()); } - var encoder = new PngEncoder() { ColorType = pngColorType }; + var encoder = new PngEncoder { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } } @@ -133,4 +133,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index f589db697..738465a6e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -19,13 +19,13 @@ namespace SixLabors.ImageSharp.Tests { public class TestImageProviderTests { - public static readonly TheoryData BasicData = new TheoryData() + public static readonly TheoryData BasicData = new TheoryData { TestImageProvider.Blank(10, 20), TestImageProvider.Blank(10, 20), }; - public static readonly TheoryData FileData = new TheoryData() + public static readonly TheoryData FileData = new TheoryData { TestImageProvider.File(TestImages.Bmp.Car), TestImageProvider.File(TestImages.Bmp.F) @@ -114,10 +114,10 @@ namespace SixLabors.ImageSharp.Tests string testName = nameof(this .GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual); - var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 42 }; + var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 42 }; decoder1.InitCaller(testName); - var decoder2 = new TestDecoderWithParameters() { Param1 = "LoL", Param2 = 42 }; + var decoder2 = new TestDecoderWithParameters { Param1 = "LoL", Param2 = 42 }; decoder2.InitCaller(testName); provider.GetImage(decoder1); @@ -148,10 +148,10 @@ namespace SixLabors.ImageSharp.Tests string testName = nameof(this .GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual); - var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 }; + var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 }; decoder1.InitCaller(testName); - var decoder2 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 }; + var decoder2 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 }; decoder2.InitCaller(testName); provider.GetImage(decoder1); @@ -354,7 +354,7 @@ namespace SixLabors.ImageSharp.Tests private static readonly object Monitor = new object(); - private string callerName = null; + private string callerName; public static void DoTestThreadSafe(Action action) { @@ -389,7 +389,7 @@ namespace SixLabors.ImageSharp.Tests private static readonly object Monitor = new object(); - private string callerName = null; + private string callerName; public string Param1 { get; set; } From c992db17febffe1ba03c28ee17c3615c8330ed2e Mon Sep 17 00:00:00 2001 From: Anton Firsov Date: Mon, 12 Aug 2019 10:22:45 +0200 Subject: [PATCH 02/11] Throw ObjectDisposedException when trying to operate on a disposed image (#968) * disable multitargeting + TreatWarningsAsErrors to for fast development * Check if image is disposed in significant Image and Image methods * Mutate / Clone: ensure image is not disposed * Revert "disable multitargeting + TreatWarningsAsErrors to for fast development" This reverts commit 9ad74f76f600acf6c3c1e4f0b91b7c9cb49b24aa. --- src/ImageSharp/Image.cs | 22 ++++++- src/ImageSharp/ImageExtensions.cs | 13 +++- src/ImageSharp/Image{TPixel}.cs | 8 ++- .../Extensions/ProcessingExtensions.cs | 22 +++++-- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 20 +++++- .../ImageSharp.Tests/Image/ImageTests.Save.cs | 16 +++++ tests/ImageSharp.Tests/ImageOperationTests.cs | 65 ++++++++++++++++++- 7 files changed, 156 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 86fef715d..57f60f2e7 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -80,8 +80,22 @@ namespace SixLabors.ImageSharp /// Configuration IConfigurable.Configuration => this.Configuration; + /// + /// Gets a value indicating whether the image instance is disposed. + /// + public bool IsDisposed { get; private set; } + /// - public abstract void Dispose(); + public void Dispose() + { + if (this.IsDisposed) + { + return; + } + + this.IsDisposed = true; + this.DisposeImpl(); + } /// /// Saves the image to the given stream using the given image encoder. @@ -93,6 +107,7 @@ namespace SixLabors.ImageSharp { Guard.NotNull(stream, nameof(stream)); Guard.NotNull(encoder, nameof(encoder)); + this.EnsureNotDisposed(); EncodeVisitor visitor = new EncodeVisitor(encoder, stream); this.AcceptVisitor(visitor); @@ -128,6 +143,11 @@ namespace SixLabors.ImageSharp /// The . protected void UpdateSize(Size size) => this.size = size; + /// + /// Implements the Dispose logic. + /// + protected abstract void DisposeImpl(); + private class EncodeVisitor : IImageVisitor { private readonly IImageEncoder encoder; diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index ec4c364d8..6ea2b234c 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -119,5 +119,16 @@ namespace SixLabors.ImageSharp return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(stream.ToArray())}"; } } + + /// + /// Throws if the image is disposed. + /// + internal static void EnsureNotDisposed(this Image image) + { + if (image.IsDisposed) + { + throw new ObjectDisposedException(nameof(image), "Trying to execute an operation on a disposed image."); + } + } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 5d0364dd8..a7ea58652 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -162,6 +162,8 @@ namespace SixLabors.ImageSharp /// Returns a new with all the same pixel data as the original. public Image Clone(Configuration configuration) { + this.EnsureNotDisposed(); + IEnumerable> clonedFrames = this.Frames.Select, ImageFrame>(x => x.Clone(configuration)); return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); @@ -175,17 +177,21 @@ namespace SixLabors.ImageSharp /// The . public override Image CloneAs(Configuration configuration) { + this.EnsureNotDisposed(); + IEnumerable> clonedFrames = this.Frames.Select, ImageFrame>(x => x.CloneAs(configuration)); return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); } /// - public override void Dispose() => this.Frames.Dispose(); + protected override void DisposeImpl() => this.Frames.Dispose(); /// internal override void AcceptVisitor(IImageVisitor visitor) { + this.EnsureNotDisposed(); + visitor.Visit(this); } diff --git a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs index 2304a44c3..cb3f8fa57 100644 --- a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs @@ -21,6 +21,10 @@ namespace SixLabors.ImageSharp.Processing /// The operation to perform on the source. public static void Mutate(this Image source, Action operation) { + Guard.NotNull(source, nameof(source)); + Guard.NotNull(operation, nameof(operation)); + source.EnsureNotDisposed(); + ProcessingVisitor visitor = new ProcessingVisitor(operation, true); source.AcceptVisitor(visitor); } @@ -34,8 +38,9 @@ namespace SixLabors.ImageSharp.Processing public static void Mutate(this Image source, Action operation) where TPixel : struct, IPixel { - Guard.NotNull(operation, nameof(operation)); Guard.NotNull(source, nameof(source)); + Guard.NotNull(operation, nameof(operation)); + source.EnsureNotDisposed(); IInternalImageProcessingContext operationsRunner = source.GetConfiguration().ImageOperationsProvider .CreateImageProcessingContext(source, true); @@ -51,8 +56,9 @@ namespace SixLabors.ImageSharp.Processing public static void Mutate(this Image source, params IImageProcessor[] operations) where TPixel : struct, IPixel { - Guard.NotNull(operations, nameof(operations)); Guard.NotNull(source, nameof(source)); + Guard.NotNull(operations, nameof(operations)); + source.EnsureNotDisposed(); IInternalImageProcessingContext operationsRunner = source.GetConfiguration().ImageOperationsProvider .CreateImageProcessingContext(source, true); @@ -67,6 +73,10 @@ namespace SixLabors.ImageSharp.Processing /// The new . public static Image Clone(this Image source, Action operation) { + Guard.NotNull(source, nameof(source)); + Guard.NotNull(operation, nameof(operation)); + source.EnsureNotDisposed(); + ProcessingVisitor visitor = new ProcessingVisitor(operation, false); source.AcceptVisitor(visitor); return visitor.ResultImage; @@ -82,8 +92,9 @@ namespace SixLabors.ImageSharp.Processing public static Image Clone(this Image source, Action operation) where TPixel : struct, IPixel { - Guard.NotNull(operation, nameof(operation)); Guard.NotNull(source, nameof(source)); + Guard.NotNull(operation, nameof(operation)); + source.EnsureNotDisposed(); IInternalImageProcessingContext operationsRunner = source.GetConfiguration().ImageOperationsProvider .CreateImageProcessingContext(source, false); @@ -101,8 +112,9 @@ namespace SixLabors.ImageSharp.Processing public static Image Clone(this Image source, params IImageProcessor[] operations) where TPixel : struct, IPixel { - Guard.NotNull(operations, nameof(operations)); Guard.NotNull(source, nameof(source)); + Guard.NotNull(operations, nameof(operations)); + source.EnsureNotDisposed(); IInternalImageProcessingContext operationsRunner = source.GetConfiguration().ImageOperationsProvider .CreateImageProcessingContext(source, false); @@ -152,4 +164,4 @@ namespace SixLabors.ImageSharp.Processing } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 82864f156..66081348a 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -7,6 +7,24 @@ namespace SixLabors.ImageSharp.Tests { public class ImageCloneTests { + [Fact] + public void CloneAs_WhenDisposed_Throws() + { + Image image = new Image(5, 5); + image.Dispose(); + + Assert.Throws(() => image.CloneAs()); + } + + [Fact] + public void Clone_WhenDisposed_Throws() + { + Image image = new Image(5, 5); + image.Dispose(); + + Assert.Throws(() => image.Clone()); + } + [Theory] [WithTestPatternImages(9, 9, PixelTypes.Rgba32)] public void CloneAs_ToBgra32(TestImageProvider provider) @@ -109,4 +127,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Save.cs b/tests/ImageSharp.Tests/Image/ImageTests.Save.cs index 66b0dd21d..61f694518 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Save.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Save.cs @@ -4,6 +4,10 @@ // ReSharper disable InconsistentNaming using System; +using System.IO; + +using Moq; + using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.PixelFormats; using Xunit; @@ -65,6 +69,18 @@ namespace SixLabors.ImageSharp.Tests Assert.Equal("image/png", mime.DefaultMimeType); } } + + [Fact] + public void ThrowsWhenDisposed() + { + var image = new Image(5, 5); + image.Dispose(); + IImageEncoder encoder = Mock.Of(); + using (MemoryStream stream = new MemoryStream()) + { + Assert.Throws(() => image.Save(stream, encoder)); + } + } } } } diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index c997f9bd0..20c3b728f 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -23,19 +23,22 @@ namespace SixLabors.ImageSharp.Tests private readonly FakeImageOperationsProvider provider; private readonly IImageProcessor processorDefinition; + private static readonly string ExpectedExceptionMessage = GetExpectedExceptionText(); + public ImageOperationTests() { this.provider = new FakeImageOperationsProvider(); Mock processorMock = new Mock(); this.processorDefinition = processorMock.Object; - + this.image = new Image(new Configuration { ImageOperationsProvider = this.provider }, 1, 1); } + [Fact] public void MutateCallsImageOperationsProvider_Func_OriginalImage() { @@ -109,5 +112,65 @@ namespace SixLabors.ImageSharp.Tests } public void Dispose() => this.image.Dispose(); + + [Fact] + public void GenericMutate_WhenDisposed_Throws() + { + this.image.Dispose(); + + CheckThrowsCorrectObjectDisposedException( + () => this.image.Mutate(x => x.ApplyProcessor(this.processorDefinition))); + } + + [Fact] + public void GenericClone_WhenDisposed_Throws() + { + this.image.Dispose(); + + CheckThrowsCorrectObjectDisposedException( + () => this.image.Clone(x => x.ApplyProcessor(this.processorDefinition))); + } + + [Fact] + public void AgnosticMutate_WhenDisposed_Throws() + { + this.image.Dispose(); + Image img = this.image; + + CheckThrowsCorrectObjectDisposedException( + () => img.Mutate(x => x.ApplyProcessor(this.processorDefinition))); + } + + [Fact] + public void AgnosticClone_WhenDisposed_Throws() + { + this.image.Dispose(); + Image img = this.image; + + CheckThrowsCorrectObjectDisposedException( + () => img.Clone(x => x.ApplyProcessor(this.processorDefinition))); + } + + private static string GetExpectedExceptionText() + { + try + { + Image img = new Image(1, 1); + img.Dispose(); + img.EnsureNotDisposed(); + } + catch (ObjectDisposedException ex) + { + return ex.Message; + } + + return "?"; + } + + private static void CheckThrowsCorrectObjectDisposedException(Action action) + { + var ex = Assert.Throws(action); + Assert.Equal(ExpectedExceptionMessage, ex.Message); + } } } From e23d8df4854abd731b2ad3835f88a980645df539 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 13 Aug 2019 09:33:39 +1000 Subject: [PATCH 03/11] remove some redundant variables and type params (#971) * remove redundant variable init * redundant variables * remove redundant tileY variable * remove redundant sum variable * redundant mcu variable * redundant type params * Revert "remove redundant sum variable" This reverts commit 21de86c82fb03d5ffd13928bbd82aaf5abf77d7f. --- src/ImageSharp/Advanced/AotCompilerTools.cs | 2 +- .../Jpeg/Components/Decoder/HuffmanScanDecoder.cs | 10 ---------- ...ptiveHistogramEqualizationProcessor{TPixel}.cs | 15 +++------------ .../Formats/Gif/GifEncoderTests.cs | 2 +- tests/ImageSharp.Tests/Image/ImageSaveTests.cs | 10 +++++----- 5 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs index c263aaa13..084f2403e 100644 --- a/src/ImageSharp/Advanced/AotCompilerTools.cs +++ b/src/ImageSharp/Advanced/AotCompilerTools.cs @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Advanced { var test = new FloydSteinbergDiffuser(); TPixel pixel = default; - test.Dither(new ImageFrame(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0); + test.Dither(new ImageFrame(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0); } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index e8a298c5a..fbb2b5272 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -209,7 +209,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder dcHuffmanTable.Configure(); acHuffmanTable.Configure(); - int mcu = 0; for (int j = 0; j < h; j++) { Span blockSpan = component.SpectralBlocks.GetRowSpan(j); @@ -228,9 +227,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder ref dcHuffmanTable, ref acHuffmanTable); - // Every data block is an MCU, so countdown the restart interval - mcu++; - this.HandleRestart(); } } @@ -379,7 +375,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DCHuffmanTableId]; dcHuffmanTable.Configure(); - int mcu = 0; for (int j = 0; j < h; j++) { Span blockSpan = component.SpectralBlocks.GetRowSpan(j); @@ -397,8 +392,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder ref Unsafe.Add(ref blockRef, i), ref dcHuffmanTable); - // Every data block is an MCU, so countdown the restart interval - mcu++; this.HandleRestart(); } } @@ -408,7 +401,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder ref HuffmanTable acHuffmanTable = ref this.acHuffmanTables[component.ACHuffmanTableId]; acHuffmanTable.Configure(); - int mcu = 0; for (int j = 0; j < h; j++) { Span blockSpan = component.SpectralBlocks.GetRowSpan(j); @@ -425,8 +417,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder ref Unsafe.Add(ref blockRef, i), ref acHuffmanTable); - // Every data block is an MCU, so countdown the restart interval - mcu++; this.HandleRestart(); } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index dd2f09bcd..537a3089e 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -77,25 +77,22 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, index => { - int cdfX = 0; - int tileX = 0; - int tileY = 0; int y = tileYStartPositions[index].y; int cdfYY = tileYStartPositions[index].cdfY; // It's unfortunate that we have to do this per iteration. ref TPixel sourceBase = ref source.GetPixelReference(0, 0); - cdfX = 0; + int cdfX = 0; for (int x = halfTileWidth; x < sourceWidth - halfTileWidth; x += tileWidth) { - tileY = 0; + int tileY = 0; int yEnd = Math.Min(y + tileHeight, sourceHeight); int xEnd = Math.Min(x + tileWidth, sourceWidth); for (int dy = y; dy < yEnd; dy++) { int dyOffSet = dy * sourceWidth; - tileX = 0; + int tileX = 0; for (int dx = x; dx < xEnd; dx++) { ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx); @@ -221,7 +218,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization int xEnd, int luminanceLevels) { - int halfTileWidth = tileWidth / 2; int halfTileHeight = tileHeight / 2; int cdfY = 0; @@ -232,13 +228,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization for (int dy = y; dy < yLimit; dy++) { int dyOffSet = dy * sourceWidth; - int tileX = halfTileWidth; for (int dx = xStart; dx < xEnd; dx++) { ref TPixel pixel = ref Unsafe.Add(ref pixelBase, dyOffSet + dx); float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels); pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); - tileX++; } tileY++; @@ -277,7 +271,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization int cdfX = 0; for (int x = halfTileWidth; x < sourceWidth - halfTileWidth; x += tileWidth) { - int tileY = 0; for (int dy = yStart; dy < yEnd; dy++) { int dyOffSet = dy * sourceWidth; @@ -290,8 +283,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } - - tileY++; } cdfX++; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 38cd5bc95..d6d58eae7 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif outStream.Position = 0; var clone = Image.Load(outStream); - GifMetadata cloneMetaData = clone.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata cloneMetaData = clone.Metadata.GetFormatMetadata(GifFormat.Instance); Assert.Equal(metaData.ColorTableMode, cloneMetaData.ColorTableMode); // Gifiddle and Cyotek GifInfo say this image has 64 colors. diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index 6236d296e..f5504fac2 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream); this.Image.Save("path.png"); - this.encoder.Verify(x => x.Encode(this.Image, stream)); + this.encoder.Verify(x => x.Encode(this.Image, stream)); } @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests this.Image.Save("path.jpg", this.encoderNotInFormat.Object); - this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream)); + this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream)); } [Fact] @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests { string str = this.Image.ToBase64String(this.localImageFormat.Object); - this.encoder.Verify(x => x.Encode(this.Image, It.IsAny())); + this.encoder.Verify(x => x.Encode(this.Image, It.IsAny())); } [Fact] @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests Stream stream = new MemoryStream(); this.Image.Save(stream, this.localImageFormat.Object); - this.encoder.Verify(x => x.Encode(this.Image, stream)); + this.encoder.Verify(x => x.Encode(this.Image, stream)); } [Fact] @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Tests this.Image.Save(stream, this.encoderNotInFormat.Object); - this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream)); + this.encoderNotInFormat.Verify(x => x.Encode(this.Image, stream)); } public void Dispose() From f2ea1c2f87e627a219d9940764e74b76f65bba70 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 13 Aug 2019 20:43:37 +1000 Subject: [PATCH 04/11] redundant comment --- tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs index 16fdf1830..5e3ba5d7b 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs @@ -85,7 +85,6 @@ namespace SixLabors.ImageSharp.Benchmarks } } - // Waiting for C# 7 stackalloc keyword patiently ... private static class OnStackInputCache { public unsafe struct Byte From f63348d69a2dcdda3ef37e22473d133c438345dc Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 13 Aug 2019 20:45:13 +1000 Subject: [PATCH 05/11] remove redundant ParallelOptions --- src/ImageSharp/ImageFrame{TPixel}.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index ef1066d49..5c9ff489e 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -4,7 +4,7 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Threading.Tasks; + using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp Guard.MustBeGreaterThan(height, 0, nameof(height)); this.PixelBuffer = this.MemoryAllocator.Allocate2D(width, height); - this.Clear(configuration.GetParallelOptions(), backgroundColor); + this.Clear(backgroundColor); } /// @@ -283,9 +283,8 @@ namespace SixLabors.ImageSharp /// /// Clears the bitmap. /// - /// The parallel options. /// The value to initialize the bitmap with. - internal void Clear(ParallelOptions parallelOptions, TPixel value) + internal void Clear(TPixel value) { Span span = this.GetPixelSpan(); From e4e8205807dd9754fa5548d4f1b699fa7794b00d Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 13 Aug 2019 20:50:16 +1000 Subject: [PATCH 06/11] aviod multiple array lookup --- .../Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 9069f0c7b..a30e45dde 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -156,9 +156,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc double[][] values = new double[channelCount][]; for (int i = 0; i < channelCount; i++) { - values[i] = new double[2]; - values[i][0] = this.ReadUFix16(); - values[i][1] = this.ReadUFix16(); + values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; } return new IccChromaticityTagDataEntry(values); From bcbd4726a6551dae20f758b6bee9ea0f18f2afa8 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 14 Aug 2019 10:40:16 +1000 Subject: [PATCH 07/11] use var where apparent (#972) * use var where apparent * use var where apparent * should use Rgb24 --- README.md | 2 +- .../Processing/DrawingHelpers.cs | 4 +- .../Common/Extensions/StreamExtensions.cs | 4 +- .../Helpers/SimdUtils.BasicIntrinsics256.cs | 12 +- .../Helpers/SimdUtils.ExtendedIntrinsics.cs | 6 +- src/ImageSharp/Common/Helpers/SimdUtils.cs | 6 +- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 20 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 4 +- src/ImageSharp/Formats/Gif/LzwDecoder.cs | 6 +- .../Formats/Jpeg/Components/Block8x8.cs | 4 +- .../Jpeg/Components/Block8x8F.Generated.cs | 12 +- .../Jpeg/Components/Block8x8F.Generated.tt | 20 +- .../Formats/Jpeg/Components/Block8x8F.cs | 6 +- .../Formats/Jpeg/JpegDecoderCore.cs | 6 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 6 +- .../ImageFrameCollection{TPixel}.cs | 2 +- .../MetaData/Profiles/Exif/ExifWriter.cs | 2 +- .../ICC/DataReader/IccDataReader.Curves.cs | 14 +- .../ICC/DataReader/IccDataReader.Lut.cs | 14 +- .../ICC/DataReader/IccDataReader.Matrix.cs | 6 +- .../IccDataReader.MultiProcessElement.cs | 4 +- .../DataReader/IccDataReader.NonPrimitives.cs | 4 +- .../DataReader/IccDataReader.Primitives.cs | 4 +- .../DataReader/IccDataReader.TagDataEntry.cs | 28 +- .../DataWriter/IccDataWriter.TagDataEntry.cs | 6 +- .../MetaData/Profiles/ICC/IccProfile.cs | 8 +- .../IccTextDescriptionTagDataEntry.cs | 6 +- .../DefaultPixelBlenders.Generated.cs | 1084 ++++++++--------- .../DefaultPixelBlenders.Generated.tt | 20 +- .../PorterDuffFunctions.Generated.cs | 130 +- .../PorterDuffFunctions.Generated.tt | 20 +- .../PixelImplementations/HalfVector2.cs | 6 +- .../PixelImplementations/NormalizedByte2.cs | 6 +- .../PixelImplementations/NormalizedShort2.cs | 6 +- .../PixelImplementations/Short2.cs | 6 +- src/ImageSharp/Primitives/Rational.cs | 6 +- src/ImageSharp/Primitives/SignedRational.cs | 6 +- .../Extensions/ProcessingExtensions.cs | 6 +- .../Effects/OilPaintingProcessor{TPixel}.cs | 10 +- .../Quantization/PaletteQuantizer.cs | 8 +- .../Quantization/WuFrameQuantizer{TPixel}.cs | 6 +- .../Codecs/Jpeg/DoubleBufferedStreams.cs | 4 +- .../Codecs/Jpeg/YCbCrColorConversion.cs | 8 +- .../ImageSharp.Benchmarks/Color/RgbToYCbCr.cs | 32 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 8 +- .../General/Vectorization/BitwiseOrUint32.cs | 6 +- .../General/Vectorization/MulFloat.cs | 8 +- .../General/Vectorization/MulUInt32.cs | 4 +- .../Vectorization/ReinterpretUInt32AsFloat.cs | 4 +- .../General/Vectorization/VectorFetching.cs | 10 +- .../Color/ColorTests.CastFrom.cs | 36 +- .../Color/ColorTests.CastTo.cs | 48 +- .../Color/ColorTests.ConstructFrom.cs | 48 +- tests/ImageSharp.Tests/Color/ColorTests.cs | 24 +- .../ImageSharp.Tests/Colorspaces/RgbTests.cs | 2 +- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 22 +- .../Drawing/DrawImageTests.cs | 10 +- .../ImageSharp.Tests/Drawing/DrawPathTests.cs | 8 +- .../Drawing/FillPolygonTests.cs | 40 +- .../Drawing/FillSolidBrushTests.cs | 4 +- .../Drawing/Text/DrawTextOnImageTests.cs | 12 +- .../Formats/Bmp/BmpFileHeaderTests.cs | 6 +- .../Formats/Jpg/Block8x8FTests.cs | 20 +- .../ImageSharp.Tests/Formats/Jpg/DCTTests.cs | 22 +- .../Formats/Jpg/Utils/JpegFixture.cs | 14 +- .../Formats/Jpg/Utils/LibJpegTools.cs | 2 +- .../ReferenceImplementations.AccurateDCT.cs | 2 +- ...ceImplementations.LLM_FloatingPoint_DCT.cs | 16 +- ...renceImplementations.StandardIntegerDCT.cs | 6 +- .../Formats/Jpg/Utils/SpanExtensions.cs | 6 +- .../Formats/Jpg/ZigZagTests.cs | 2 +- .../Formats/Png/PngDecoderTests.Chunks.cs | 6 +- .../Helpers/ParallelHelperTests.cs | 4 +- .../Helpers/RowIntervalTests.cs | 28 +- .../IO/DoubleBufferedStreamReaderTests.cs | 8 +- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 6 +- .../ImageFrameCollectionTests.NonGeneric.cs | 18 +- .../ImageSharp.Tests/Image/ImageSaveTests.cs | 8 +- ...s.Load_FromBytes_PassLocalConfiguration.cs | 20 +- ....Load_FromStream_PassLocalConfiguration.cs | 22 +- .../ImageSharp.Tests/Image/ImageTests.Save.cs | 2 +- tests/ImageSharp.Tests/ImageOperationTests.cs | 4 +- .../ImageSharp.Tests/Memory/Buffer2DTests.cs | 12 +- .../Memory/BufferAreaTests.cs | 6 +- .../MetaData/Profiles/ICC/IccProfileTests.cs | 2 +- .../MetaData/Profiles/ICC/IccWriterTests.cs | 6 +- .../PixelOperations/PixelOperationsTests.cs | 22 +- .../PixelFormats/Rgba64Tests.cs | 88 +- .../HistogramEqualizationTests.cs | 4 +- .../Processors/Transforms/AutoOrientTests.cs | 6 +- .../Processors/Transforms/PadTest.cs | 6 +- ...ResizeKernelMapTests.ReferenceKernelMap.cs | 6 +- .../Attributes/ImageDataAttributeBase.cs | 4 +- .../ImageProviders/TestPatternProvider.cs | 2 +- .../TestUtilities/TestDataGenerator.cs | 12 +- 95 files changed, 1082 insertions(+), 1190 deletions(-) diff --git a/README.md b/README.md index 3c343ad13..078219183 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; // Individual pixels -using (Image image = new Image(400, 400)) +using (var image = new Image(400, 400)) { image[200, 200] = Rgba32.White; } diff --git a/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs b/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs index b4ce0c5cb..25a8204f2 100644 --- a/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs +++ b/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs @@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Processing public static DenseMatrix ToPixelMatrix(this DenseMatrix colorMatrix, Configuration configuration) where TPixel : struct, IPixel { - DenseMatrix result = new DenseMatrix(colorMatrix.Columns, colorMatrix.Rows); + var result = new DenseMatrix(colorMatrix.Columns, colorMatrix.Rows); Color.ToPixel(configuration, colorMatrix.Span, result.Span); return result; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Common/Extensions/StreamExtensions.cs b/src/ImageSharp/Common/Extensions/StreamExtensions.cs index 505ecccdd..6af09b220 100644 --- a/src/ImageSharp/Common/Extensions/StreamExtensions.cs +++ b/src/ImageSharp/Common/Extensions/StreamExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp } else { - byte[] foo = new byte[count]; + var foo = new byte[count]; while (count > 0) { int bytesRead = stream.Read(foo, 0, count); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs b/src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs index b16bbc86b..5aa0b21ec 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -138,8 +138,8 @@ namespace SixLabors.ImageSharp ref Octet.OfByte destBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 8; - Vector magick = new Vector(32768.0f); - Vector scale = new Vector(255f) / new Vector(256f); + var magick = new Vector(32768.0f); + var scale = new Vector(255f) / new Vector(256f); // need to copy to a temporary struct, because // SimdUtils.Octet.OfUInt32 temp = Unsafe.As, SimdUtils.Octet.OfUInt32>(ref x) @@ -187,8 +187,8 @@ namespace SixLabors.ImageSharp ref Octet.OfByte destBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 8; - Vector magick = new Vector(32768.0f); - Vector scale = new Vector(255f) / new Vector(256f); + var magick = new Vector(32768.0f); + var scale = new Vector(255f) / new Vector(256f); // need to copy to a temporary struct, because // SimdUtils.Octet.OfUInt32 temp = Unsafe.As, SimdUtils.Octet.OfUInt32>(ref x) @@ -211,4 +211,4 @@ namespace SixLabors.ImageSharp } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs index 83216aaa7..7baa788e4 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector ConvertToUInt32(Vector vf) { - Vector maxBytes = new Vector(255f); + var maxBytes = new Vector(255f); vf *= maxBytes; vf += new Vector(0.5f); vf = Vector.Min(Vector.Max(vf, Vector.Zero), maxBytes); @@ -190,4 +190,4 @@ namespace SixLabors.ImageSharp } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 45761a0d0..4c34e28bc 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Vector FastRound(this Vector v) { - Vector magic0 = new Vector(int.MinValue); // 0x80000000 + var magic0 = new Vector(int.MinValue); // 0x80000000 Vector sgn0 = Vector.AsVectorSingle(magic0); Vector and0 = Vector.BitwiseAnd(sgn0, v); Vector or0 = Vector.BitwiseOr(and0, new Vector(8388608.0f)); @@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp $"length should be divisible by {shouldBeDivisibleBy}!"); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 906fc53fe..b7733e026 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -446,7 +446,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span cmd = stackalloc byte[2]; #else - byte[] cmd = new byte[2]; + var cmd = new byte[2]; #endif int count = 0; @@ -485,7 +485,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp int max = cmd[1]; int bytesToRead = (max + 1) / 2; - byte[] run = new byte[bytesToRead]; + var run = new byte[bytesToRead]; this.stream.Read(run, 0, run.Length); @@ -557,7 +557,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span cmd = stackalloc byte[2]; #else - byte[] cmd = new byte[2]; + var cmd = new byte[2]; #endif int count = 0; @@ -595,7 +595,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp // Take this number of bytes from the stream as uncompressed data. int length = cmd[1]; - byte[] run = new byte[length]; + var run = new byte[length]; this.stream.Read(run, 0, run.Length); @@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span cmd = stackalloc byte[2]; #else - byte[] cmd = new byte[2]; + var cmd = new byte[2]; #endif int uncompressedPixels = 0; @@ -678,7 +678,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp // Take this number of bytes from the stream as uncompressed data. int length = cmd[1]; - byte[] run = new byte[length * 3]; + var run = new byte[length * 3]; this.stream.Read(run, 0, run.Length); @@ -1214,7 +1214,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span buffer = stackalloc byte[BmpInfoHeader.MaxHeaderSize]; #else - byte[] buffer = new byte[BmpInfoHeader.MaxHeaderSize]; + var buffer = new byte[BmpInfoHeader.MaxHeaderSize]; #endif // Read the header size. @@ -1252,7 +1252,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp // color masks for each color channel follow the info header. if (this.infoHeader.Compression == BmpCompression.BitFields) { - byte[] bitfieldsBuffer = new byte[12]; + var bitfieldsBuffer = new byte[12]; this.stream.Read(bitfieldsBuffer, 0, 12); Span data = bitfieldsBuffer.AsSpan(); this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4)); @@ -1261,7 +1261,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp } else if (this.infoHeader.Compression == BmpCompression.BI_ALPHABITFIELDS) { - byte[] bitfieldsBuffer = new byte[16]; + var bitfieldsBuffer = new byte[16]; this.stream.Read(bitfieldsBuffer, 0, 16); Span data = bitfieldsBuffer.AsSpan(); this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4)); @@ -1340,7 +1340,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span buffer = stackalloc byte[BmpFileHeader.Size]; #else - byte[] buffer = new byte[BmpFileHeader.Size]; + var buffer = new byte[BmpFileHeader.Size]; #endif this.stream.Read(buffer, 0, BmpFileHeader.Size); diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 4e6ec4502..a5e1ee5db 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp #if NETCOREAPP2_1 Span buffer = stackalloc byte[infoHeaderSize]; #else - byte[] buffer = new byte[infoHeaderSize]; + var buffer = new byte[infoHeaderSize]; #endif fileHeader.WriteTo(buffer); diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 07594e81a..af390e954 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Formats.Gif #if NETCOREAPP2_1 Span buffer = stackalloc byte[255]; #else - byte[] buffer = new byte[255]; + var buffer = new byte[255]; #endif while (xyz < length) @@ -253,4 +253,4 @@ namespace SixLabors.ImageSharp.Formats.Gif this.pixelStack.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 60fec25d2..0b69e3f8b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -194,7 +194,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components /// public short[] ToArray() { - short[] result = new short[Size]; + var result = new short[Size]; this.CopyTo(result); return result; } @@ -297,4 +297,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components return result; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs index a9e9903a9..23b51f092 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -95,9 +95,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components /// public void NormalizeColorsInplace(float maximum) { - Vector4 CMin4 = new Vector4(0F); - Vector4 CMax4 = new Vector4(maximum); - Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2)); + var CMin4 = new Vector4(0F); + var CMax4 = new Vector4(maximum); + var COff4 = new Vector4(MathF.Ceiling(maximum / 2)); this.V0L = Vector4.Clamp(this.V0L + COff4, CMin4, CMax4); this.V0R = Vector4.Clamp(this.V0R + COff4, CMin4, CMax4); @@ -123,8 +123,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInplaceAvx2(float maximum) { - Vector off = new Vector(MathF.Ceiling(maximum / 2)); - Vector max = new Vector(maximum); + var off = new Vector(MathF.Ceiling(maximum / 2)); + var max = new Vector(maximum); ref Vector row0 = ref Unsafe.As>(ref this.V0L); row0 = NormalizeAndRound(row0, off, max); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt index d6c42a802..176591972 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt @@ -1,4 +1,4 @@ -<# +<# // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #> @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components char srcCoord = coordz[j % 4]; char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R'; - string expression = $"d.V{j}{destSide}.{destCoord} = V{i}{srcSide}.{srcCoord};\r\n"; + var expression = $"d.V{j}{destSide}.{destCoord} = V{i}{srcSide}.{srcCoord};\r\n"; Write(expression); } } @@ -60,9 +60,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components /// public void NormalizeColorsInplace(float maximum) { - Vector4 CMin4 = new Vector4(0F); - Vector4 CMax4 = new Vector4(maximum); - Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2)); + var CMin4 = new Vector4(0F); + var CMax4 = new Vector4(maximum); + var COff4 = new Vector4(MathF.Ceiling(maximum / 2)); <# @@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInplaceAvx2(float maximum) { - Vector off = new Vector(MathF.Ceiling(maximum / 2)); - Vector max = new Vector(maximum); + var off = new Vector(MathF.Ceiling(maximum / 2)); + var max = new Vector(maximum); <# for (int i = 0; i < 8; i++) @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components { char destCoord = coordz[i % 4]; char destSide = (i / 4) % 2 == 0 ? 'L' : 'R'; - + if(j > 0 && i == 0){ WriteLine(""); } @@ -125,9 +125,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components char srcCoord = coordz[j % 4]; char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R'; - string expression = $"this.V{j}{destSide}.{destCoord} = Unsafe.Add(ref selfRef, {j*8+i});\r\n"; + var expression = $"this.V{j}{destSide}.{destCoord} = Unsafe.Add(ref selfRef, {j*8+i});\r\n"; Write(expression); - + } } PopIndent(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index 0e19d6f98..f11b0f8fa 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components { fixed (Vector4* ptr = &this.V0L) { - float* fp = (float*)ptr; + var fp = (float*)ptr; for (int i = 0; i < Size; i++) { dest[i] = (int)fp[i]; @@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public float[] ToArray() { - float[] result = new float[Size]; + var result = new float[Size]; this.CopyTo(result); return result; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index bf7c8f9c8..c15fe5e27 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -538,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg return; } - byte[] profile = new byte[remaining]; + var profile = new byte[remaining]; this.InputStream.Read(profile, 0, remaining); if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) @@ -571,14 +571,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg return; } - byte[] identifier = new byte[Icclength]; + var identifier = new byte[Icclength]; this.InputStream.Read(identifier, 0, Icclength); remaining -= Icclength; // We have read it by this point if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker)) { this.isIcc = true; - byte[] profile = new byte[remaining]; + var profile = new byte[remaining]; this.InputStream.Read(profile, 0, remaining); if (this.iccData is null) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index c7ffc46a7..9bc5a5079 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -183,12 +183,12 @@ namespace SixLabors.ImageSharp.Formats.Png break; case PngChunkType.Palette: - byte[] pal = new byte[chunk.Length]; + var pal = new byte[chunk.Length]; Buffer.BlockCopy(chunk.Data.Array, 0, pal, 0, chunk.Length); this.palette = pal; break; case PngChunkType.Transparency: - byte[] alpha = new byte[chunk.Length]; + var alpha = new byte[chunk.Length]; Buffer.BlockCopy(chunk.Data.Array, 0, alpha, 0, chunk.Length); this.paletteAlpha = alpha; this.AssignTransparentMarkers(alpha, pngMetadata); @@ -205,7 +205,7 @@ namespace SixLabors.ImageSharp.Formats.Png case PngChunkType.Exif: if (!this.ignoreMetadata) { - byte[] exifData = new byte[chunk.Length]; + var exifData = new byte[chunk.Length]; Buffer.BlockCopy(chunk.Data.Array, 0, exifData, 0, chunk.Length); metadata.ExifProfile = new ExifProfile(exifData); } diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index ffd7225bd..893a7a4a8 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -347,7 +347,7 @@ namespace SixLabors.ImageSharp private ImageFrame CopyNonCompatibleFrame(ImageFrame source) { - ImageFrame result = new ImageFrame( + var result = new ImageFrame( this.parent.GetConfiguration(), source.Size(), source.Metadata.DeepClone()); diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index 77af1717d..67c1b2b65 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif length += 4 + 2; - byte[] result = new byte[length]; + var result = new byte[length]; int i = 0; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 111911080..58ca46d81 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -18,13 +18,13 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { ushort segmentCount = this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved - float[] breakPoints = new float[segmentCount - 1]; + var breakPoints = new float[segmentCount - 1]; for (int i = 0; i < breakPoints.Length; i++) { breakPoints[i] = this.ReadSingle(); } - IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; + var segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); @@ -41,19 +41,19 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccResponseCurve ReadResponseCurve(int channelCount) { var type = (IccCurveMeasurementEncodings)this.ReadUInt32(); - uint[] measurement = new uint[channelCount]; + var measurement = new uint[channelCount]; for (int i = 0; i < channelCount; i++) { measurement[i] = this.ReadUInt32(); } - Vector3[] xyzValues = new Vector3[channelCount]; + var xyzValues = new Vector3[channelCount]; for (int i = 0; i < channelCount; i++) { xyzValues[i] = this.ReadXyzNumber(); } - IccResponseNumber[][] response = new IccResponseNumber[channelCount][]; + var response = new IccResponseNumber[channelCount][]; for (int i = 0; i < channelCount; i++) { response[i] = new IccResponseNumber[measurement[i]]; @@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccSampledCurveElement ReadSampledCurveElement() { uint count = this.ReadUInt32(); - float[] entries = new float[count]; + var entries = new float[count]; for (int i = 0; i < count; i++) { entries[i] = this.ReadSingle(); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs index 5262e3ee9..0aa3c31e0 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The read LUT public IccLut ReadLut16(int count) { - ushort[] values = new ushort[count]; + var values = new ushort[count]; for (int i = 0; i < count; i++) { values[i] = this.ReadUInt16(); @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) { // Grid-points are always 16 bytes long but only 0-inChCount are used - byte[] gridPointCount = new byte[inChannelCount]; + var gridPointCount = new byte[inChannelCount]; Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount); if (!isFloat) @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const float Max = byte.MaxValue; - float[][] values = new float[length][]; + var values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChannelCount]; @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const float Max = ushort.MaxValue; - float[][] values = new float[length][]; + var values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChannelCount]; @@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc length /= inChCount; - float[][] values = new float[length][]; + var values = new float[length][]; for (int i = 0; i < length; i++) { values[i] = new float[outChCount]; @@ -168,4 +168,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc return new IccClut(values, gridPointCount, IccClutDataType.Float); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs index 3157b9ef3..ecc33dd77 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The read matrix public float[,] ReadMatrix(int xCount, int yCount, bool isSingle) { - float[,] matrix = new float[xCount, yCount]; + var matrix = new float[xCount, yCount]; for (int y = 0; y < yCount; y++) { for (int x = 0; x < xCount; x++) @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The read matrix public float[] ReadMatrix(int yCount, bool isSingle) { - float[] matrix = new float[yCount]; + var matrix = new float[yCount]; for (int i = 0; i < yCount; i++) { if (isSingle) diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index 425305828..b854247da 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The read public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount) { - IccOneDimensionalCurve[] curves = new IccOneDimensionalCurve[inChannelCount]; + var curves = new IccOneDimensionalCurve[inChannelCount]; for (int i = 0; i < inChannelCount; i++) { curves[i] = this.ReadOneDimensionalCurve(); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index aacbbcc1d..b5326225c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { string name = this.ReadAsciiString(32); ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; - ushort[] deviceCoord = new ushort[deviceCoordCount]; + var deviceCoord = new ushort[deviceCoordCount]; for (int i = 0; i < deviceCoordCount; i++) { diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 2cbf798ec..3f016444b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc /// The read bytes public byte[] ReadBytes(int count) { - byte[] bytes = new byte[count]; + var bytes = new byte[count]; Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count); return bytes; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index a30e45dde..a0ee1d5e5 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc else { // The type is not know, so the values need be read - double[][] values = new double[channelCount][]; + var values = new double[channelCount][]; for (int i = 0; i < channelCount; i++) { values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc return new IccCurveTagDataEntry(this.ReadUFix8()); } - float[] cdata = new float[pointCount]; + var cdata = new float[pointCount]; for (int i = 0; i < pointCount; i++) { cdata[i] = this.ReadUInt16() / 65535f; @@ -264,7 +264,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc // Input LUT var inValues = new IccLut[inChCount]; - byte[] gridPointCount = new byte[inChCount]; + var gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { inValues[i] = this.ReadLut16(inTableCount); @@ -299,7 +299,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc // Input LUT var inValues = new IccLut[inChCount]; - byte[] gridPointCount = new byte[inChCount]; + var gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { inValues[i] = this.ReadLut8(); @@ -464,8 +464,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc var text = new IccLocalizedString[recordCount]; var culture = new CultureInfo[recordCount]; - uint[] length = new uint[recordCount]; - uint[] offset = new uint[recordCount]; + var length = new uint[recordCount]; + var offset = new uint[recordCount]; for (int i = 0; i < recordCount; i++) { @@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc ushort channelCount = this.ReadUInt16(); ushort measurementCount = this.ReadUInt16(); - uint[] offset = new uint[measurementCount]; + var offset = new uint[measurementCount]; for (int i = 0; i < measurementCount; i++) { offset[i] = this.ReadUInt32(); @@ -651,7 +651,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; - float[] arrayData = new float[count]; + var arrayData = new float[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadFix16() / 256f; @@ -687,7 +687,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; - float[] arrayData = new float[count]; + var arrayData = new float[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadUFix16(); @@ -704,7 +704,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size) { uint count = (size - 8) / 2; - ushort[] arrayData = new ushort[count]; + var arrayData = new ushort[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadUInt16(); @@ -721,7 +721,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size) { uint count = (size - 8) / 4; - uint[] arrayData = new uint[count]; + var arrayData = new uint[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadUInt32(); @@ -738,7 +738,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size) { uint count = (size - 8) / 8; - ulong[] arrayData = new ulong[count]; + var arrayData = new ulong[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadUInt64(); @@ -878,14 +878,14 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size) { uint ucrCount = this.ReadUInt32(); - ushort[] ucrCurve = new ushort[ucrCount]; + var ucrCurve = new ushort[ucrCount]; for (int i = 0; i < ucrCurve.Length; i++) { ucrCurve[i] = this.ReadUInt16(); } uint bgCount = this.ReadUInt32(); - ushort[] bgCurve = new ushort[bgCount]; + var bgCurve = new ushort[bgCount]; for (int i = 0; i < bgCurve.Length; i++) { bgCurve[i] = this.ReadUInt16(); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 18f3fa15a..b761f48ba 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -560,8 +560,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc // TODO: Investigate cost of Linq GroupBy IGrouping[] texts = value.Texts.GroupBy(t => t.Text).ToArray(); - uint[] offset = new uint[texts.Length]; - int[] lengths = new int[texts.Length]; + var offset = new uint[texts.Length]; + var lengths = new int[texts.Length]; for (int i = 0; i < texts.Length; i++) { @@ -746,7 +746,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc long tablePosition = this.dataStream.Position; this.dataStream.Position += value.Curves.Length * 4; - uint[] offset = new uint[value.Curves.Length]; + var offset = new uint[value.Curves.Length]; for (int i = 0; i < value.Curves.Length; i++) { diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs index afdd7ebfb..7c5139475 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc const int profileIdPos = 84; // need to copy some values because they need to be zero for the hashing - byte[] temp = new byte[24]; + var temp = new byte[24]; Buffer.BlockCopy(data, profileFlagPos, temp, 0, 4); Buffer.BlockCopy(data, renderingIntentPos, temp, 4, 4); Buffer.BlockCopy(data, profileIdPos, temp, 8, 16); @@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc { if (this.data != null) { - byte[] copy = new byte[this.data.Length]; + var copy = new byte[this.data.Length]; Buffer.BlockCopy(this.data, 0, copy, 0, copy.Length); return copy; } @@ -216,4 +216,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc this.entries = reader.ReadTagData(this.data); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs index 4134779c3..23e81fe99 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc && p3 >= 0x41 && p3 <= 0x5A && p4 >= 0x41 && p4 <= 0x5A) { - string culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); + var culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); return new CultureInfo(culture); } @@ -175,4 +175,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc this.ScriptCodeCode); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 0cf8d6bbb..e94ea452b 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // @@ -38,26 +38,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -73,26 +73,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplySrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -108,26 +108,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -143,26 +143,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -178,26 +178,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -213,26 +213,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -248,26 +248,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -283,26 +283,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlaySrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -318,26 +318,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightSrc(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrc(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -353,26 +353,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -388,26 +388,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -423,26 +423,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -458,26 +458,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -493,26 +493,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -528,26 +528,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -563,26 +563,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -598,26 +598,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -633,26 +633,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -668,26 +668,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -703,26 +703,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -738,26 +738,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -773,26 +773,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -808,26 +808,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -843,26 +843,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -878,26 +878,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -913,26 +913,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -948,26 +948,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -983,26 +983,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1018,26 +1018,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1053,26 +1053,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1088,26 +1088,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1123,26 +1123,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1158,26 +1158,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1193,26 +1193,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1228,26 +1228,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1263,26 +1263,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1298,26 +1298,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1333,26 +1333,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplySrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1368,26 +1368,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1403,26 +1403,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1438,26 +1438,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1473,26 +1473,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1508,26 +1508,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1543,26 +1543,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlaySrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlaySrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1578,26 +1578,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightSrcOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightSrcOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1613,26 +1613,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1648,26 +1648,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1683,26 +1683,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1718,26 +1718,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1753,26 +1753,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1788,26 +1788,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1823,26 +1823,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1858,26 +1858,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1893,26 +1893,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightDest(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDest(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDest(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1928,26 +1928,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1963,26 +1963,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -1998,26 +1998,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2033,26 +2033,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2068,26 +2068,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2103,26 +2103,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2138,26 +2138,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2173,26 +2173,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2208,26 +2208,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightDestAtop(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestAtop(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestAtop(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2243,26 +2243,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2278,26 +2278,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2313,26 +2313,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2348,26 +2348,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2383,26 +2383,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2418,26 +2418,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2453,26 +2453,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2488,26 +2488,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2523,26 +2523,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOver(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOver(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOver(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2558,26 +2558,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2593,26 +2593,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2628,26 +2628,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2663,26 +2663,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2698,26 +2698,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2733,26 +2733,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2768,26 +2768,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2803,26 +2803,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2838,26 +2838,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightDestIn(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestIn(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestIn(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2873,26 +2873,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2908,26 +2908,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2943,26 +2943,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -2978,26 +2978,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3013,26 +3013,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3048,26 +3048,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3083,26 +3083,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3118,26 +3118,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3153,26 +3153,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightDestOut(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOut(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightDestOut(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3188,26 +3188,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3223,26 +3223,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3258,26 +3258,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3293,26 +3293,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3328,26 +3328,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3363,26 +3363,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3398,26 +3398,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3433,26 +3433,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3468,26 +3468,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightClear(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightClear(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightClear(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3503,26 +3503,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.NormalXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.NormalXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3538,26 +3538,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.MultiplyXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.MultiplyXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3573,26 +3573,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.AddXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.AddXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3608,26 +3608,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.SubtractXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.SubtractXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3643,26 +3643,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.ScreenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.ScreenXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3678,26 +3678,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.DarkenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.DarkenXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3713,26 +3713,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.LightenXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.LightenXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3748,26 +3748,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.OverlayXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.OverlayXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -3783,28 +3783,28 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.HardLightXor(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightXor(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.HardLightXor(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 2cca55e4c..66a00975e 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -1,4 +1,4 @@ -<# +<# // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #> @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { <# - string[] composers = new []{ + var composers = new []{ "Src", "SrcAtop", "SrcOver", @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders "Xor", }; - string[] blenders = new []{ + var blenders = new []{ "Normal", "Multiply", "Add", @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders foreach(var composer in composers) { foreach(var blender in blenders) { - string blender_composer= $"{blender}{composer}"; + var blender_composer= $"{blender}{composer}"; #> internal class <#= blender_composer#> : PixelBlender @@ -82,26 +82,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { TPixel dest = default; dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); - return dest; + return dest; } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, float amount) { amount = amount.Clamp(0, 1); for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount); - } + } } /// - protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) + protected override void BlendFunction(Span destination, ReadOnlySpan background, ReadOnlySpan source, ReadOnlySpan amount) { for (int i = 0; i < destination.Length; i++) { destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1)); - } + } } } @@ -111,4 +111,4 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders #> } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index a99deb535..8b92f95c3 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity) @@ -110,7 +110,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrc(TPixel backdrop, TPixel source, float opacity) @@ -122,7 +121,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -134,7 +132,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -146,7 +143,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -158,7 +154,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -170,7 +165,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDest(TPixel backdrop, TPixel source, float opacity) @@ -182,7 +176,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -194,7 +187,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestOver(TPixel backdrop, TPixel source, float opacity) @@ -206,7 +198,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestIn(TPixel backdrop, TPixel source, float opacity) @@ -218,7 +209,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalDestOut(TPixel backdrop, TPixel source, float opacity) @@ -230,7 +220,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalClear(TPixel backdrop, TPixel source, float opacity) @@ -242,7 +231,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel NormalXor(TPixel backdrop, TPixel source, float opacity) @@ -339,7 +327,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity) @@ -348,7 +336,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrc(TPixel backdrop, TPixel source, float opacity) @@ -360,7 +347,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -372,7 +358,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcOver(TPixel backdrop, TPixel source, float opacity) @@ -384,7 +369,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcIn(TPixel backdrop, TPixel source, float opacity) @@ -396,7 +380,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplySrcOut(TPixel backdrop, TPixel source, float opacity) @@ -408,7 +391,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDest(TPixel backdrop, TPixel source, float opacity) @@ -420,7 +402,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -432,7 +413,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestOver(TPixel backdrop, TPixel source, float opacity) @@ -444,7 +424,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestIn(TPixel backdrop, TPixel source, float opacity) @@ -456,7 +435,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyDestOut(TPixel backdrop, TPixel source, float opacity) @@ -468,7 +446,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyClear(TPixel backdrop, TPixel source, float opacity) @@ -480,7 +457,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel MultiplyXor(TPixel backdrop, TPixel source, float opacity) @@ -577,7 +553,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity) @@ -586,7 +562,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrc(TPixel backdrop, TPixel source, float opacity) @@ -598,7 +573,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -610,7 +584,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -622,7 +595,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -634,7 +606,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -646,7 +617,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDest(TPixel backdrop, TPixel source, float opacity) @@ -658,7 +628,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -670,7 +639,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestOver(TPixel backdrop, TPixel source, float opacity) @@ -682,7 +650,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestIn(TPixel backdrop, TPixel source, float opacity) @@ -694,7 +661,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddDestOut(TPixel backdrop, TPixel source, float opacity) @@ -706,7 +672,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddClear(TPixel backdrop, TPixel source, float opacity) @@ -718,7 +683,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel AddXor(TPixel backdrop, TPixel source, float opacity) @@ -815,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity) @@ -824,7 +788,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrc(TPixel backdrop, TPixel source, float opacity) @@ -836,7 +799,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -848,7 +810,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -860,7 +821,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -872,7 +832,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -884,7 +843,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDest(TPixel backdrop, TPixel source, float opacity) @@ -896,7 +854,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -908,7 +865,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestOver(TPixel backdrop, TPixel source, float opacity) @@ -920,7 +876,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestIn(TPixel backdrop, TPixel source, float opacity) @@ -932,7 +887,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractDestOut(TPixel backdrop, TPixel source, float opacity) @@ -944,7 +898,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractClear(TPixel backdrop, TPixel source, float opacity) @@ -956,7 +909,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel SubtractXor(TPixel backdrop, TPixel source, float opacity) @@ -1053,7 +1005,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity) @@ -1062,7 +1014,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrc(TPixel backdrop, TPixel source, float opacity) @@ -1074,7 +1025,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -1086,7 +1036,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -1098,7 +1047,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -1110,7 +1058,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -1122,7 +1069,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDest(TPixel backdrop, TPixel source, float opacity) @@ -1134,7 +1080,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -1146,7 +1091,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestOver(TPixel backdrop, TPixel source, float opacity) @@ -1158,7 +1102,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestIn(TPixel backdrop, TPixel source, float opacity) @@ -1170,7 +1113,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenDestOut(TPixel backdrop, TPixel source, float opacity) @@ -1182,7 +1124,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenClear(TPixel backdrop, TPixel source, float opacity) @@ -1194,7 +1135,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel ScreenXor(TPixel backdrop, TPixel source, float opacity) @@ -1291,7 +1231,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity) @@ -1300,7 +1240,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrc(TPixel backdrop, TPixel source, float opacity) @@ -1312,7 +1251,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -1324,7 +1262,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -1336,7 +1273,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -1348,7 +1284,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -1360,7 +1295,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDest(TPixel backdrop, TPixel source, float opacity) @@ -1372,7 +1306,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -1384,7 +1317,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestOver(TPixel backdrop, TPixel source, float opacity) @@ -1396,7 +1328,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestIn(TPixel backdrop, TPixel source, float opacity) @@ -1408,7 +1339,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenDestOut(TPixel backdrop, TPixel source, float opacity) @@ -1420,7 +1350,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenClear(TPixel backdrop, TPixel source, float opacity) @@ -1432,7 +1361,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel DarkenXor(TPixel backdrop, TPixel source, float opacity) @@ -1529,7 +1457,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity) @@ -1538,7 +1466,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrc(TPixel backdrop, TPixel source, float opacity) @@ -1550,7 +1477,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -1562,7 +1488,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -1574,7 +1499,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -1586,7 +1510,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -1598,7 +1521,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDest(TPixel backdrop, TPixel source, float opacity) @@ -1610,7 +1532,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -1622,7 +1543,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestOver(TPixel backdrop, TPixel source, float opacity) @@ -1634,7 +1554,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestIn(TPixel backdrop, TPixel source, float opacity) @@ -1646,7 +1565,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenDestOut(TPixel backdrop, TPixel source, float opacity) @@ -1658,7 +1576,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenClear(TPixel backdrop, TPixel source, float opacity) @@ -1670,7 +1587,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel LightenXor(TPixel backdrop, TPixel source, float opacity) @@ -1767,7 +1683,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity) @@ -1776,7 +1692,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrc(TPixel backdrop, TPixel source, float opacity) @@ -1788,7 +1703,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -1800,7 +1714,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcOver(TPixel backdrop, TPixel source, float opacity) @@ -1812,7 +1725,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcIn(TPixel backdrop, TPixel source, float opacity) @@ -1824,7 +1736,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlaySrcOut(TPixel backdrop, TPixel source, float opacity) @@ -1836,7 +1747,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDest(TPixel backdrop, TPixel source, float opacity) @@ -1848,7 +1758,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -1860,7 +1769,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestOver(TPixel backdrop, TPixel source, float opacity) @@ -1872,7 +1780,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestIn(TPixel backdrop, TPixel source, float opacity) @@ -1884,7 +1791,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayDestOut(TPixel backdrop, TPixel source, float opacity) @@ -1896,7 +1802,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayClear(TPixel backdrop, TPixel source, float opacity) @@ -1908,7 +1813,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel OverlayXor(TPixel backdrop, TPixel source, float opacity) @@ -2005,7 +1909,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity) @@ -2014,7 +1918,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return Clear(backdrop, source); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrc(TPixel backdrop, TPixel source, float opacity) @@ -2026,7 +1929,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcAtop(TPixel backdrop, TPixel source, float opacity) @@ -2038,7 +1940,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcOver(TPixel backdrop, TPixel source, float opacity) @@ -2050,7 +1951,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcIn(TPixel backdrop, TPixel source, float opacity) @@ -2062,7 +1962,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightSrcOut(TPixel backdrop, TPixel source, float opacity) @@ -2074,7 +1973,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDest(TPixel backdrop, TPixel source, float opacity) @@ -2086,7 +1984,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestAtop(TPixel backdrop, TPixel source, float opacity) @@ -2098,7 +1995,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestOver(TPixel backdrop, TPixel source, float opacity) @@ -2110,7 +2006,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestIn(TPixel backdrop, TPixel source, float opacity) @@ -2122,7 +2017,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightDestOut(TPixel backdrop, TPixel source, float opacity) @@ -2134,7 +2028,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightClear(TPixel backdrop, TPixel source, float opacity) @@ -2146,7 +2039,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return dest; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLightXor(TPixel backdrop, TPixel source, float opacity) @@ -2159,4 +2051,4 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index c8345cfb9..f591ee873 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -1,4 +1,4 @@ -<# +<# // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #> @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders source.W *= opacity; return Xor(backdrop, source); - } + } [MethodImpl(MethodImplOptions.NoInlining)] public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity) @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders <# } #> -<# void GenerateGenericPixelBlender(string blender, string composer) { #> +<# void GenerateGenericPixelBlender(string blender, string composer) { #> [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel <#=blender#><#=composer#>(TPixel backdrop, TPixel source, float opacity) @@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders <# -string[] composers = new []{ +var composers = new []{ "Src", "SrcAtop", "SrcOver", @@ -156,7 +156,7 @@ string[] composers = new []{ "Xor", }; -string[] blenders = new []{ +var blenders = new []{ "Normal", "Multiply", "Add", @@ -166,12 +166,12 @@ string[] blenders = new []{ "Lighten", "Overlay", "HardLight" -}; +}; foreach(var blender in blenders) - { - GeneratePixelBlenders(blender); - + { + GeneratePixelBlenders(blender); + foreach(var composer in composers) { GenerateGenericPixelBlender(blender,composer); @@ -180,4 +180,4 @@ string[] blenders = new []{ #> } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs index e2ed931b7..8854f1650 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromScaledVector4(Vector4 vector) { - Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; + var scaled = new Vector2(vector.X, vector.Y) * 2F; scaled -= Vector2.One; this.PackedValue = Pack(scaled.X, scaled.Y); } @@ -173,4 +173,4 @@ namespace SixLabors.ImageSharp.PixelFormats return num2 | num; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index cd95e87ec..a24e72569 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromScaledVector4(Vector4 vector) { - Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; + var scaled = new Vector2(vector.X, vector.Y) * 2F; scaled -= Vector2.One; this.PackedValue = Pack(scaled); } @@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.PixelFormats return (ushort)(byte2 | byte1); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index 8d7c400b4..3ede94713 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromScaledVector4(Vector4 vector) { - Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; + var scaled = new Vector2(vector.X, vector.Y) * 2F; scaled -= Vector2.One; this.PackedValue = Pack(scaled); } @@ -186,4 +186,4 @@ namespace SixLabors.ImageSharp.PixelFormats return word2 | word1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 803a77b23..14987e582 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromScaledVector4(Vector4 vector) { - Vector2 scaled = new Vector2(vector.X, vector.Y) * 65534F; + var scaled = new Vector2(vector.X, vector.Y) * 65534F; scaled -= new Vector2(32767F); this.PackedValue = Pack(scaled); } @@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.PixelFormats return word2 | word1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Primitives/Rational.cs b/src/ImageSharp/Primitives/Rational.cs index b598f0e02..f9299bc17 100644 --- a/src/ImageSharp/Primitives/Rational.cs +++ b/src/ImageSharp/Primitives/Rational.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives { if (simplify) { - LongRational rational = new LongRational(numerator, denominator).Simplify(); + var rational = new LongRational(numerator, denominator).Simplify(); this.Numerator = (uint)rational.Numerator; this.Denominator = (uint)rational.Denominator; @@ -187,4 +187,4 @@ namespace SixLabors.ImageSharp.Primitives return rational.ToString(provider); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index 7e486e4f2..395a24b14 100644 --- a/src/ImageSharp/Primitives/SignedRational.cs +++ b/src/ImageSharp/Primitives/SignedRational.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives { if (simplify) { - LongRational rational = new LongRational(numerator, denominator).Simplify(); + var rational = new LongRational(numerator, denominator).Simplify(); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -187,4 +187,4 @@ namespace SixLabors.ImageSharp.Primitives return rational.ToString(provider); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs index cb3f8fa57..48876251e 100644 --- a/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing Guard.NotNull(operation, nameof(operation)); source.EnsureNotDisposed(); - ProcessingVisitor visitor = new ProcessingVisitor(operation, true); + var visitor = new ProcessingVisitor(operation, true); source.AcceptVisitor(visitor); } @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing Guard.NotNull(operation, nameof(operation)); source.EnsureNotDisposed(); - ProcessingVisitor visitor = new ProcessingVisitor(operation, false); + var visitor = new ProcessingVisitor(operation, false); source.AcceptVisitor(visitor); return visitor.ResultImage; } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 7efb71fa1..d31858ba1 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -69,10 +69,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects int maxIntensity = 0; int maxIndex = 0; - int[] intensityBin = new int[levels]; - float[] redBin = new float[levels]; - float[] blueBin = new float[levels]; - float[] greenBin = new float[levels]; + var intensityBin = new int[levels]; + var redBin = new float[levels]; + var blueBin = new float[levels]; + var greenBin = new float[levels]; for (int fy = 0; fy <= radius; fy++) { @@ -126,4 +126,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index ba434a4b2..17734bcdc 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization public IFrameQuantizer CreateFrameQuantizer(Configuration configuration) where TPixel : struct, IPixel { - TPixel[] palette = new TPixel[this.Palette.Length]; + var palette = new TPixel[this.Palette.Length]; Color.ToPixel(configuration, this.Palette.Span, palette.AsSpan()); return new PaletteFrameQuantizer(this.Diffuser, palette); } @@ -71,11 +71,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization maxColors = maxColors.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors); int max = Math.Min(maxColors, this.Palette.Length); - TPixel[] palette = new TPixel[max]; + var palette = new TPixel[max]; Color.ToPixel(configuration, this.Palette.Span.Slice(0, max), palette.AsSpan()); return new PaletteFrameQuantizer(this.Diffuser, palette); } private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null; } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs index 2b1a24aee..87d696dc9 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -828,7 +828,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization private void BuildCube() { this.colorCube = new Box[this.colors]; - double[] vv = new double[this.colors]; + var vv = new double[this.colors]; ref Box cube = ref this.colorCube[0]; cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0; @@ -985,4 +985,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs index b0834eb52..6f2c492d0 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg private static byte[] CreateTestBytes() { - byte[] buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; + var buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; var random = new Random(); random.NextBytes(buffer); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs index 8417b32f2..313a7c97d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -67,10 +67,10 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg float maxVal = 255f) { var rnd = new Random(42); - Buffer2D[] buffers = new Buffer2D[componentCount]; + var buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { - float[] values = new float[inputBufferLength]; + var values = new float[inputBufferLength]; for (int j = 0; j < inputBufferLength; j++) { @@ -84,4 +84,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg return buffers; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs index 5e3ba5d7b..0571513f5 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs @@ -132,13 +132,13 @@ namespace SixLabors.ImageSharp.Benchmarks public unsafe void RgbaToYcbCrScalarFloat() { // Copy the input to the stack: - OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); + var input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: Result result = default; - float* yPtr = (float*)&result.Y; - float* cbPtr = (float*)&result.Cb; - float* crPtr = (float*)&result.Cr; + var yPtr = (float*)&result.Y; + var cbPtr = (float*)&result.Cb; + var crPtr = (float*)&result.Cr; // end of code-bloat block :) for (int i = 0; i < InputColorCount; i++) @@ -158,20 +158,20 @@ namespace SixLabors.ImageSharp.Benchmarks public unsafe void RgbaToYcbCrSimdFloat() { // Copy the input to the stack: - OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); + var input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: Result result = default; - float* yPtr = (float*)&result.Y; - float* cbPtr = (float*)&result.Cb; - float* crPtr = (float*)&result.Cr; + var yPtr = (float*)&result.Y; + var cbPtr = (float*)&result.Cb; + var crPtr = (float*)&result.Cr; // end of code-bloat block :) for (int i = 0; i < InputColorCount; i++) { int i3 = i * 3; - Vector3 vectorRgb = new Vector3( + var vectorRgb = new Vector3( input.Data[i3 + 0], input.Data[i3 + 1], input.Data[i3 + 2] @@ -194,9 +194,9 @@ namespace SixLabors.ImageSharp.Benchmarks // On-stack output: Result result = default; - float* yPtr = (float*)&result.Y; - float* cbPtr = (float*)&result.Cb; - float* crPtr = (float*)&result.Cr; + var yPtr = (float*)&result.Y; + var cbPtr = (float*)&result.Cb; + var crPtr = (float*)&result.Cr; // end of code-bloat block :) var yCoeffs = new Vector(ScaledCoeffs.Y); @@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < InputColorCount; i += 2) { - Vector rgb = new Vector(this.inputSourceRGBAsInteger, i * 3); + var rgb = new Vector(this.inputSourceRGBAsInteger, i * 3); Vector y = yCoeffs * rgb; Vector cb = cbCoeffs * rgb; @@ -264,7 +264,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < InputColorCount; i += 2) { - Vector rgb = new Vector(this.inputSourceRGBAsInteger, i * 3); + var rgb = new Vector(this.inputSourceRGBAsInteger, i * 3); Vector y = yCoeffs * rgb; Vector cb = cbCoeffs * rgb; @@ -299,7 +299,7 @@ namespace SixLabors.ImageSharp.Benchmarks public unsafe void RgbaToYcbCrScaledInteger() { // Copy the input to the stack: - OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); + var input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: Result result = default; @@ -338,7 +338,7 @@ namespace SixLabors.ImageSharp.Benchmarks public unsafe void RgbaToYcbCrScaledIntegerLut() { // Copy the input to the stack: - OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); + var input = OnStackInputCache.Byte.Create(this.inputSourceRGB); // On-stack output: Result result = default; 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 3b288260c..cd0aed3c4 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -253,8 +253,8 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion private static void BitopsSimdImpl(ref Octet.OfUInt32 s, ref Octet.OfUInt32 d) { Vector sVec = Unsafe.As>(ref s); - Vector aMask = new Vector(0xFF00FF00); - Vector bMask = new Vector(0x00FF00FF); + var aMask = new Vector(0xFF00FF00); + var bMask = new Vector(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; @@ -388,4 +388,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion // Bitops_Tuple | 64 | 75.47 ns | 1.1824 ns | 1.1060 ns | 0.91 | 0.01 | // BitOps_GroupAsULong | 64 | 65.42 ns | 0.7157 ns | 0.6695 ns | 0.79 | 0.01 | } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs index 3afb796a7..60bf615c5 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -41,14 +41,14 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization [Benchmark] public void Simd() { - Vector v = new Vector(this.testValue); + var v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i+=Vector.Count) { - Vector a = new Vector(this.input, i); + var a = new Vector(this.input, i); a = Vector.BitwiseOr(a, v); a.CopyTo(this.result, i); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index 418209cbc..79207a9ff 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization [Benchmark] public void SimdMultiplyByVector() { - Vector v = new Vector(this.testValue); + var v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + var a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } @@ -58,10 +58,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + var a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs index 7253dbd6a..d837556f7 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -45,10 +45,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + var a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs index 67a8a9f39..19a1bcea4 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -53,10 +53,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization { for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + var a = new Vector(this.input, i); Vector b = Vector.AsVectorSingle(a); b.CopyTo(this.result, i); } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index f2dab02ef..4d83dd491 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -44,11 +44,11 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization [Benchmark] public void FetchWithVectorConstructor() { - Vector v = new Vector(this.testValue); + var v = new Vector(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - Vector a = new Vector(this.data, i); + var a = new Vector(this.data, i); a = a * v; a.CopyTo(this.data, i); } @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization [Benchmark] public void FetchWithUnsafeCast() { - Vector v = new Vector(this.testValue); + var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); int n = this.InputSize / Vector.Count; @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization [Benchmark] public void FetchWithUnsafeCastNoTempVector() { - Vector v = new Vector(this.testValue); + var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); int n = this.InputSize / Vector.Count; @@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs index 22c6d55ad..3fc4c5659 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs @@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Rgba64() { - Rgba64 source = new Rgba64(100, 2222, 3333, 4444); - + var source = new Rgba64(100, 2222, 3333, 4444); + // Act: Color color = source; @@ -23,12 +23,12 @@ namespace SixLabors.ImageSharp.Tests Rgba64 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Rgba32() { - Rgba32 source = new Rgba32(1, 22, 33, 231); - + var source = new Rgba32(1, 22, 33, 231); + // Act: Color color = source; @@ -36,12 +36,12 @@ namespace SixLabors.ImageSharp.Tests Rgba32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Argb32() { - Argb32 source = new Argb32(1, 22, 33, 231); - + var source = new Argb32(1, 22, 33, 231); + // Act: Color color = source; @@ -49,12 +49,12 @@ namespace SixLabors.ImageSharp.Tests Argb32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Bgra32() { - Bgra32 source = new Bgra32(1, 22, 33, 231); - + var source = new Bgra32(1, 22, 33, 231); + // Act: Color color = source; @@ -62,12 +62,12 @@ namespace SixLabors.ImageSharp.Tests Bgra32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Rgb24() { - Rgb24 source = new Rgb24(1, 22, 231); - + var source = new Rgb24(1, 22, 231); + // Act: Color color = source; @@ -75,12 +75,12 @@ namespace SixLabors.ImageSharp.Tests Rgb24 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Bgr24() { - Bgr24 source = new Bgr24(1, 22, 231); - + var source = new Bgr24(1, 22, 231); + // Act: Color color = source; @@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index d44472b28..fbd1c73f1 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs @@ -14,75 +14,75 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Rgba64() { - Rgba64 source = new Rgba64(100, 2222, 3333, 4444); - + var source = new Rgba64(100, 2222, 3333, 4444); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgba64 data = color; Assert.Equal(source, data); } - + [Fact] public void Rgba32() { - Rgba32 source = new Rgba32(1, 22, 33, 231); - + var source = new Rgba32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgba32 data = color; Assert.Equal(source, data); } - + [Fact] public void Argb32() { - Argb32 source = new Argb32(1, 22, 33, 231); - + var source = new Argb32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Argb32 data = color; Assert.Equal(source, data); } - + [Fact] public void Bgra32() { - Bgra32 source = new Bgra32(1, 22, 33, 231); - + var source = new Bgra32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Bgra32 data = color; Assert.Equal(source, data); } - + [Fact] public void Rgb24() { - Rgb24 source = new Rgb24(1, 22, 231); - + var source = new Rgb24(1, 22, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgb24 data = color; Assert.Equal(source, data); } - + [Fact] public void Bgr24() { - Bgr24 source = new Bgr24(1, 22, 231); - + var source = new Bgr24(1, 22, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Bgr24 data = color; @@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs b/tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs index 9d21cd80c..7f7c084e7 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs @@ -14,75 +14,75 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Rgba64() { - Rgba64 source = new Rgba64(100, 2222, 3333, 4444); - + var source = new Rgba64(100, 2222, 3333, 4444); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgba64 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Rgba32() { - Rgba32 source = new Rgba32(1, 22, 33, 231); - + var source = new Rgba32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgba32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Argb32() { - Argb32 source = new Argb32(1, 22, 33, 231); - + var source = new Argb32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Argb32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Bgra32() { - Bgra32 source = new Bgra32(1, 22, 33, 231); - + var source = new Bgra32(1, 22, 33, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Bgra32 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Rgb24() { - Rgb24 source = new Rgb24(1, 22, 231); - + var source = new Rgb24(1, 22, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Rgb24 data = color.ToPixel(); Assert.Equal(source, data); } - + [Fact] public void Bgr24() { - Bgr24 source = new Bgr24(1, 22, 231); - + var source = new Bgr24(1, 22, 231); + // Act: - Color color = new Color(source); + var color = new Color(source); // Assert: Bgr24 data = color.ToPixel(); @@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index da35e7f5f..6d9b34ee9 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -18,47 +18,47 @@ namespace SixLabors.ImageSharp.Tests Color c1 = Color.FromRgba(111, 222, 55, 255); Color c2 = c1.WithAlpha(0.5f); - Rgba32 expected = new Rgba32(111, 222, 55, 128); - + var expected = new Rgba32(111, 222, 55, 128); + Assert.Equal(expected, (Rgba32)c2); } - + [Fact] public void Equality_WhenTrue() { Color c1 = new Rgba64(100, 2000, 3000, 40000); Color c2 = new Rgba64(100, 2000, 3000, 40000); - + Assert.True(c1.Equals(c2)); Assert.True(c1 == c2); Assert.False(c1 != c2); Assert.True(c1.GetHashCode() == c2.GetHashCode()); } - + [Fact] public void Equality_WhenFalse() { Color c1 = new Rgba64(100, 2000, 3000, 40000); Color c2 = new Rgba64(101, 2000, 3000, 40000); Color c3 = new Rgba64(100, 2000, 3000, 40001); - + Assert.False(c1.Equals(c2)); Assert.False(c2.Equals(c3)); Assert.False(c3.Equals(c1)); - + Assert.False(c1 == c2); Assert.True(c1 != c2); - + Assert.False(c1.Equals(null)); } - + [Fact] public void ToHex() { string expected = "ABCD1234"; Color color = Color.FromHex(expected); string actual = color.ToHex(); - + Assert.Equal(expected, actual); } @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests Rgba32[] actualPalette = Color.WernerPalette.ToArray().Select(c => (Rgba32)c).ToArray(); Assert.Equal(ReferencePalette.WernerColors, actualPalette); } - + public class FromHex { [Fact] @@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs b/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs index 7987fbe9f..17816aab1 100644 --- a/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs +++ b/tests/ImageSharp.Tests/Colorspaces/RgbTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 4f8a2cdaf..58317ca49 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Common private static Vector CreateExactTestVector1() { - float[] data = new float[Vector.Count]; + var data = new float[Vector.Count]; data[0] = 0.1f; data[1] = 0.4f; @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Common private static Vector CreateRandomTestVector(int seed, float min, float max) { - float[] data = new float[Vector.Count]; + var data = new float[Vector.Count]; var rnd = new Random(seed); @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Common float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256); float[] normalized = orig.Select(f => f / 255f).ToArray(); - byte[] dest = new byte[count]; + var dest = new byte[count]; SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(normalized, dest); @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Common float[] source = new Random(seed).GenerateRandomFloatArray(count, 0, 1f); - byte[] dest = new byte[count]; + var dest = new byte[count]; SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(source, dest); @@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Common count, (s, d) => SimdUtils.BasicIntrinsics256.BulkConvertByteToNormalizedFloat(s.Span, d.Span)); } - + [Theory] [MemberData(nameof(ArraySizesDivisibleBy32))] public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat(int count) @@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Common Action, Memory> convert) { byte[] source = new Random(count).GenerateRandomByteArray(count); - float[] result = new float[count]; + var result = new float[count]; float[] expected = source.Select(b => (float)b / 255f).ToArray(); convert(source, result); @@ -306,7 +306,7 @@ namespace SixLabors.ImageSharp.Tests.Common seed = seed > 0 ? seed : count; float[] source = new Random(seed).GenerateRandomFloatArray(count, -0.2f, 1.2f); byte[] expected = source.Select(NormalizedFloatToByte).ToArray(); - byte[] actual = new byte[count]; + var actual = new byte[count]; convert(source, actual); @@ -325,7 +325,7 @@ namespace SixLabors.ImageSharp.Tests.Common private void MagicConvertToByte(float value) { byte actual = MagicConvert(value / 256f); - byte expected = (byte)value; + var expected = (byte)value; Assert.Equal(expected, actual); } @@ -362,7 +362,7 @@ namespace SixLabors.ImageSharp.Tests.Common { var magick = new Vector(32768.0f); - Vector scale = new Vector(255f) / new Vector(256f); + var scale = new Vector(255f) / new Vector(256f); Vector x = MemoryMarshal.Cast>(source)[0]; @@ -392,4 +392,4 @@ namespace SixLabors.ImageSharp.Tests.Common } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index e6a3b9913..86c1c2850 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -75,13 +75,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (Image image = provider.GetImage()) using (var blend = Image.Load(TestFile.Create(brushImage).Bytes)) { - Size size = new Size(image.Width * 3 / 4, image.Height * 3 / 4); - Point position = new Point(image.Width / 8, image.Height / 8); + var size = new Size(image.Width * 3 / 4, image.Height * 3 / 4); + var position = new Point(image.Width / 8, image.Height / 8); blend.Mutate(x => x.Resize(size.Width, size.Height, KnownResamplers.Bicubic)); image.Mutate(x => x.DrawImage(blend, position, mode, opacity)); FormattableString testInfo = $"{System.IO.Path.GetFileNameWithoutExtension(brushImage)}-{mode}-{opacity}"; - PngEncoder encoder = new PngEncoder(); + var encoder = new PngEncoder(); if (provider.PixelType == PixelTypes.Rgba64) { @@ -197,4 +197,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 4a320d66b..8c2c6fc6e 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void PathExtendingOffEdgeOfImageShouldNotBeCropped(TestImageProvider provider) where TPixel : struct, IPixel { - Color color = Color.White; + var color = Color.White; Pen pen = Pens.Solid(color, 5f); provider.RunValidatingProcessorTest( @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { for (int i = 0; i < 300; i += 20) { - PointF[] points = new PointF[] { new Vector2(100, 2), new Vector2(-10, i) }; + var points = new PointF[] { new Vector2(100, 2), new Vector2(-10, i) }; x.DrawLines(pen, points); } }, @@ -75,4 +75,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing appendSourceFileOrDescription: false); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs index af92876cd..104237ec3 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -28,18 +28,18 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); - - GraphicsOptions options = new GraphicsOptions(antialias); + + var options = new GraphicsOptions(antialias); string aa = antialias ? "" : "_NoAntialias"; FormattableString outputDetails = $"{colorName}_A{alpha}{aa}"; - + provider.RunValidatingProcessorTest( c => c.FillPolygon(options, color, simplePath), outputDetails, appendSourceFileOrDescription: false); } - + [Theory] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32)] public void FillPolygon_Concave(TestImageProvider provider) @@ -47,15 +47,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var points = new SixLabors.Primitives.PointF[] { - new Vector2(8, 8), - new Vector2(64, 8), - new Vector2(64, 64), + new Vector2(8, 8), + new Vector2(64, 8), + new Vector2(64, 64), new Vector2(120, 64), - new Vector2(120, 120), + new Vector2(120, 120), new Vector2(8, 120) }; - - Color color = Color.LightGreen; + + var color = Color.LightGreen; provider.RunValidatingProcessorTest( c => c.FillPolygon(color, points), @@ -72,15 +72,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; - Color color = Color.Yellow; + var color = Color.Yellow; var brush = Brushes.Horizontal(color); - + provider.RunValidatingProcessorTest( c => c.FillPolygon(brush, simplePath), appendSourceFileOrDescription: false); } - + [Theory] [WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Png.Ducky)] [WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Bmp.Car)] @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (Image brushImage = Image.Load(TestFile.Create(brushImageName).Bytes)) { var brush = new ImageBrush(brushImage); - + provider.RunValidatingProcessorTest( c => c.FillPolygon(brush, simplePath), System.IO.Path.GetFileNameWithoutExtension(brushImageName), @@ -109,13 +109,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing where TPixel : struct, IPixel { var polygon = new SixLabors.Shapes.RectangularPolygon(10, 10, 190, 140); - Color color = Color.White; + var color = Color.White; provider.RunValidatingProcessorTest( c => c.Fill(color, polygon), - appendSourceFileOrDescription: false); + appendSourceFileOrDescription: false); } - + [Theory] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 50, 0f)] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 60, 20f)] @@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { float angle = GeometryUtilities.DegreeToRadian(angleDeg); var polygon = new RegularPolygon(100, 100, vertices, radius, angle); - Color color = Color.Yellow; + var color = Color.Yellow; FormattableString testOutput = $"V({vertices})_R({radius})_Ang({angleDeg})"; provider.RunValidatingProcessorTest( @@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing where TPixel : struct, IPixel { var polygon = new EllipsePolygon(100, 100, 80, 120); - Color color = Color.Azure; + var color = Color.Azure; provider.RunValidatingProcessorTest( c => c.Fill(color, polygon), diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 83f2537e7..a5e745083 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { using (Image image = provider.GetImage()) { - Color color = Color.HotPink; + var color = Color.HotPink; image.Mutate(c => c.Fill(color)); image.DebugSave(provider, appendPixelTypeToFileName: false); @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { using (Image image = provider.GetImage()) { - Color color = Color.HotPink; + var color = Color.HotPink; image.Mutate(c => c.Fill(color)); image.DebugSave(provider, appendSourceFileOrDescription: false); diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs index 73a1114d3..7bebdabd3 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont("OpenSans-Regular.ttf", 36); - Color color = Color.Black; + var color = Color.Black; var text = "A short piece of text"; using (var img = provider.GetImage()) @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text float scalingFactor = Math.Min(img.Width / size.Width, img.Height / size.Height); //create a new font - Font scaledFont = new Font(font, scalingFactor * font.Size); + var scaledFont = new Font(font, scalingFactor * font.Size); var center = new PointF(img.Width / 2, img.Height / 2); var textGraphicOptions = new TextGraphicsOptions(true) @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont(fontName, fontSize); - Color color = Color.Black; + var color = Color.Black; provider.VerifyOperation( TextDrawingComparer, @@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text HorizontalAlignment = HorizontalAlignment.Left, }; - Color color = Color.Black; + var color = Color.Black; // Based on the reported 0.0270% difference with AccuracyMultiple = 8 // We should avoid quality regressions leading to higher difference! @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont(fontName, fontSize); - Color color = Color.Black; + var color = Color.Black; provider.VerifyOperation( OutlinedTextDrawingComparer, @@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont(fontName, fontSize); - Color color = Color.Black; + var color = Color.Black; provider.VerifyOperation( OutlinedTextDrawingComparer, diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index 8ad227cfd..25cf29406 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using SixLabors.ImageSharp.Formats.Bmp; using Xunit; @@ -11,11 +11,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { var header = new BmpFileHeader(1, 2, 3, 4); - byte[] buffer = new byte[14]; + var buffer = new byte[14]; header.WriteTo(buffer); Assert.Equal("AQACAAAAAwAAAAQAAAA=", Convert.ToBase64String(buffer)); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index 93f3f7089..21b9b6cab 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg () => { // Block8x8F block = new Block8x8F(); - float[] block = new float[64]; + var block = new float[64]; for (int i = 0; i < Block8x8F.Size; i++) { block[i] = i; @@ -90,8 +90,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void Load_Store_FloatArray() { - float[] data = new float[Block8x8F.Size]; - float[] mirror = new float[Block8x8F.Size]; + var data = new float[Block8x8F.Size]; + var mirror = new float[Block8x8F.Size]; for (int i = 0; i < Block8x8F.Size; i++) { @@ -115,8 +115,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public unsafe void Load_Store_FloatArray_Ptr() { - float[] data = new float[Block8x8F.Size]; - float[] mirror = new float[Block8x8F.Size]; + var data = new float[Block8x8F.Size]; + var mirror = new float[Block8x8F.Size]; for (int i = 0; i < Block8x8F.Size; i++) { @@ -140,8 +140,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void Load_Store_IntArray() { - int[] data = new int[Block8x8F.Size]; - int[] mirror = new int[Block8x8F.Size]; + var data = new int[Block8x8F.Size]; + var mirror = new int[Block8x8F.Size]; for (int i = 0; i < Block8x8F.Size; i++) { @@ -174,7 +174,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var dest = new Block8x8F(); source.TransposeInto(ref dest); - float[] actual = new float[64]; + var actual = new float[64]; dest.CopyTo(actual); Assert.Equal(expected, actual); @@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg private static float[] Create8x8ColorCropTestData() { - float[] result = new float[64]; + var result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -230,7 +230,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Block8x8F dest = block; dest.NormalizeColorsInplace(255); - float[] array = new float[64]; + var array = new float[64]; dest.CopyTo(array); this.Output.WriteLine("Result:"); this.PrintLinearData(array); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 04e55fad3..91e2f43d3 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void iDCT2D8x4_LeftPart() { float[] sourceArray = Create8x8FloatData(); - float[] expectedDestArray = new float[64]; + var expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray, expectedDestArray); @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg FastFloatingPointDCT.IDCT8x4_LeftPart(ref source, ref dest); - float[] actualDestArray = new float[64]; + var actualDestArray = new float[64]; dest.CopyTo(actualDestArray); this.Print8x8Data(expectedDestArray); @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void iDCT2D8x4_RightPart() { float[] sourceArray = Create8x8FloatData(); - float[] expectedDestArray = new float[64]; + var expectedDestArray = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray.AsSpan(4), expectedDestArray.AsSpan(4)); @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg FastFloatingPointDCT.IDCT8x4_RightPart(ref source, ref dest); - float[] actualDestArray = new float[64]; + var actualDestArray = new float[64]; dest.CopyTo(actualDestArray); this.Print8x8Data(expectedDestArray); @@ -118,12 +118,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var destBlock = new Block8x8F(); - float[] expectedDest = new float[64]; + var expectedDest = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D8x4_32f(src, expectedDest); FastFloatingPointDCT.FDCT8x4_LeftPart(ref srcBlock, ref destBlock); - float[] actualDest = new float[64]; + var actualDest = new float[64]; destBlock.CopyTo(actualDest); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); @@ -140,12 +140,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var destBlock = new Block8x8F(); - float[] expectedDest = new float[64]; + var expectedDest = new float[64]; ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D8x4_32f(src.Slice(4), expectedDest.AsSpan(4)); FastFloatingPointDCT.FDCT8x4_RightPart(ref srcBlock, ref destBlock); - float[] actualDest = new float[64]; + var actualDest = new float[64]; destBlock.CopyTo(actualDest); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); @@ -162,14 +162,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var destBlock = new Block8x8F(); - float[] expectedDest = new float[64]; - float[] temp1 = new float[64]; + var expectedDest = new float[64]; + var temp1 = new float[64]; var temp2 = new Block8x8F(); ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D_llm(src, expectedDest, temp1, downscaleBy8: true); FastFloatingPointDCT.TransformFDCT(ref srcBlock, ref destBlock, ref temp2, false); - float[] actualDest = new float[64]; + var actualDest = new float[64]; destBlock.CopyTo(actualDest); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index 89fdd5745..20830a33f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // ReSharper disable InconsistentNaming @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils // ReSharper disable once InconsistentNaming public static float[] Create8x8FloatData() { - float[] result = new float[64]; + var result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils // ReSharper disable once InconsistentNaming public static int[] Create8x8IntData() { - int[] result = new int[64]; + var result = new int[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils // ReSharper disable once InconsistentNaming public static short[] Create8x8ShortData() { - short[] result = new short[64]; + var result = new short[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { var rnd = new Random(seed); - int[] result = new int[64]; + var result = new int[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42) { var rnd = new Random(seed); - float[] result = new float[64]; + var result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -189,4 +189,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index 5a62de034..31779df45 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils result[i] = resultComponent; } - byte[] buffer = new byte[64 * sizeof(short)]; + var buffer = new byte[64 * sizeof(short)]; for (int i = 0; i < result.Length; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index 46f030580..58fa4231e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils private static double[,] InitCosLut() { - double[,] coslu = new double[8, 8]; + var coslu = new double[8, 8]; int a, b; double tmp; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index df5ec9740..0c644e5c2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -29,10 +29,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { public static Block8x8F TransformIDCT(ref Block8x8F source) { - float[] s = new float[64]; + var s = new float[64]; source.CopyTo(s); - float[] d = new float[64]; - float[] temp = new float[64]; + var d = new float[64]; + var temp = new float[64]; iDCT2D_llm(s, d, temp); Block8x8F result = default; @@ -42,10 +42,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static Block8x8F TransformFDCT_UpscaleBy8(ref Block8x8F source) { - float[] s = new float[64]; + var s = new float[64]; source.CopyTo(s); - float[] d = new float[64]; - float[] temp = new float[64]; + var d = new float[64]; + var temp = new float[64]; fDCT2D_llm(s, d, temp); Block8x8F result = default; @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static float[] PrintConstants(ITestOutputHelper output) { - float[] r = new float[8]; + var r = new float[8]; for (int i = 0; i < 8; i++) { r[i] = (float)(Cos(i / 16.0 * M_PI) * M_SQRT2); @@ -466,7 +466,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { float t0, t1, t2, t3, t4, t5, t6, t7; float c0, c1, c2, c3; - float[] r = new float[8]; + var r = new float[8]; //for(i = 0;i < 8;i++){ r[i] = (float)(cos((double)i / 16.0 * M_PI) * M_SQRT2); } r[0] = 1.414214f; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs index cc701c814..a929e0eb0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block) { - int[] temp = new int[Block8x8.Size]; + var temp = new int[Block8x8.Size]; block.CopyTo(temp); Subtract128_TransformFDCT_Upscale8_Inplace(temp); var result = default(Block8x8); @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils // [Obsolete("Looks like this method produces really bad results for bigger values!")] public static Block8x8 TransformIDCT(ref Block8x8 block) { - int[] temp = new int[Block8x8.Size]; + var temp = new int[Block8x8.Size]; block.CopyTo(temp); TransformIDCTInplace(temp); var result = default(Block8x8); @@ -364,4 +364,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index f604cb1b5..142e38dc0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils /// A new with float values public static float[] ConvertAllToFloat(this int[] src) { - float[] result = new float[src.Length]; + var result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i]; @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils /// A new instance of public static Span AddScalarToAllValues(this Span src, float scalar) { - float[] result = new float[src.Length]; + var result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils /// A new instance of public static Span AddScalarToAllValues(this Span src, int scalar) { - int[] result = new int[src.Length]; + var result = new int[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs index e59584991..61a5d8f1d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void ZigZagCanHandleAllPossibleCoefficients() { // Mimic the behaviour of the huffman scan decoder using all possible byte values - short[] block = new short[64]; + var block = new short[64]; var zigzag = ZigZag.CreateUnzigTable(); for (int h = 0; h < 255; h++) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index 6a0119f0f..e976d5a76 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -1,4 +1,4 @@ -using System.Buffers.Binary; +using System.Buffers.Binary; using System.IO; using System.Text; @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png private static string GetChunkTypeName(uint value) { - byte[] data = new byte[4]; + var data = new byte[4]; BinaryPrimitives.WriteUInt32BigEndian(data, value); @@ -125,4 +125,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png memStream.Position = 0; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs index 3468c076a..aeadfcebb 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - int[] actualData = new int[maxY]; + var actualData = new int[maxY]; ParallelHelper.IterateRows( rectangle, @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers var rectangle = new Rectangle(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - int[] actualData = new int[maxY]; + var actualData = new int[maxY]; ParallelHelper.IterateRowsWithTempBuffer( rectangle, diff --git a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs index 3aead6aaa..45067f82f 100644 --- a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs +++ b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers var rows = new RowInterval(min, max); Span span = buffer.GetMultiRowSpan(rows); - + ref int expected0 = ref buffer.Span[min * width]; int expectedLength = (max - min) * width; @@ -38,9 +38,9 @@ namespace SixLabors.ImageSharp.Tests.Helpers [Fact] public void Slice1() { - RowInterval rowInterval = new RowInterval(10, 20); + var rowInterval = new RowInterval(10, 20); RowInterval sliced = rowInterval.Slice(5); - + Assert.Equal(15, sliced.Min); Assert.Equal(20, sliced.Max); } @@ -48,9 +48,9 @@ namespace SixLabors.ImageSharp.Tests.Helpers [Fact] public void Slice2() { - RowInterval rowInterval = new RowInterval(10, 20); + var rowInterval = new RowInterval(10, 20); RowInterval sliced = rowInterval.Slice(3, 5); - + Assert.Equal(13, sliced.Min); Assert.Equal(18, sliced.Max); } @@ -58,9 +58,9 @@ namespace SixLabors.ImageSharp.Tests.Helpers [Fact] public void Equality_WhenTrue() { - RowInterval a = new RowInterval(42, 123); - RowInterval b = new RowInterval(42, 123); - + var a = new RowInterval(42, 123); + var b = new RowInterval(42, 123); + Assert.True(a.Equals(b)); Assert.True(a.Equals((object)b)); Assert.True(a == b); @@ -70,14 +70,14 @@ namespace SixLabors.ImageSharp.Tests.Helpers [Fact] public void Equality_WhenFalse() { - RowInterval a = new RowInterval(42, 123); - RowInterval b = new RowInterval(42, 125); - RowInterval c = new RowInterval(40, 123); - + var a = new RowInterval(42, 123); + var b = new RowInterval(42, 125); + var c = new RowInterval(40, 123); + Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); Assert.False(b.Equals(c)); - + Assert.False(a.Equals((object)b)); Assert.False(a.Equals(null)); Assert.False(a == b); diff --git a/tests/ImageSharp.Tests/IO/DoubleBufferedStreamReaderTests.cs b/tests/ImageSharp.Tests/IO/DoubleBufferedStreamReaderTests.cs index 4fac8d954..2d5e81173 100644 --- a/tests/ImageSharp.Tests/IO/DoubleBufferedStreamReaderTests.cs +++ b/tests/ImageSharp.Tests/IO/DoubleBufferedStreamReaderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.IO { using (MemoryStream stream = this.CreateTestStream()) { - byte[] buffer = new byte[2]; + var buffer = new byte[2]; byte[] expected = stream.ToArray(); var reader = new DoubleBufferedStreamReader(this.allocator, stream); @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.IO { using (MemoryStream stream = this.CreateTestStream()) { - byte[] buffer = new byte[2]; + var buffer = new byte[2]; byte[] expected = stream.ToArray(); var reader = new DoubleBufferedStreamReader(this.allocator, stream); @@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests.IO private MemoryStream CreateTestStream() { - byte[] buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; + var buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; var random = new Random(); random.NextBytes(buffer); diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 66081348a..035babcb8 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using Xunit; @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void CloneAs_WhenDisposed_Throws() { - Image image = new Image(5, 5); + var image = new Image(5, 5); image.Dispose(); Assert.Throws(() => image.CloneAs()); @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Clone_WhenDisposed_Throws() { - Image image = new Image(5, 5); + var image = new Image(5, 5); image.Dispose(); Assert.Throws(() => image.Clone()); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index 92c5915ff..e972012e2 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void AddFrame_OfDifferentPixelType() { - using (Image sourceImage = new Image( + using (var sourceImage = new Image( this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray(); Assert.Equal(2, this.Collection.Count); - ImageFrame actualFrame = (ImageFrame)this.Collection[1]; + var actualFrame = (ImageFrame)this.Collection[1]; actualFrame.ComparePixelBufferTo(expectedAllBlue); } @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void InsertFrame_OfDifferentPixelType() { - using (Image sourceImage = new Image( + using (var sourceImage = new Image( this.Image.GetConfiguration(), this.Image.Width, this.Image.Height, @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray(); Assert.Equal(2, this.Collection.Count); - ImageFrame actualFrame = (ImageFrame)this.Collection[0]; + var actualFrame = (ImageFrame)this.Collection[0]; actualFrame.ComparePixelBufferTo(expectedAllBlue); @@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests { Assert.Equal(2, img.Frames.Count); - Image expectedClone = (Image)cloned; + var expectedClone = (Image)cloned; expectedClone.ComparePixelBufferTo(img.GetPixelSpan()); } @@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Tests { Assert.Equal(1, img.Frames.Count); - Image expectedClone = (Image)cloned; + var expectedClone = (Image)cloned; expectedClone.ComparePixelBufferTo(sourcePixelData); } } @@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Tests Assert.Equal(2, this.Image.Frames.Count); - ImageFrame frame = (ImageFrame)this.Image.Frames[1]; + var frame = (ImageFrame)this.Image.Frames[1]; frame.ComparePixelBufferTo(default(Rgba32)); } @@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests Assert.Equal(2, this.Image.Frames.Count); - ImageFrame frame = (ImageFrame)this.Image.Frames[1]; + var frame = (ImageFrame)this.Image.Frames[1]; frame.ComparePixelBufferTo(Rgba32.HotPink); } @@ -273,7 +273,7 @@ namespace SixLabors.ImageSharp.Tests where TPixel : struct, IPixel { using (Image source = provider.GetImage()) - using (Image dest = new Image(source.GetConfiguration(), source.Width, source.Height)) + using (var dest = new Image(source.GetConfiguration(), source.Width, source.Height)) { // Giphy.gif has 5 frames diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index f5504fac2..25bc3f604 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void SavePath() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream); this.Image.Save("path.png"); @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void SavePathWithEncoder() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); this.fileSystem.Setup(x => x.Create("path.jpg")).Returns(stream); this.Image.Save("path.jpg", this.encoderNotInFormat.Object); @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void SaveStreamWithMime() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); this.Image.Save(stream, this.localImageFormat.Object); this.encoder.Verify(x => x.Encode(this.Image, stream)); @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void SaveStreamWithEncoder() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); this.Image.Save(stream, this.encoderNotInFormat.Object); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs index ad8dc20e4..2b1411fa6 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Theory] [InlineData(false)] [InlineData(true)] @@ -47,14 +47,14 @@ namespace SixLabors.ImageSharp.Tests this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Theory] [InlineData(false)] [InlineData(true)] public void Configuration_Bytes_Decoder_Specific(bool useSpan) { - TestFormat localFormat = new TestFormat(); - + var localFormat = new TestFormat(); + var img = useSpan ? Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) : Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder); @@ -62,14 +62,14 @@ namespace SixLabors.ImageSharp.Tests Assert.NotNull(img); localFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Theory] [InlineData(false)] [InlineData(true)] public void Configuration_Bytes_Decoder_Agnostic(bool useSpan) { - TestFormat localFormat = new TestFormat(); - + var localFormat = new TestFormat(); + var img = useSpan ? Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) : Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder); @@ -90,10 +90,10 @@ namespace SixLabors.ImageSharp.Tests Assert.NotNull(img); Assert.Equal(this.TestFormat, format); - + this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Theory] [InlineData(false)] [InlineData(true)] @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests Assert.NotNull(img); Assert.Equal(this.TestFormat, format); - + this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs index 5ca86c3ce..4e91cfebc 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Fact] public void Configuration_Stream_Agnostic() { @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Fact] public void NonSeekableStream() { @@ -46,21 +46,21 @@ namespace SixLabors.ImageSharp.Tests this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Fact] public void Configuration_Stream_Decoder_Specific() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); var img = Image.Load(this.TopLevelConfiguration, stream, this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(this.TopLevelConfiguration, stream)); } - + [Fact] public void Configuration_Stream_Decoder_Agnostic() { - Stream stream = new MemoryStream(); + var stream = new MemoryStream(); var img = Image.Load(this.TopLevelConfiguration, stream, this.localDecoder.Object); Assert.NotNull(img); @@ -74,10 +74,10 @@ namespace SixLabors.ImageSharp.Tests Assert.NotNull(img); Assert.Equal(this.TestFormat, format); - + this.TestFormat.VerifySpecificDecodeCall(this.Marker, this.TopLevelConfiguration); } - + [Fact] public void Configuration_Stream_OutFormat_Agnostic() { @@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.Tests Assert.NotNull(img); Assert.Equal(this.TestFormat, format); - + this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); - } + } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Save.cs b/tests/ImageSharp.Tests/Image/ImageTests.Save.cs index 61f694518..e00a70e39 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Save.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Save.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests var image = new Image(5, 5); image.Dispose(); IImageEncoder encoder = Mock.Of(); - using (MemoryStream stream = new MemoryStream()) + using (var stream = new MemoryStream()) { Assert.Throws(() => image.Save(stream, encoder)); } diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs index 20c3b728f..d2dc95cfe 100644 --- a/tests/ImageSharp.Tests/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/ImageOperationTests.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests { this.provider = new FakeImageOperationsProvider(); - Mock processorMock = new Mock(); + var processorMock = new Mock(); this.processorDefinition = processorMock.Object; this.image = new Image(new Configuration @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests { try { - Image img = new Image(1, 1); + var img = new Image(1, 1); img.Dispose(); img.EnsureNotDisposed(); } diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index abe78e747..ee32be3ca 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -137,11 +137,11 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(5, 1, 1, 3, 2)] public void CopyColumns(int width, int height, int startIndex, int destIndex, int columnCount) { - Random rnd = new Random(123); + var rnd = new Random(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(width, height)) { rnd.RandomFill(b.Span, 0, 1); - + b.CopyColumns(startIndex, destIndex, columnCount); for (int y = 0; y < b.Height; y++) @@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Tests.Memory Span s = row.Slice(startIndex, columnCount); Span d = row.Slice(destIndex, columnCount); - + Xunit.Assert.True(s.SequenceEqual(d)); } } @@ -159,11 +159,11 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void CopyColumns_InvokeMultipleTimes() { - Random rnd = new Random(123); + var rnd = new Random(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(100, 100)) { rnd.RandomFill(b.Span, 0, 1); - + b.CopyColumns(0, 50, 22); b.CopyColumns(0, 50, 22); @@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Memory Span s = row.Slice(0, 22); Span d = row.Slice(50, 22); - + Xunit.Assert.True(s.SequenceEqual(d)); } } diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index dc735e41b..919279862 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Memory { using (Buffer2D buffer = CreateTestBuffer(20, 30)) { - Rectangle r = new Rectangle(rx, ry, 5, 6); + var r = new Rectangle(rx, ry, 5, 6); BufferArea area = buffer.GetArea(r); @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Memory { using (Buffer2D buffer = CreateTestBuffer(20, 30)) { - Rectangle r = new Rectangle(rx, ry, w, h); + var r = new Rectangle(rx, ry, w, h); BufferArea area = buffer.GetArea(r); @@ -145,4 +145,4 @@ namespace SixLabors.ImageSharp.Tests.Memory } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs index 52d88afaf..633c7c823 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Icc public void CalculateHash_WithByteArray_DoesNotModifyData() { byte[] data = IccTestDataProfiles.Profile_Random_Array; - byte[] copy = new byte[data.Length]; + var copy = new byte[data.Length]; Buffer.BlockCopy(data, 0, copy, 0, data.Length); IccProfile.CalculateHash(data); diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs index 33ecf53c7..e66554b85 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs @@ -13,12 +13,12 @@ namespace SixLabors.ImageSharp.Tests.Icc { IccWriter writer = CreateWriter(); - IccProfile profile = new IccProfile + var profile = new IccProfile { Header = IccTestDataProfiles.Header_Random_Write }; byte[] output = writer.Write(profile); - + Assert.Equal(IccTestDataProfiles.Header_Random_Array, output); } @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Icc IccWriter writer = CreateWriter(); byte[] output = writer.Write(IccTestDataProfiles.Profile_Random_Val); - + Assert.Equal(IccTestDataProfiles.Profile_Random_Array, output); } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 58242713c..682da89fc 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations { const int Count = 2134; TPixel[] source = CreatePixelTestData(Count); - TDestPixel[] expected = new TDestPixel[Count]; + var expected = new TDestPixel[Count]; PixelConverterTests.ReferenceImplementations.To(this.Configuration, source, expected); @@ -457,7 +457,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToArgb32Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 4]; + var expected = new byte[count * 4]; var argb = default(Argb32); for (int i = 0; i < count; i++) @@ -504,7 +504,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToBgr24Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 3]; + var expected = new byte[count * 3]; var bgr = default(Bgr24); for (int i = 0; i < count; i++) @@ -549,7 +549,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToBgra32Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 4]; + var expected = new byte[count * 4]; var bgra = default(Bgra32); for (int i = 0; i < count; i++) @@ -595,7 +595,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToRgb24Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 3]; + var expected = new byte[count * 3]; var rgb = default(Rgb24); for (int i = 0; i < count; i++) @@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToRgba32Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 4]; + var expected = new byte[count * 4]; var rgba = default(Rgba32); for (int i = 0; i < count; i++) @@ -686,7 +686,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToRgb48Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 6]; + var expected = new byte[count * 6]; Rgb48 rgb = default; for (int i = 0; i < count; i++) @@ -735,7 +735,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToRgba64Bytes(int count) { TPixel[] source = CreatePixelTestData(count); - byte[] expected = new byte[count * 8]; + var expected = new byte[count * 8]; Rgba64 rgba = default; for (int i = 0; i < count; i++) @@ -787,7 +787,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToGray8(int count) { TPixel[] source = CreatePixelTestData(count); - Gray8[] expected = new Gray8[count]; + var expected = new Gray8[count]; for (int i = 0; i < count; i++) { @@ -831,7 +831,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public void ToGray16(int count) { TPixel[] source = CreatePixelTestData(count); - Gray16[] expected = new Gray16[count]; + var expected = new Gray16[count]; for (int i = 0; i < count; i++) { @@ -946,7 +946,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations internal static byte[] CreateByteTestData(int length) { - byte[] result = new byte[length]; + var result = new byte[length]; var rnd = new Random(42); // Deterministic random values for (int i = 0; i < result.Length; i++) diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs index 55a2dda7a..9cdf4125c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; @@ -65,16 +65,16 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public void Rgba64_FromScaledVector4(ushort r, ushort g, ushort b, ushort a) { // arrange - + var source = new Rgba64(r, g, b, a); - - // act + + // act Vector4 scaled = source.ToScaledVector4(); Rgba64 actual = default; actual.FromScaledVector4(scaled); - + // assert Assert.Equal(source, actual); } @@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats // assert Assert.Equal(expected, actual); } - + [Fact] public void Rgba64_FromBgra5551() @@ -126,20 +126,20 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats [Fact] public void Equality_WhenTrue() { - Rgba64 c1 = new Rgba64(100, 2000, 3000, 40000); - Rgba64 c2 = new Rgba64(100, 2000, 3000, 40000); - + var c1 = new Rgba64(100, 2000, 3000, 40000); + var c2 = new Rgba64(100, 2000, 3000, 40000); + Assert.True(c1.Equals(c2)); Assert.True(c1.GetHashCode() == c2.GetHashCode()); } - + [Fact] public void Equality_WhenFalse() { - Rgba64 c1 = new Rgba64(100, 2000, 3000, 40000); - Rgba64 c2 = new Rgba64(101, 2000, 3000, 40000); - Rgba64 c3 = new Rgba64(100, 2000, 3000, 40001); - + var c1 = new Rgba64(100, 2000, 3000, 40000); + var c2 = new Rgba64(101, 2000, 3000, 40000); + var c3 = new Rgba64(100, 2000, 3000, 40001); + Assert.False(c1.Equals(c2)); Assert.False(c2.Equals(c3)); Assert.False(c3.Equals(c1)); @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats Rgba64 actual = default; actual.FromRgba32(source); - + Assert.Equal(expected, actual); } @@ -162,127 +162,127 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { var expected = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba32(20, 38, 76, 115); - Rgba64 actual = new Rgba64(source); - + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ConstructFrom_Bgra32() { var expected = new Rgba64(5140, 9766, 19532, 29555); var source = new Bgra32(20, 38, 76, 115); - Rgba64 actual = new Rgba64(source); - + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ConstructFrom_Argb32() { var expected = new Rgba64(5140, 9766, 19532, 29555); var source = new Argb32(20, 38, 76, 115); - Rgba64 actual = new Rgba64(source); - + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ConstructFrom_Rgb24() { var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue); var source = new Rgb24(20, 38, 76); - Rgba64 actual = new Rgba64(source); - + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ConstructFrom_Bgr24() { var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue); var source = new Bgr24(20, 38, 76); - Rgba64 actual = new Rgba64(source); - + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ConstructFrom_Vector4() { - Vector4 source = new Vector4(0f, 0.2f, 0.5f, 1f); + var source = new Vector4(0f, 0.2f, 0.5f, 1f); Rgba64 expected = default; expected.FromScaledVector4(source); - - Rgba64 actual = new Rgba64(source); - + + var actual = new Rgba64(source); + Assert.Equal(expected, actual); } - + [Fact] public void ToRgba32_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Rgba32(20, 38, 76, 115); - + // act var actual = source.ToRgba32(); // assert Assert.Equal(expected, actual); } - + [Fact] public void ToBgra32_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Bgra32(20, 38, 76, 115); - + // act var actual = source.ToBgra32(); // assert Assert.Equal(expected, actual); } - + [Fact] public void ToArgb32_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Argb32(20, 38, 76, 115); - + // act var actual = source.ToArgb32(); // assert Assert.Equal(expected, actual); } - + [Fact] public void ToRgb24_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Rgb24(20, 38, 76); - + // act var actual = source.ToRgb24(); // assert Assert.Equal(expected, actual); } - + [Fact] public void ToBgr24_Retval() { // arrange var source = new Rgba64(5140, 9766, 19532, 29555); var expected = new Bgr24(20, 38, 76); - + // act var actual = source.ToBgr24(); diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index e5015a6ee..5d8a155f0 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization public void HistogramEqualizationTest(int luminanceLevels) { // Arrange - byte[] pixels = new byte[] + var pixels = new byte[] { 52, 55, 61, 59, 70, 61, 76, 61, 62, 59, 55, 104, 94, 85, 59, 71, @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization } } - byte[] expected = new byte[] + var expected = new byte[] { 0, 12, 53, 32, 146, 53, 174, 53, 57, 32, 12, 227, 219, 202, 32, 154, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 69acf9282..ceb6f8363 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { image.Metadata.ExifProfile = new ExifProfile(); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); - + image.Mutate(x => x.AutoOrient()); image.DebugSave(provider, orientation, appendPixelTypeToFileName: false); image.CompareToReferenceOutput(provider, orientation, appendPixelTypeToFileName: false); @@ -71,8 +71,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms bytes[18] = (byte)dataType; // Change the number of components bytes[20] = 1; - - byte[] orientationCodeData = new byte[8]; + + var orientationCodeData = new byte[8]; Array.Copy(orientation, orientationCodeData, orientation.Length); ulong orientationCode = BitConverter.ToUInt64(orientationCodeData, 0); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index f56827870..dbaff43f0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms public void ImageShouldPadWithBackgroundColor(TestImageProvider provider) where TPixel : struct, IPixel { - Color color = Color.Red; + var color = Color.Red; TPixel expected = color.ToPixel(); using (Image image = provider.GetImage()) { @@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 2c5914253..1681c3046 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Collections.Generic; @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms double sum = 0; - double[] values = new double[right - left + 1]; + var values = new double[right - left + 1]; for (int j = left; j <= right; j++) { @@ -108,4 +108,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index ee1665138..f03d68307 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests { foreach (object[] row in memberData) { - object[] actualFactoryMethodArgs = new object[originalFactoryMethodArgs.Length + 2]; + var actualFactoryMethodArgs = new object[originalFactoryMethodArgs.Length + 2]; Array.Copy(originalFactoryMethodArgs, actualFactoryMethodArgs, originalFactoryMethodArgs.Length); actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 2] = testMethod; actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 1] = kv.Key; @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests object factory = factoryType.GetMethod(this.GetFactoryMethodName(testMethod)) .Invoke(null, actualFactoryMethodArgs); - object[] result = new object[this.AdditionalParameters.Length + 1 + row.Length]; + var result = new object[this.AdditionalParameters.Length + 1 + row.Length]; result[0] = factory; Array.Copy(row, 0, result, 1, row.Length); Array.Copy(this.AdditionalParameters, 0, result, 1 + row.Length, this.AdditionalParameters.Length); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs index 5694617c1..8965458cd 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs @@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Tests int pixelCount = left * top; uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount); TPixel c = default; - Rgba32 t = new Rgba32(0); + var t = new Rgba32(0); for (int x = left; x < right; x++) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs index 4ccb38745..7c29ac4db 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests /// The . public static float[] GenerateRandomFloatArray(this Random rnd, int length, float minVal, float maxVal) { - float[] values = new float[length]; + var values = new float[length]; RandomFill(rnd, values, minVal, maxVal); @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests /// The . public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int length, float minVal, float maxVal) { - float[] values = new float[length]; + var values = new float[length]; for (int i = 0; i < length; i++) { @@ -88,14 +88,14 @@ namespace SixLabors.ImageSharp.Tests /// The . public static byte[] GenerateRandomByteArray(this Random rnd, int length) { - byte[] values = new byte[length]; + var values = new byte[length]; rnd.NextBytes(values); return values; } public static short[] GenerateRandomInt16Array(this Random rnd, int length, short minVal, short maxVal) { - short[] values = new short[length]; + var values = new short[length]; for (int i = 0; i < values.Length; i++) { values[i] = (short)rnd.Next(minVal, maxVal); @@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Tests private static float GetRandomFloat(this Random rnd, float minVal, float maxVal) => ((float)rnd.NextDouble() * (maxVal - minVal)) + minVal; } -} \ No newline at end of file +} From f7819ae340046c8312bf21fe604832fad999ce92 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 15 Aug 2019 20:39:19 +1000 Subject: [PATCH 08/11] cache max in ConvertToRgba --- .../ColorConverters/JpegColorConverter.FromGrayScale.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs index 15bb2cf4b..dd952b210 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs @@ -19,10 +19,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters public override void ConvertToRgba(in ComponentValues values, Span result) { + var maximum = 1 / this.MaximumValue; var scale = new Vector4( - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1 / this.MaximumValue, + maximum, + maximum, + maximum, 1F); ref float sBase = ref MemoryMarshal.GetReference(values.Component0); From c4d6466e651bccd052e79413e6c27001da6cc565 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Thu, 15 Aug 2019 20:53:00 +1000 Subject: [PATCH 09/11] cache max value --- .../Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs | 7 ++----- .../ColorConverters/JpegColorConverter.FromGrayScale.cs | 6 +----- .../Decoder/ColorConverters/JpegColorConverter.FromRgb.cs | 7 ++----- .../Decoder/ColorConverters/JpegColorConverter.FromYccK.cs | 7 ++----- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs index a57535b71..f106d67ad 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs @@ -25,11 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters var v = new Vector4(0, 0, 0, 1F); - var scale = new Vector4( - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1F); + var maximum = 1 / this.MaximumValue; + var scale = new Vector4(maximum, maximum, maximum, 1F); for (int i = 0; i < result.Length; i++) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs index dd952b210..68ab6f912 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs @@ -20,11 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters public override void ConvertToRgba(in ComponentValues values, Span result) { var maximum = 1 / this.MaximumValue; - var scale = new Vector4( - maximum, - maximum, - maximum, - 1F); + var scale = new Vector4(maximum, maximum, maximum, 1F); ref float sBase = ref MemoryMarshal.GetReference(values.Component0); ref Vector4 dBase = ref MemoryMarshal.GetReference(result); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs index 2f68e312d..7a92a4ed4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs @@ -24,11 +24,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters var v = new Vector4(0, 0, 0, 1); - var scale = new Vector4( - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1F); + var maximum = 1 / this.MaximumValue; + var scale = new Vector4(maximum, maximum, maximum, 1F); for (int i = 0; i < result.Length; i++) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs index cd8a3bb06..f1d773708 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs @@ -25,11 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters var v = new Vector4(0, 0, 0, 1F); - var scale = new Vector4( - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1 / this.MaximumValue, - 1F); + var maximum = 1 / this.MaximumValue; + var scale = new Vector4(maximum, maximum, maximum, 1F); for (int i = 0; i < result.Length; i++) { From fd6a03af15b5d516af9d87e00cdab331a1a04513 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 17 Aug 2019 08:52:53 +1000 Subject: [PATCH 10/11] remove some redundant usings (#976) --- src/ImageSharp/Advanced/AotCompilerTools.cs | 1 - src/ImageSharp/Common/Helpers/Guard.cs | 1 - src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 1 - src/ImageSharp/Formats/Png/IPngDecoderOptions.cs | 2 -- src/ImageSharp/Formats/Png/PngDecoder.cs | 1 - tests/ImageSharp.Tests/Drawing/Text/DrawText.cs | 2 -- tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs | 1 - tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs | 1 - tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs | 3 --- .../MetaData/Profiles/Exif/ExifProfileTests.cs | 1 - 10 files changed, 14 deletions(-) diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs index 084f2403e..439ea6de0 100644 --- a/src/ImageSharp/Advanced/AotCompilerTools.cs +++ b/src/ImageSharp/Advanced/AotCompilerTools.cs @@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Dithering; using SixLabors.ImageSharp.Processing.Processors.Quantization; using SixLabors.ImageSharp.Processing.Processors.Transforms; -using SixLabors.Primitives; namespace SixLabors.ImageSharp.Advanced { diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index a39d10b6b..7dc683c37 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 912e6c04d..c8fc44812 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -6,7 +6,6 @@ using System.Buffers; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Text; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; diff --git a/src/ImageSharp/Formats/Png/IPngDecoderOptions.cs b/src/ImageSharp/Formats/Png/IPngDecoderOptions.cs index 44cb837a6..e3036d4bd 100644 --- a/src/ImageSharp/Formats/Png/IPngDecoderOptions.cs +++ b/src/ImageSharp/Formats/Png/IPngDecoderOptions.cs @@ -1,8 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Text; - namespace SixLabors.ImageSharp.Formats.Png { /// diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index 19e5e848d..eea9e54c0 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System.IO; -using System.Text; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Png diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index 181ec9b9d..8b45bd524 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -3,11 +3,9 @@ using System.Numerics; using SixLabors.Fonts; -using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Text; using SixLabors.Primitives; -using SixLabors.Shapes; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Text diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 6c8732b5d..99dc2d06d 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Metadata; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs index a5bd6efbb..8cb61235e 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Metadata; diff --git a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs b/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs index 6730605e9..39135d003 100644 --- a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs +++ b/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs @@ -1,9 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Collections.Generic; - -using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs index 3ae452d7d..4f928e070 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; From 8bbb9e0466f87355e50ec3720e0cb8ca5dbf0191 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 17 Aug 2019 20:58:37 +1000 Subject: [PATCH 11/11] remove SteppedRange (#980) --- .../Common/Extensions/EnumerableExtensions.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/ImageSharp/Common/Extensions/EnumerableExtensions.cs b/src/ImageSharp/Common/Extensions/EnumerableExtensions.cs index e28db7cff..cff6e3b60 100644 --- a/src/ImageSharp/Common/Extensions/EnumerableExtensions.cs +++ b/src/ImageSharp/Common/Extensions/EnumerableExtensions.cs @@ -11,33 +11,6 @@ namespace SixLabors.ImageSharp.Common /// internal static class EnumerableExtensions { - /// - /// Generates a sequence of integral numbers within a specified range. - /// - /// - /// The start index, inclusive. - /// - /// - /// The end index, exclusive. - /// - /// - /// The incremental step. - /// - /// - /// The that contains a range of sequential integral numbers. - /// - public static IEnumerable SteppedRange(int fromInclusive, int toExclusive, int step) - { - // Borrowed from Enumerable.Range - long num = (fromInclusive + toExclusive) - 1L; - if ((toExclusive < 0) || (num > 0x7fffffffL)) - { - throw new ArgumentOutOfRangeException(nameof(toExclusive)); - } - - return RangeIterator(fromInclusive, i => i < toExclusive, step); - } - /// /// Generates a sequence of integral numbers within a specified range. ///