Browse Source

use var where apparent (#972)

* use var where apparent

* use var where apparent

* should use Rgb24
af/merge-core
Simon Cropp 7 years ago
committed by James Jackson-South
parent
commit
bcbd4726a6
  1. 2
      README.md
  2. 2
      src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
  3. 4
      src/ImageSharp/Common/Extensions/StreamExtensions.cs
  4. 10
      src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs
  5. 4
      src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs
  6. 4
      src/ImageSharp/Common/Helpers/SimdUtils.cs
  7. 20
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  8. 4
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  9. 4
      src/ImageSharp/Formats/Gif/LzwDecoder.cs
  10. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  11. 12
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
  12. 16
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt
  13. 6
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  14. 6
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  15. 6
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  16. 2
      src/ImageSharp/ImageFrameCollection{TPixel}.cs
  17. 2
      src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
  18. 14
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
  19. 12
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs
  20. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs
  21. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs
  22. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs
  23. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
  24. 28
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
  25. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  26. 6
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  27. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  28. 2
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  29. 8
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  30. 110
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  31. 6
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  32. 4
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  33. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  34. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  35. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  36. 4
      src/ImageSharp/Primitives/Rational.cs
  37. 4
      src/ImageSharp/Primitives/SignedRational.cs
  38. 6
      src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
  39. 8
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  40. 6
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs
  41. 4
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  42. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs
  43. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs
  44. 32
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs
  45. 6
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs
  46. 4
      tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs
  47. 6
      tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs
  48. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs
  49. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs
  50. 8
      tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs
  51. 12
      tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs
  52. 24
      tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs
  53. 24
      tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs
  54. 2
      tests/ImageSharp.Tests/Color/ColorTests.cs
  55. 2
      tests/ImageSharp.Tests/Colorspaces/RgbTests.cs
  56. 18
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
  57. 8
      tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
  58. 6
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  59. 14
      tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs
  60. 4
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  61. 12
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  62. 4
      tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs
  63. 20
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
  64. 22
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs
  65. 12
      tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
  66. 2
      tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs
  67. 2
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs
  68. 16
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
  69. 4
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs
  70. 6
      tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
  71. 2
      tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs
  72. 4
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs
  73. 4
      tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs
  74. 16
      tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs
  75. 8
      tests/ImageSharp.Tests/IO/DoubleBufferedStreamReaderTests.cs
  76. 6
      tests/ImageSharp.Tests/Image/ImageCloneTests.cs
  77. 18
      tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs
  78. 8
      tests/ImageSharp.Tests/Image/ImageSaveTests.cs
  79. 4
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs
  80. 4
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs
  81. 2
      tests/ImageSharp.Tests/Image/ImageTests.Save.cs
  82. 4
      tests/ImageSharp.Tests/ImageOperationTests.cs
  83. 4
      tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
  84. 4
      tests/ImageSharp.Tests/Memory/BufferAreaTests.cs
  85. 2
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs
  86. 2
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs
  87. 22
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  88. 26
      tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs
  89. 4
      tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs
  90. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs
  91. 4
      tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs
  92. 4
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs
  93. 4
      tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs
  94. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  95. 10
      tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs

2
README.md

@ -92,7 +92,7 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
// Individual pixels // Individual pixels
using (Image<Rgba32> image = new Image<Rgba32>(400, 400)) using (var image = new Image<Rgba32>(400, 400))
{ {
image[200, 200] = Rgba32.White; image[200, 200] = Rgba32.White;
} }

2
src/ImageSharp.Drawing/Processing/DrawingHelpers.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Processing
public static DenseMatrix<TPixel> ToPixelMatrix<TPixel>(this DenseMatrix<Color> colorMatrix, Configuration configuration) public static DenseMatrix<TPixel> ToPixelMatrix<TPixel>(this DenseMatrix<Color> colorMatrix, Configuration configuration)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
DenseMatrix<TPixel> result = new DenseMatrix<TPixel>(colorMatrix.Columns, colorMatrix.Rows); var result = new DenseMatrix<TPixel>(colorMatrix.Columns, colorMatrix.Rows);
Color.ToPixel(configuration, colorMatrix.Span, result.Span); Color.ToPixel(configuration, colorMatrix.Span, result.Span);
return result; return result;
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp
} }
else else
{ {
byte[] foo = new byte[count]; var foo = new byte[count];
while (count > 0) while (count > 0)
{ {
int bytesRead = stream.Read(foo, 0, count); int bytesRead = stream.Read(foo, 0, count);

10
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -138,8 +138,8 @@ namespace SixLabors.ImageSharp
ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest)); ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 8; int n = source.Length / 8;
Vector<float> magick = new Vector<float>(32768.0f); var magick = new Vector<float>(32768.0f);
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f); var scale = new Vector<float>(255f) / new Vector<float>(256f);
// need to copy to a temporary struct, because // need to copy to a temporary struct, because
// SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x) // SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x)
@ -187,8 +187,8 @@ namespace SixLabors.ImageSharp
ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest)); ref Octet.OfByte destBase = ref Unsafe.As<byte, Octet.OfByte>(ref MemoryMarshal.GetReference(dest));
int n = source.Length / 8; int n = source.Length / 8;
Vector<float> magick = new Vector<float>(32768.0f); var magick = new Vector<float>(32768.0f);
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f); var scale = new Vector<float>(255f) / new Vector<float>(256f);
// need to copy to a temporary struct, because // need to copy to a temporary struct, because
// SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x) // SimdUtils.Octet.OfUInt32 temp = Unsafe.As<Vector<float>, SimdUtils.Octet.OfUInt32>(ref x)

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector<uint> ConvertToUInt32(Vector<float> vf) private static Vector<uint> ConvertToUInt32(Vector<float> vf)
{ {
Vector<float> maxBytes = new Vector<float>(255f); var maxBytes = new Vector<float>(255f);
vf *= maxBytes; vf *= maxBytes;
vf += new Vector<float>(0.5f); vf += new Vector<float>(0.5f);
vf = Vector.Min(Vector.Max(vf, Vector<float>.Zero), maxBytes); vf = Vector.Min(Vector.Max(vf, Vector<float>.Zero), maxBytes);

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector<float> FastRound(this Vector<float> v) internal static Vector<float> FastRound(this Vector<float> v)
{ {
Vector<int> magic0 = new Vector<int>(int.MinValue); // 0x80000000 var magic0 = new Vector<int>(int.MinValue); // 0x80000000
Vector<float> sgn0 = Vector.AsVectorSingle(magic0); Vector<float> sgn0 = Vector.AsVectorSingle(magic0);
Vector<float> and0 = Vector.BitwiseAnd(sgn0, v); Vector<float> and0 = Vector.BitwiseAnd(sgn0, v);
Vector<float> or0 = Vector.BitwiseOr(and0, new Vector<float>(8388608.0f)); Vector<float> or0 = Vector.BitwiseOr(and0, new Vector<float>(8388608.0f));

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

@ -446,7 +446,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2]; Span<byte> cmd = stackalloc byte[2];
#else #else
byte[] cmd = new byte[2]; var cmd = new byte[2];
#endif #endif
int count = 0; int count = 0;
@ -485,7 +485,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
int max = cmd[1]; int max = cmd[1];
int bytesToRead = (max + 1) / 2; int bytesToRead = (max + 1) / 2;
byte[] run = new byte[bytesToRead]; var run = new byte[bytesToRead];
this.stream.Read(run, 0, run.Length); this.stream.Read(run, 0, run.Length);
@ -557,7 +557,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2]; Span<byte> cmd = stackalloc byte[2];
#else #else
byte[] cmd = new byte[2]; var cmd = new byte[2];
#endif #endif
int count = 0; int count = 0;
@ -595,7 +595,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
// Take this number of bytes from the stream as uncompressed data. // Take this number of bytes from the stream as uncompressed data.
int length = cmd[1]; int length = cmd[1];
byte[] run = new byte[length]; var run = new byte[length];
this.stream.Read(run, 0, run.Length); this.stream.Read(run, 0, run.Length);
@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> cmd = stackalloc byte[2]; Span<byte> cmd = stackalloc byte[2];
#else #else
byte[] cmd = new byte[2]; var cmd = new byte[2];
#endif #endif
int uncompressedPixels = 0; int uncompressedPixels = 0;
@ -678,7 +678,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
// Take this number of bytes from the stream as uncompressed data. // Take this number of bytes from the stream as uncompressed data.
int length = cmd[1]; int length = cmd[1];
byte[] run = new byte[length * 3]; var run = new byte[length * 3];
this.stream.Read(run, 0, run.Length); this.stream.Read(run, 0, run.Length);
@ -1214,7 +1214,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[BmpInfoHeader.MaxHeaderSize]; Span<byte> buffer = stackalloc byte[BmpInfoHeader.MaxHeaderSize];
#else #else
byte[] buffer = new byte[BmpInfoHeader.MaxHeaderSize]; var buffer = new byte[BmpInfoHeader.MaxHeaderSize];
#endif #endif
// Read the header size. // Read the header size.
@ -1252,7 +1252,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
// color masks for each color channel follow the info header. // color masks for each color channel follow the info header.
if (this.infoHeader.Compression == BmpCompression.BitFields) if (this.infoHeader.Compression == BmpCompression.BitFields)
{ {
byte[] bitfieldsBuffer = new byte[12]; var bitfieldsBuffer = new byte[12];
this.stream.Read(bitfieldsBuffer, 0, 12); this.stream.Read(bitfieldsBuffer, 0, 12);
Span<byte> data = bitfieldsBuffer.AsSpan(); Span<byte> data = bitfieldsBuffer.AsSpan();
this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4)); 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) else if (this.infoHeader.Compression == BmpCompression.BI_ALPHABITFIELDS)
{ {
byte[] bitfieldsBuffer = new byte[16]; var bitfieldsBuffer = new byte[16];
this.stream.Read(bitfieldsBuffer, 0, 16); this.stream.Read(bitfieldsBuffer, 0, 16);
Span<byte> data = bitfieldsBuffer.AsSpan(); Span<byte> data = bitfieldsBuffer.AsSpan();
this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4)); this.infoHeader.RedMask = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(0, 4));
@ -1340,7 +1340,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[BmpFileHeader.Size]; Span<byte> buffer = stackalloc byte[BmpFileHeader.Size];
#else #else
byte[] buffer = new byte[BmpFileHeader.Size]; var buffer = new byte[BmpFileHeader.Size];
#endif #endif
this.stream.Read(buffer, 0, BmpFileHeader.Size); this.stream.Read(buffer, 0, BmpFileHeader.Size);

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[infoHeaderSize]; Span<byte> buffer = stackalloc byte[infoHeaderSize];
#else #else
byte[] buffer = new byte[infoHeaderSize]; var buffer = new byte[infoHeaderSize];
#endif #endif
fileHeader.WriteTo(buffer); fileHeader.WriteTo(buffer);

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
#if NETCOREAPP2_1 #if NETCOREAPP2_1
Span<byte> buffer = stackalloc byte[255]; Span<byte> buffer = stackalloc byte[255];
#else #else
byte[] buffer = new byte[255]; var buffer = new byte[255];
#endif #endif
while (xyz < length) while (xyz < length)

2
src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs

@ -194,7 +194,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// </summary> /// </summary>
public short[] ToArray() public short[] ToArray()
{ {
short[] result = new short[Size]; var result = new short[Size];
this.CopyTo(result); this.CopyTo(result);
return result; return result;
} }

12
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -95,9 +95,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// </summary> /// </summary>
public void NormalizeColorsInplace(float maximum) public void NormalizeColorsInplace(float maximum)
{ {
Vector4 CMin4 = new Vector4(0F); var CMin4 = new Vector4(0F);
Vector4 CMax4 = new Vector4(maximum); var CMax4 = new Vector4(maximum);
Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2)); var COff4 = new Vector4(MathF.Ceiling(maximum / 2));
this.V0L = Vector4.Clamp(this.V0L + COff4, CMin4, CMax4); this.V0L = Vector4.Clamp(this.V0L + COff4, CMin4, CMax4);
this.V0R = Vector4.Clamp(this.V0R + 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)] [MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInplaceAvx2(float maximum) public void NormalizeColorsAndRoundInplaceAvx2(float maximum)
{ {
Vector<float> off = new Vector<float>(MathF.Ceiling(maximum / 2)); var off = new Vector<float>(MathF.Ceiling(maximum / 2));
Vector<float> max = new Vector<float>(maximum); var max = new Vector<float>(maximum);
ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L); ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref this.V0L);
row0 = NormalizeAndRound(row0, off, max); row0 = NormalizeAndRound(row0, off, max);

16
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt

@ -1,4 +1,4 @@
<# <#
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#> #>
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
char srcCoord = coordz[j % 4]; char srcCoord = coordz[j % 4];
char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R'; 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); Write(expression);
} }
} }
@ -60,9 +60,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// </summary> /// </summary>
public void NormalizeColorsInplace(float maximum) public void NormalizeColorsInplace(float maximum)
{ {
Vector4 CMin4 = new Vector4(0F); var CMin4 = new Vector4(0F);
Vector4 CMax4 = new Vector4(maximum); var CMax4 = new Vector4(maximum);
Vector4 COff4 = new Vector4(MathF.Ceiling(maximum / 2)); var COff4 = new Vector4(MathF.Ceiling(maximum / 2));
<# <#
@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void NormalizeColorsAndRoundInplaceAvx2(float maximum) public void NormalizeColorsAndRoundInplaceAvx2(float maximum)
{ {
Vector<float> off = new Vector<float>(MathF.Ceiling(maximum / 2)); var off = new Vector<float>(MathF.Ceiling(maximum / 2));
Vector<float> max = new Vector<float>(maximum); var max = new Vector<float>(maximum);
<# <#
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
char srcCoord = coordz[j % 4]; char srcCoord = coordz[j % 4];
char srcSide = (j / 4) % 2 == 0 ? 'L' : 'R'; 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); Write(expression);
} }

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{ {
fixed (Vector4* ptr = &this.V0L) fixed (Vector4* ptr = &this.V0L)
{ {
float* fp = (float*)ptr; var fp = (float*)ptr;
for (int i = 0; i < Size; i++) for (int i = 0; i < Size; i++)
{ {
dest[i] = (int)fp[i]; dest[i] = (int)fp[i];
@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
public float[] ToArray() public float[] ToArray()
{ {
float[] result = new float[Size]; var result = new float[Size];
this.CopyTo(result); this.CopyTo(result);
return result; return result;
} }

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

@ -538,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
return; return;
} }
byte[] profile = new byte[remaining]; var profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining); this.InputStream.Read(profile, 0, remaining);
if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker))
@ -571,14 +571,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
return; return;
} }
byte[] identifier = new byte[Icclength]; var identifier = new byte[Icclength];
this.InputStream.Read(identifier, 0, Icclength); this.InputStream.Read(identifier, 0, Icclength);
remaining -= Icclength; // We have read it by this point remaining -= Icclength; // We have read it by this point
if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker)) if (ProfileResolver.IsProfile(identifier, ProfileResolver.IccMarker))
{ {
this.isIcc = true; this.isIcc = true;
byte[] profile = new byte[remaining]; var profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining); this.InputStream.Read(profile, 0, remaining);
if (this.iccData is null) if (this.iccData is null)

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

@ -183,12 +183,12 @@ namespace SixLabors.ImageSharp.Formats.Png
break; break;
case PngChunkType.Palette: 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); Buffer.BlockCopy(chunk.Data.Array, 0, pal, 0, chunk.Length);
this.palette = pal; this.palette = pal;
break; break;
case PngChunkType.Transparency: 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); Buffer.BlockCopy(chunk.Data.Array, 0, alpha, 0, chunk.Length);
this.paletteAlpha = alpha; this.paletteAlpha = alpha;
this.AssignTransparentMarkers(alpha, pngMetadata); this.AssignTransparentMarkers(alpha, pngMetadata);
@ -205,7 +205,7 @@ namespace SixLabors.ImageSharp.Formats.Png
case PngChunkType.Exif: case PngChunkType.Exif:
if (!this.ignoreMetadata) 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); Buffer.BlockCopy(chunk.Data.Array, 0, exifData, 0, chunk.Length);
metadata.ExifProfile = new ExifProfile(exifData); metadata.ExifProfile = new ExifProfile(exifData);
} }

2
src/ImageSharp/ImageFrameCollection{TPixel}.cs

@ -347,7 +347,7 @@ namespace SixLabors.ImageSharp
private ImageFrame<TPixel> CopyNonCompatibleFrame(ImageFrame source) private ImageFrame<TPixel> CopyNonCompatibleFrame(ImageFrame source)
{ {
ImageFrame<TPixel> result = new ImageFrame<TPixel>( var result = new ImageFrame<TPixel>(
this.parent.GetConfiguration(), this.parent.GetConfiguration(),
source.Size(), source.Size(),
source.Metadata.DeepClone()); source.Metadata.DeepClone());

2
src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs

@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
length += 4 + 2; length += 4 + 2;
byte[] result = new byte[length]; var result = new byte[length];
int i = 0; int i = 0;

14
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. // Licensed under the Apache License, Version 2.0.
using System.Numerics; using System.Numerics;
@ -18,13 +18,13 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{ {
ushort segmentCount = this.ReadUInt16(); ushort segmentCount = this.ReadUInt16();
this.AddIndex(2); // 2 bytes reserved 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++) for (int i = 0; i < breakPoints.Length; i++)
{ {
breakPoints[i] = this.ReadSingle(); breakPoints[i] = this.ReadSingle();
} }
IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; var segments = new IccCurveSegment[segmentCount];
for (int i = 0; i < segmentCount; i++) for (int i = 0; i < segmentCount; i++)
{ {
segments[i] = this.ReadCurveSegment(); segments[i] = this.ReadCurveSegment();
@ -41,19 +41,19 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccResponseCurve ReadResponseCurve(int channelCount) public IccResponseCurve ReadResponseCurve(int channelCount)
{ {
var type = (IccCurveMeasurementEncodings)this.ReadUInt32(); var type = (IccCurveMeasurementEncodings)this.ReadUInt32();
uint[] measurement = new uint[channelCount]; var measurement = new uint[channelCount];
for (int i = 0; i < channelCount; i++) for (int i = 0; i < channelCount; i++)
{ {
measurement[i] = this.ReadUInt32(); measurement[i] = this.ReadUInt32();
} }
Vector3[] xyzValues = new Vector3[channelCount]; var xyzValues = new Vector3[channelCount];
for (int i = 0; i < channelCount; i++) for (int i = 0; i < channelCount; i++)
{ {
xyzValues[i] = this.ReadXyzNumber(); xyzValues[i] = this.ReadXyzNumber();
} }
IccResponseNumber[][] response = new IccResponseNumber[channelCount][]; var response = new IccResponseNumber[channelCount][];
for (int i = 0; i < channelCount; i++) for (int i = 0; i < channelCount; i++)
{ {
response[i] = new IccResponseNumber[measurement[i]]; response[i] = new IccResponseNumber[measurement[i]];
@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccSampledCurveElement ReadSampledCurveElement() public IccSampledCurveElement ReadSampledCurveElement()
{ {
uint count = this.ReadUInt32(); uint count = this.ReadUInt32();
float[] entries = new float[count]; var entries = new float[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
entries[i] = this.ReadSingle(); entries[i] = this.ReadSingle();

12
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read LUT</returns> /// <returns>The read LUT</returns>
public IccLut ReadLut16(int count) public IccLut ReadLut16(int count)
{ {
ushort[] values = new ushort[count]; var values = new ushort[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
values[i] = this.ReadUInt16(); values[i] = this.ReadUInt16();
@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat)
{ {
// Grid-points are always 16 bytes long but only 0-inChCount are used // 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); Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount);
if (!isFloat) if (!isFloat)
@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
const float Max = byte.MaxValue; const float Max = byte.MaxValue;
float[][] values = new float[length][]; var values = new float[length][];
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
values[i] = new float[outChannelCount]; values[i] = new float[outChannelCount];
@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
const float Max = ushort.MaxValue; const float Max = ushort.MaxValue;
float[][] values = new float[length][]; var values = new float[length][];
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
values[i] = new float[outChannelCount]; values[i] = new float[outChannelCount];
@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
length /= inChCount; length /= inChCount;
float[][] values = new float[length][]; var values = new float[length][];
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
values[i] = new float[outChCount]; values[i] = new float[outChCount];

6
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. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Metadata.Profiles.Icc namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read matrix</returns> /// <returns>The read matrix</returns>
public float[,] ReadMatrix(int xCount, int yCount, bool isSingle) 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 y = 0; y < yCount; y++)
{ {
for (int x = 0; x < xCount; x++) for (int x = 0; x < xCount; x++)
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read matrix</returns> /// <returns>The read matrix</returns>
public float[] ReadMatrix(int yCount, bool isSingle) public float[] ReadMatrix(int yCount, bool isSingle)
{ {
float[] matrix = new float[yCount]; var matrix = new float[yCount];
for (int i = 0; i < yCount; i++) for (int i = 0; i < yCount; i++)
{ {
if (isSingle) if (isSingle)

4
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. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Metadata.Profiles.Icc namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read <see cref="IccCurveSetProcessElement"/></returns> /// <returns>The read <see cref="IccCurveSetProcessElement"/></returns>
public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount) public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount)
{ {
IccOneDimensionalCurve[] curves = new IccOneDimensionalCurve[inChannelCount]; var curves = new IccOneDimensionalCurve[inChannelCount];
for (int i = 0; i < inChannelCount; i++) for (int i = 0; i < inChannelCount; i++)
{ {
curves[i] = this.ReadOneDimensionalCurve(); curves[i] = this.ReadOneDimensionalCurve();

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{ {
string name = this.ReadAsciiString(32); string name = this.ReadAsciiString(32);
ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; 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++) for (int i = 0; i < deviceCoordCount; i++)
{ {

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read bytes</returns> /// <returns>The read bytes</returns>
public byte[] ReadBytes(int count) 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); Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count);
return bytes; return bytes;
} }

28
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs

@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
else else
{ {
// The type is not know, so the values need be read // 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++) for (int i = 0; i < channelCount; i++)
{ {
values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() };
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
return new IccCurveTagDataEntry(this.ReadUFix8()); return new IccCurveTagDataEntry(this.ReadUFix8());
} }
float[] cdata = new float[pointCount]; var cdata = new float[pointCount];
for (int i = 0; i < pointCount; i++) for (int i = 0; i < pointCount; i++)
{ {
cdata[i] = this.ReadUInt16() / 65535f; cdata[i] = this.ReadUInt16() / 65535f;
@ -264,7 +264,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
// Input LUT // Input LUT
var inValues = new IccLut[inChCount]; var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount]; var gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++) for (int i = 0; i < inChCount; i++)
{ {
inValues[i] = this.ReadLut16(inTableCount); inValues[i] = this.ReadLut16(inTableCount);
@ -299,7 +299,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
// Input LUT // Input LUT
var inValues = new IccLut[inChCount]; var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount]; var gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++) for (int i = 0; i < inChCount; i++)
{ {
inValues[i] = this.ReadLut8(); inValues[i] = this.ReadLut8();
@ -464,8 +464,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
var text = new IccLocalizedString[recordCount]; var text = new IccLocalizedString[recordCount];
var culture = new CultureInfo[recordCount]; var culture = new CultureInfo[recordCount];
uint[] length = new uint[recordCount]; var length = new uint[recordCount];
uint[] offset = new uint[recordCount]; var offset = new uint[recordCount];
for (int i = 0; i < recordCount; i++) for (int i = 0; i < recordCount; i++)
{ {
@ -627,7 +627,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
ushort channelCount = this.ReadUInt16(); ushort channelCount = this.ReadUInt16();
ushort measurementCount = this.ReadUInt16(); ushort measurementCount = this.ReadUInt16();
uint[] offset = new uint[measurementCount]; var offset = new uint[measurementCount];
for (int i = 0; i < measurementCount; i++) for (int i = 0; i < measurementCount; i++)
{ {
offset[i] = this.ReadUInt32(); offset[i] = this.ReadUInt32();
@ -651,7 +651,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size) public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size)
{ {
uint count = (size - 8) / 4; uint count = (size - 8) / 4;
float[] arrayData = new float[count]; var arrayData = new float[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadFix16() / 256f; arrayData[i] = this.ReadFix16() / 256f;
@ -687,7 +687,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size) public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
{ {
uint count = (size - 8) / 4; uint count = (size - 8) / 4;
float[] arrayData = new float[count]; var arrayData = new float[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadUFix16(); arrayData[i] = this.ReadUFix16();
@ -704,7 +704,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size) public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
{ {
uint count = (size - 8) / 2; uint count = (size - 8) / 2;
ushort[] arrayData = new ushort[count]; var arrayData = new ushort[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadUInt16(); arrayData[i] = this.ReadUInt16();
@ -721,7 +721,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size) public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
{ {
uint count = (size - 8) / 4; uint count = (size - 8) / 4;
uint[] arrayData = new uint[count]; var arrayData = new uint[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadUInt32(); arrayData[i] = this.ReadUInt32();
@ -738,7 +738,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size) public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size)
{ {
uint count = (size - 8) / 8; uint count = (size - 8) / 8;
ulong[] arrayData = new ulong[count]; var arrayData = new ulong[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
arrayData[i] = this.ReadUInt64(); arrayData[i] = this.ReadUInt64();
@ -878,14 +878,14 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size) public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
{ {
uint ucrCount = this.ReadUInt32(); uint ucrCount = this.ReadUInt32();
ushort[] ucrCurve = new ushort[ucrCount]; var ucrCurve = new ushort[ucrCount];
for (int i = 0; i < ucrCurve.Length; i++) for (int i = 0; i < ucrCurve.Length; i++)
{ {
ucrCurve[i] = this.ReadUInt16(); ucrCurve[i] = this.ReadUInt16();
} }
uint bgCount = this.ReadUInt32(); uint bgCount = this.ReadUInt32();
ushort[] bgCurve = new ushort[bgCount]; var bgCurve = new ushort[bgCount];
for (int i = 0; i < bgCurve.Length; i++) for (int i = 0; i < bgCurve.Length; i++)
{ {
bgCurve[i] = this.ReadUInt16(); bgCurve[i] = this.ReadUInt16();

6
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 // TODO: Investigate cost of Linq GroupBy
IGrouping<string, IccLocalizedString>[] texts = value.Texts.GroupBy(t => t.Text).ToArray(); IGrouping<string, IccLocalizedString>[] texts = value.Texts.GroupBy(t => t.Text).ToArray();
uint[] offset = new uint[texts.Length]; var offset = new uint[texts.Length];
int[] lengths = new int[texts.Length]; var lengths = new int[texts.Length];
for (int i = 0; i < texts.Length; i++) for (int i = 0; i < texts.Length; i++)
{ {
@ -746,7 +746,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
long tablePosition = this.dataStream.Position; long tablePosition = this.dataStream.Position;
this.dataStream.Position += value.Curves.Length * 4; 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++) for (int i = 0; i < value.Curves.Length; i++)
{ {

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
const int profileIdPos = 84; const int profileIdPos = 84;
// need to copy some values because they need to be zero for the hashing // 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, profileFlagPos, temp, 0, 4);
Buffer.BlockCopy(data, renderingIntentPos, temp, 4, 4); Buffer.BlockCopy(data, renderingIntentPos, temp, 4, 4);
Buffer.BlockCopy(data, profileIdPos, temp, 8, 16); Buffer.BlockCopy(data, profileIdPos, temp, 8, 16);
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{ {
if (this.data != null) 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); Buffer.BlockCopy(this.data, 0, copy, 0, copy.Length);
return copy; return copy;
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
&& p3 >= 0x41 && p3 <= 0x5A && p3 >= 0x41 && p3 <= 0x5A
&& p4 >= 0x41 && p4 <= 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); return new CultureInfo(culture);
} }

2
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. // Licensed under the Apache License, Version 2.0.
// <auto-generated /> // <auto-generated />

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

@ -1,4 +1,4 @@
<# <#
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#> #>
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
{ {
<# <#
string[] composers = new []{ var composers = new []{
"Src", "Src",
"SrcAtop", "SrcAtop",
"SrcOver", "SrcOver",
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
"Xor", "Xor",
}; };
string[] blenders = new []{ var blenders = new []{
"Normal", "Normal",
"Multiply", "Multiply",
"Add", "Add",
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
foreach(var composer in composers) { foreach(var composer in composers) {
foreach(var blender in blenders) { foreach(var blender in blenders) {
string blender_composer= $"{blender}{composer}"; var blender_composer= $"{blender}{composer}";
#> #>
internal class <#= blender_composer#> : PixelBlender<TPixel> internal class <#= blender_composer#> : PixelBlender<TPixel>

110
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. // Licensed under the Apache License, Version 2.0.
// <auto-generated /> // <auto-generated />
@ -111,7 +111,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -123,7 +122,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -135,7 +133,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -147,7 +144,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -159,7 +155,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -171,7 +166,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -183,7 +177,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -195,7 +188,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -207,7 +199,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -219,7 +210,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -231,7 +221,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -243,7 +232,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel NormalXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel NormalXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -349,7 +337,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -361,7 +348,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -373,7 +359,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -385,7 +370,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -397,7 +381,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -409,7 +392,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -421,7 +403,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -433,7 +414,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -445,7 +425,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -457,7 +436,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -469,7 +447,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -481,7 +458,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel MultiplyXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel MultiplyXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -587,7 +563,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -599,7 +574,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -611,7 +585,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -623,7 +596,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -635,7 +607,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -647,7 +618,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -659,7 +629,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -671,7 +640,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -683,7 +651,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -695,7 +662,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -707,7 +673,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -719,7 +684,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel AddXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel AddXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -825,7 +789,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -837,7 +800,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -849,7 +811,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -861,7 +822,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -873,7 +833,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -885,7 +844,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -897,7 +855,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -909,7 +866,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -921,7 +877,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -933,7 +888,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -945,7 +899,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -957,7 +910,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel SubtractXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel SubtractXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1063,7 +1015,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1075,7 +1026,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1087,7 +1037,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1099,7 +1048,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1111,7 +1059,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1123,7 +1070,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1135,7 +1081,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1147,7 +1092,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1159,7 +1103,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1171,7 +1114,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1183,7 +1125,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1195,7 +1136,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel ScreenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel ScreenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1301,7 +1241,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1313,7 +1252,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1325,7 +1263,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1337,7 +1274,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1349,7 +1285,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1361,7 +1296,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1373,7 +1307,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1385,7 +1318,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1397,7 +1329,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1409,7 +1340,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1421,7 +1351,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1433,7 +1362,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel DarkenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel DarkenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1539,7 +1467,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1551,7 +1478,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1563,7 +1489,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1575,7 +1500,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1587,7 +1511,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1599,7 +1522,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1611,7 +1533,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1623,7 +1544,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1635,7 +1555,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1647,7 +1566,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1659,7 +1577,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1671,7 +1588,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel LightenXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel LightenXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1777,7 +1693,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1789,7 +1704,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1801,7 +1715,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1813,7 +1726,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1825,7 +1737,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlaySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlaySrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1837,7 +1748,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1849,7 +1759,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1861,7 +1770,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1873,7 +1781,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1885,7 +1792,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1897,7 +1803,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -1909,7 +1814,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel OverlayXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel OverlayXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2015,7 +1919,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return Clear(backdrop, source); return Clear(backdrop, source);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrc<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrc<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2027,7 +1930,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2039,7 +1941,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2051,7 +1952,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2063,7 +1963,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightSrcOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2075,7 +1974,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDest<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDest<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2087,7 +1985,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestAtop<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2099,7 +1996,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestOver<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2111,7 +2007,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestIn<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2123,7 +2018,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightDestOut<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2135,7 +2029,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightClear<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightClear<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -2147,7 +2040,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel HardLightXor<TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel HardLightXor<TPixel>(TPixel backdrop, TPixel source, float opacity)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>

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

@ -1,4 +1,4 @@
<# <#
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#> #>
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
<# <#
string[] composers = new []{ var composers = new []{
"Src", "Src",
"SrcAtop", "SrcAtop",
"SrcOver", "SrcOver",
@ -156,7 +156,7 @@ string[] composers = new []{
"Xor", "Xor",
}; };
string[] blenders = new []{ var blenders = new []{
"Normal", "Normal",
"Multiply", "Multiply",
"Add", "Add",

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) 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; scaled -= Vector2.One;
this.PackedValue = Pack(scaled.X, scaled.Y); this.PackedValue = Pack(scaled.X, scaled.Y);
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) 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; scaled -= Vector2.One;
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) 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; scaled -= Vector2.One;
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) 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); scaled -= new Vector2(32767F);
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives
{ {
if (simplify) if (simplify)
{ {
LongRational rational = new LongRational(numerator, denominator).Simplify(); var rational = new LongRational(numerator, denominator).Simplify();
this.Numerator = (uint)rational.Numerator; this.Numerator = (uint)rational.Numerator;
this.Denominator = (uint)rational.Denominator; this.Denominator = (uint)rational.Denominator;

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives
{ {
if (simplify) if (simplify)
{ {
LongRational rational = new LongRational(numerator, denominator).Simplify(); var rational = new LongRational(numerator, denominator).Simplify();
this.Numerator = (int)rational.Numerator; this.Numerator = (int)rational.Numerator;
this.Denominator = (int)rational.Denominator; this.Denominator = (int)rational.Denominator;

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing
Guard.NotNull(operation, nameof(operation)); Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed(); source.EnsureNotDisposed();
ProcessingVisitor visitor = new ProcessingVisitor(operation, true); var visitor = new ProcessingVisitor(operation, true);
source.AcceptVisitor(visitor); source.AcceptVisitor(visitor);
} }
@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing
Guard.NotNull(operation, nameof(operation)); Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed(); source.EnsureNotDisposed();
ProcessingVisitor visitor = new ProcessingVisitor(operation, false); var visitor = new ProcessingVisitor(operation, false);
source.AcceptVisitor(visitor); source.AcceptVisitor(visitor);
return visitor.ResultImage; return visitor.ResultImage;
} }

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

@ -69,10 +69,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
int maxIntensity = 0; int maxIntensity = 0;
int maxIndex = 0; int maxIndex = 0;
int[] intensityBin = new int[levels]; var intensityBin = new int[levels];
float[] redBin = new float[levels]; var redBin = new float[levels];
float[] blueBin = new float[levels]; var blueBin = new float[levels];
float[] greenBin = new float[levels]; var greenBin = new float[levels];
for (int fy = 0; fy <= radius; fy++) for (int fy = 0; fy <= radius; fy++)
{ {

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
public IFrameQuantizer<TPixel> CreateFrameQuantizer<TPixel>(Configuration configuration) public IFrameQuantizer<TPixel> CreateFrameQuantizer<TPixel>(Configuration configuration)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel[] palette = new TPixel[this.Palette.Length]; var palette = new TPixel[this.Palette.Length];
Color.ToPixel(configuration, this.Palette.Span, palette.AsSpan()); Color.ToPixel(configuration, this.Palette.Span, palette.AsSpan());
return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette); return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette);
} }
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
maxColors = maxColors.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors); maxColors = maxColors.Clamp(QuantizerConstants.MinColors, QuantizerConstants.MaxColors);
int max = Math.Min(maxColors, this.Palette.Length); 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()); Color.ToPixel(configuration, this.Palette.Span.Slice(0, max), palette.AsSpan());
return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette); return new PaletteFrameQuantizer<TPixel>(this.Diffuser, palette);
} }

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -828,7 +828,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
private void BuildCube() private void BuildCube()
{ {
this.colorCube = new Box[this.colors]; 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]; ref Box cube = ref this.colorCube[0];
cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0; cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0;

4
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
private static byte[] CreateTestBytes() private static byte[] CreateTestBytes()
{ {
byte[] buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; var buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3];
var random = new Random(); var random = new Random();
random.NextBytes(buffer); random.NextBytes(buffer);

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -67,10 +67,10 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
float maxVal = 255f) float maxVal = 255f)
{ {
var rnd = new Random(42); var rnd = new Random(42);
Buffer2D<float>[] buffers = new Buffer2D<float>[componentCount]; var buffers = new Buffer2D<float>[componentCount];
for (int i = 0; i < componentCount; i++) for (int i = 0; i < componentCount; i++)
{ {
float[] values = new float[inputBufferLength]; var values = new float[inputBufferLength];
for (int j = 0; j < inputBufferLength; j++) for (int j = 0; j < inputBufferLength; j++)
{ {

32
tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs

@ -132,13 +132,13 @@ namespace SixLabors.ImageSharp.Benchmarks
public unsafe void RgbaToYcbCrScalarFloat() public unsafe void RgbaToYcbCrScalarFloat()
{ {
// Copy the input to the stack: // Copy the input to the stack:
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); var input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output: // On-stack output:
Result result = default; Result result = default;
float* yPtr = (float*)&result.Y; var yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb; var cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr; var crPtr = (float*)&result.Cr;
// end of code-bloat block :) // end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++) for (int i = 0; i < InputColorCount; i++)
@ -158,20 +158,20 @@ namespace SixLabors.ImageSharp.Benchmarks
public unsafe void RgbaToYcbCrSimdFloat() public unsafe void RgbaToYcbCrSimdFloat()
{ {
// Copy the input to the stack: // Copy the input to the stack:
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); var input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output: // On-stack output:
Result result = default; Result result = default;
float* yPtr = (float*)&result.Y; var yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb; var cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr; var crPtr = (float*)&result.Cr;
// end of code-bloat block :) // end of code-bloat block :)
for (int i = 0; i < InputColorCount; i++) for (int i = 0; i < InputColorCount; i++)
{ {
int i3 = i * 3; int i3 = i * 3;
Vector3 vectorRgb = new Vector3( var vectorRgb = new Vector3(
input.Data[i3 + 0], input.Data[i3 + 0],
input.Data[i3 + 1], input.Data[i3 + 1],
input.Data[i3 + 2] input.Data[i3 + 2]
@ -194,9 +194,9 @@ namespace SixLabors.ImageSharp.Benchmarks
// On-stack output: // On-stack output:
Result result = default; Result result = default;
float* yPtr = (float*)&result.Y; var yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb; var cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr; var crPtr = (float*)&result.Cr;
// end of code-bloat block :) // end of code-bloat block :)
var yCoeffs = new Vector<int>(ScaledCoeffs.Y); var yCoeffs = new Vector<int>(ScaledCoeffs.Y);
@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.Benchmarks
for (int i = 0; i < InputColorCount; i += 2) for (int i = 0; i < InputColorCount; i += 2)
{ {
Vector<int> rgb = new Vector<int>(this.inputSourceRGBAsInteger, i * 3); var rgb = new Vector<int>(this.inputSourceRGBAsInteger, i * 3);
Vector<int> y = yCoeffs * rgb; Vector<int> y = yCoeffs * rgb;
Vector<int> cb = cbCoeffs * rgb; Vector<int> cb = cbCoeffs * rgb;
@ -264,7 +264,7 @@ namespace SixLabors.ImageSharp.Benchmarks
for (int i = 0; i < InputColorCount; i += 2) for (int i = 0; i < InputColorCount; i += 2)
{ {
Vector<int> rgb = new Vector<int>(this.inputSourceRGBAsInteger, i * 3); var rgb = new Vector<int>(this.inputSourceRGBAsInteger, i * 3);
Vector<int> y = yCoeffs * rgb; Vector<int> y = yCoeffs * rgb;
Vector<int> cb = cbCoeffs * rgb; Vector<int> cb = cbCoeffs * rgb;
@ -299,7 +299,7 @@ namespace SixLabors.ImageSharp.Benchmarks
public unsafe void RgbaToYcbCrScaledInteger() public unsafe void RgbaToYcbCrScaledInteger()
{ {
// Copy the input to the stack: // Copy the input to the stack:
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); var input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output: // On-stack output:
Result result = default; Result result = default;
@ -338,7 +338,7 @@ namespace SixLabors.ImageSharp.Benchmarks
public unsafe void RgbaToYcbCrScaledIntegerLut() public unsafe void RgbaToYcbCrScaledIntegerLut()
{ {
// Copy the input to the stack: // Copy the input to the stack:
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB); var input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output: // On-stack output:
Result result = default; Result result = default;

6
tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; 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) private static void BitopsSimdImpl(ref Octet.OfUInt32 s, ref Octet.OfUInt32 d)
{ {
Vector<uint> sVec = Unsafe.As<Octet.OfUInt32, Vector<uint>>(ref s); Vector<uint> sVec = Unsafe.As<Octet.OfUInt32, Vector<uint>>(ref s);
Vector<uint> aMask = new Vector<uint>(0xFF00FF00); var aMask = new Vector<uint>(0xFF00FF00);
Vector<uint> bMask = new Vector<uint>(0x00FF00FF); var bMask = new Vector<uint>(0x00FF00FF);
Vector<uint> aa = sVec & aMask; Vector<uint> aa = sVec & aMask;
Vector<uint> bb = sVec & bMask; Vector<uint> bb = sVec & bMask;

4
tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs

@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
[Benchmark] [Benchmark]
public void Simd() public void Simd()
{ {
Vector<uint> v = new Vector<uint>(this.testValue); var v = new Vector<uint>(this.testValue);
for (int i = 0; i < this.input.Length; i+=Vector<uint>.Count) for (int i = 0; i < this.input.Length; i+=Vector<uint>.Count)
{ {
Vector<uint> a = new Vector<uint>(this.input, i); var a = new Vector<uint>(this.input, i);
a = Vector.BitwiseOr(a, v); a = Vector.BitwiseOr(a, v);
a.CopyTo(this.result, i); a.CopyTo(this.result, i);
} }

6
tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs

@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
[Benchmark] [Benchmark]
public void SimdMultiplyByVector() public void SimdMultiplyByVector()
{ {
Vector<float> v = new Vector<float>(this.testValue); var v = new Vector<float>(this.testValue);
for (int i = 0; i < this.input.Length; i += Vector<uint>.Count) for (int i = 0; i < this.input.Length; i += Vector<uint>.Count)
{ {
Vector<float> a = new Vector<float>(this.input, i); var a = new Vector<float>(this.input, i);
a = a * v; a = a * v;
a.CopyTo(this.result, i); a.CopyTo(this.result, i);
} }
@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
for (int i = 0; i < this.input.Length; i += Vector<uint>.Count) for (int i = 0; i < this.input.Length; i += Vector<uint>.Count)
{ {
Vector<float> a = new Vector<float>(this.input, i); var a = new Vector<float>(this.input, i);
a = a * v; a = a * v;
a.CopyTo(this.result, i); a.CopyTo(this.result, i);
} }

2
tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs

@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
for (int i = 0; i < this.input.Length; i += Vector<uint>.Count) for (int i = 0; i < this.input.Length; i += Vector<uint>.Count)
{ {
Vector<uint> a = new Vector<uint>(this.input, i); var a = new Vector<uint>(this.input, i);
a = a * v; a = a * v;
a.CopyTo(this.result, i); a.CopyTo(this.result, i);
} }

2
tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs

@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
{ {
for (int i = 0; i < this.input.Length; i += Vector<uint>.Count) for (int i = 0; i < this.input.Length; i += Vector<uint>.Count)
{ {
Vector<uint> a = new Vector<uint>(this.input, i); var a = new Vector<uint>(this.input, i);
Vector<float> b = Vector.AsVectorSingle(a); Vector<float> b = Vector.AsVectorSingle(a);
b.CopyTo(this.result, i); b.CopyTo(this.result, i);
} }

8
tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs

@ -44,11 +44,11 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
[Benchmark] [Benchmark]
public void FetchWithVectorConstructor() public void FetchWithVectorConstructor()
{ {
Vector<float> v = new Vector<float>(this.testValue); var v = new Vector<float>(this.testValue);
for (int i = 0; i < this.data.Length; i += Vector<uint>.Count) for (int i = 0; i < this.data.Length; i += Vector<uint>.Count)
{ {
Vector<float> a = new Vector<float>(this.data, i); var a = new Vector<float>(this.data, i);
a = a * v; a = a * v;
a.CopyTo(this.data, i); a.CopyTo(this.data, i);
} }
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
[Benchmark] [Benchmark]
public void FetchWithUnsafeCast() public void FetchWithUnsafeCast()
{ {
Vector<float> v = new Vector<float>(this.testValue); var v = new Vector<float>(this.testValue);
ref Vector<float> start = ref Unsafe.As<float, Vector<float>>(ref this.data[0]); ref Vector<float> start = ref Unsafe.As<float, Vector<float>>(ref this.data[0]);
int n = this.InputSize / Vector<uint>.Count; int n = this.InputSize / Vector<uint>.Count;
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
[Benchmark] [Benchmark]
public void FetchWithUnsafeCastNoTempVector() public void FetchWithUnsafeCastNoTempVector()
{ {
Vector<float> v = new Vector<float>(this.testValue); var v = new Vector<float>(this.testValue);
ref Vector<float> start = ref Unsafe.As<float, Vector<float>>(ref this.data[0]); ref Vector<float> start = ref Unsafe.As<float, Vector<float>>(ref this.data[0]);
int n = this.InputSize / Vector<uint>.Count; int n = this.InputSize / Vector<uint>.Count;

12
tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba64() public void Rgba64()
{ {
Rgba64 source = new Rgba64(100, 2222, 3333, 4444); var source = new Rgba64(100, 2222, 3333, 4444);
// Act: // Act:
Color color = source; Color color = source;
@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba32() public void Rgba32()
{ {
Rgba32 source = new Rgba32(1, 22, 33, 231); var source = new Rgba32(1, 22, 33, 231);
// Act: // Act:
Color color = source; Color color = source;
@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Argb32() public void Argb32()
{ {
Argb32 source = new Argb32(1, 22, 33, 231); var source = new Argb32(1, 22, 33, 231);
// Act: // Act:
Color color = source; Color color = source;
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgra32() public void Bgra32()
{ {
Bgra32 source = new Bgra32(1, 22, 33, 231); var source = new Bgra32(1, 22, 33, 231);
// Act: // Act:
Color color = source; Color color = source;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgb24() public void Rgb24()
{ {
Rgb24 source = new Rgb24(1, 22, 231); var source = new Rgb24(1, 22, 231);
// Act: // Act:
Color color = source; Color color = source;
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgr24() public void Bgr24()
{ {
Bgr24 source = new Bgr24(1, 22, 231); var source = new Bgr24(1, 22, 231);
// Act: // Act:
Color color = source; Color color = source;

24
tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs

@ -14,10 +14,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba64() public void Rgba64()
{ {
Rgba64 source = new Rgba64(100, 2222, 3333, 4444); var source = new Rgba64(100, 2222, 3333, 4444);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgba64 data = color; Rgba64 data = color;
@ -27,10 +27,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba32() public void Rgba32()
{ {
Rgba32 source = new Rgba32(1, 22, 33, 231); var source = new Rgba32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgba32 data = color; Rgba32 data = color;
@ -40,10 +40,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Argb32() public void Argb32()
{ {
Argb32 source = new Argb32(1, 22, 33, 231); var source = new Argb32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Argb32 data = color; Argb32 data = color;
@ -53,10 +53,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgra32() public void Bgra32()
{ {
Bgra32 source = new Bgra32(1, 22, 33, 231); var source = new Bgra32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Bgra32 data = color; Bgra32 data = color;
@ -66,10 +66,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgb24() public void Rgb24()
{ {
Rgb24 source = new Rgb24(1, 22, 231); var source = new Rgb24(1, 22, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgb24 data = color; Rgb24 data = color;
@ -79,10 +79,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgr24() public void Bgr24()
{ {
Bgr24 source = new Bgr24(1, 22, 231); var source = new Bgr24(1, 22, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Bgr24 data = color; Bgr24 data = color;

24
tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs

@ -14,10 +14,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba64() public void Rgba64()
{ {
Rgba64 source = new Rgba64(100, 2222, 3333, 4444); var source = new Rgba64(100, 2222, 3333, 4444);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgba64 data = color.ToPixel<Rgba64>(); Rgba64 data = color.ToPixel<Rgba64>();
@ -27,10 +27,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgba32() public void Rgba32()
{ {
Rgba32 source = new Rgba32(1, 22, 33, 231); var source = new Rgba32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgba32 data = color.ToPixel<Rgba32>(); Rgba32 data = color.ToPixel<Rgba32>();
@ -40,10 +40,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Argb32() public void Argb32()
{ {
Argb32 source = new Argb32(1, 22, 33, 231); var source = new Argb32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Argb32 data = color.ToPixel<Argb32>(); Argb32 data = color.ToPixel<Argb32>();
@ -53,10 +53,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgra32() public void Bgra32()
{ {
Bgra32 source = new Bgra32(1, 22, 33, 231); var source = new Bgra32(1, 22, 33, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Bgra32 data = color.ToPixel<Bgra32>(); Bgra32 data = color.ToPixel<Bgra32>();
@ -66,10 +66,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Rgb24() public void Rgb24()
{ {
Rgb24 source = new Rgb24(1, 22, 231); var source = new Rgb24(1, 22, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Rgb24 data = color.ToPixel<Rgb24>(); Rgb24 data = color.ToPixel<Rgb24>();
@ -79,10 +79,10 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Bgr24() public void Bgr24()
{ {
Bgr24 source = new Bgr24(1, 22, 231); var source = new Bgr24(1, 22, 231);
// Act: // Act:
Color color = new Color(source); var color = new Color(source);
// Assert: // Assert:
Bgr24 data = color.ToPixel<Bgr24>(); Bgr24 data = color.ToPixel<Bgr24>();

2
tests/ImageSharp.Tests/Color/ColorTests.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests
Color c1 = Color.FromRgba(111, 222, 55, 255); Color c1 = Color.FromRgba(111, 222, 55, 255);
Color c2 = c1.WithAlpha(0.5f); 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); Assert.Equal(expected, (Rgba32)c2);
} }

2
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. // Licensed under the Apache License, Version 2.0.
using System.Numerics; using System.Numerics;

18
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Common
private static Vector<float> CreateExactTestVector1() private static Vector<float> CreateExactTestVector1()
{ {
float[] data = new float[Vector<float>.Count]; var data = new float[Vector<float>.Count];
data[0] = 0.1f; data[0] = 0.1f;
data[1] = 0.4f; data[1] = 0.4f;
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Common
private static Vector<float> CreateRandomTestVector(int seed, float min, float max) private static Vector<float> CreateRandomTestVector(int seed, float min, float max)
{ {
float[] data = new float[Vector<float>.Count]; var data = new float[Vector<float>.Count];
var rnd = new Random(seed); var rnd = new Random(seed);
@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.Common
float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256); float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256);
float[] normalized = orig.Select(f => f / 255f).ToArray(); float[] normalized = orig.Select(f => f / 255f).ToArray();
byte[] dest = new byte[count]; var dest = new byte[count];
SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(normalized, dest); SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(normalized, dest);
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Common
float[] source = new Random(seed).GenerateRandomFloatArray(count, 0, 1f); float[] source = new Random(seed).GenerateRandomFloatArray(count, 0, 1f);
byte[] dest = new byte[count]; var dest = new byte[count];
SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(source, dest); SimdUtils.BasicIntrinsics256.BulkConvertNormalizedFloatToByte(source, dest);
@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Common
Action<Memory<byte>, Memory<float>> convert) Action<Memory<byte>, Memory<float>> convert)
{ {
byte[] source = new Random(count).GenerateRandomByteArray(count); 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(); float[] expected = source.Select(b => (float)b / 255f).ToArray();
convert(source, result); convert(source, result);
@ -306,7 +306,7 @@ namespace SixLabors.ImageSharp.Tests.Common
seed = seed > 0 ? seed : count; seed = seed > 0 ? seed : count;
float[] source = new Random(seed).GenerateRandomFloatArray(count, -0.2f, 1.2f); float[] source = new Random(seed).GenerateRandomFloatArray(count, -0.2f, 1.2f);
byte[] expected = source.Select(NormalizedFloatToByte).ToArray(); byte[] expected = source.Select(NormalizedFloatToByte).ToArray();
byte[] actual = new byte[count]; var actual = new byte[count];
convert(source, actual); convert(source, actual);
@ -325,7 +325,7 @@ namespace SixLabors.ImageSharp.Tests.Common
private void MagicConvertToByte(float value) private void MagicConvertToByte(float value)
{ {
byte actual = MagicConvert(value / 256f); byte actual = MagicConvert(value / 256f);
byte expected = (byte)value; var expected = (byte)value;
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -362,7 +362,7 @@ namespace SixLabors.ImageSharp.Tests.Common
{ {
var magick = new Vector<float>(32768.0f); var magick = new Vector<float>(32768.0f);
Vector<float> scale = new Vector<float>(255f) / new Vector<float>(256f); var scale = new Vector<float>(255f) / new Vector<float>(256f);
Vector<float> x = MemoryMarshal.Cast<float, Vector<float>>(source)[0]; Vector<float> x = MemoryMarshal.Cast<float, Vector<float>>(source)[0];

8
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -75,13 +75,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
using (var blend = Image.Load<TPixel>(TestFile.Create(brushImage).Bytes)) using (var blend = Image.Load<TPixel>(TestFile.Create(brushImage).Bytes))
{ {
Size size = new Size(image.Width * 3 / 4, image.Height * 3 / 4); var size = new Size(image.Width * 3 / 4, image.Height * 3 / 4);
Point position = new Point(image.Width / 8, image.Height / 8); var position = new Point(image.Width / 8, image.Height / 8);
blend.Mutate(x => x.Resize(size.Width, size.Height, KnownResamplers.Bicubic)); blend.Mutate(x => x.Resize(size.Width, size.Height, KnownResamplers.Bicubic));
image.Mutate(x => x.DrawImage(blend, position, mode, opacity)); image.Mutate(x => x.DrawImage(blend, position, mode, opacity));
FormattableString testInfo = $"{System.IO.Path.GetFileNameWithoutExtension(brushImage)}-{mode}-{opacity}"; FormattableString testInfo = $"{System.IO.Path.GetFileNameWithoutExtension(brushImage)}-{mode}-{opacity}";
PngEncoder encoder = new PngEncoder(); var encoder = new PngEncoder();
if (provider.PixelType == PixelTypes.Rgba64) if (provider.PixelType == PixelTypes.Rgba64)
{ {

6
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void PathExtendingOffEdgeOfImageShouldNotBeCropped<TPixel>(TestImageProvider<TPixel> provider) public void PathExtendingOffEdgeOfImageShouldNotBeCropped<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = Color.White; var color = Color.White;
Pen pen = Pens.Solid(color, 5f); Pen pen = Pens.Solid(color, 5f);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
for (int i = 0; i < 300; i += 20) 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); x.DrawLines(pen, points);
} }
}, },

14
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}; };
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
GraphicsOptions options = new GraphicsOptions(antialias); var options = new GraphicsOptions(antialias);
string aa = antialias ? "" : "_NoAntialias"; string aa = antialias ? "" : "_NoAntialias";
FormattableString outputDetails = $"{colorName}_A{alpha}{aa}"; FormattableString outputDetails = $"{colorName}_A{alpha}{aa}";
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
new Vector2(8, 120) new Vector2(8, 120)
}; };
Color color = Color.LightGreen; var color = Color.LightGreen;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(color, points), c => c.FillPolygon(color, points),
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) 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); var brush = Brushes.Horizontal(color);
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var polygon = new SixLabors.Shapes.RectangularPolygon(10, 10, 190, 140); var polygon = new SixLabors.Shapes.RectangularPolygon(10, 10, 190, 140);
Color color = Color.White; var color = Color.White;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.Fill(color, polygon), c => c.Fill(color, polygon),
@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
float angle = GeometryUtilities.DegreeToRadian(angleDeg); float angle = GeometryUtilities.DegreeToRadian(angleDeg);
var polygon = new RegularPolygon(100, 100, vertices, radius, angle); 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})"; FormattableString testOutput = $"V({vertices})_R({radius})_Ang({angleDeg})";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var polygon = new EllipsePolygon(100, 100, 80, 120); var polygon = new EllipsePolygon(100, 100, 80, 120);
Color color = Color.Azure; var color = Color.Azure;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.Fill(color, polygon), c => c.Fill(color, polygon),

4
tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
Color color = Color.HotPink; var color = Color.HotPink;
image.Mutate(c => c.Fill(color)); image.Mutate(c => c.Fill(color));
image.DebugSave(provider, appendPixelTypeToFileName: false); image.DebugSave(provider, appendPixelTypeToFileName: false);
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
Color color = Color.HotPink; var color = Color.HotPink;
image.Mutate(c => c.Fill(color)); image.Mutate(c => c.Fill(color));
image.DebugSave(provider, appendSourceFileOrDescription: false); image.DebugSave(provider, appendSourceFileOrDescription: false);

12
tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont("OpenSans-Regular.ttf", 36); Font font = CreateFont("OpenSans-Regular.ttf", 36);
Color color = Color.Black; var color = Color.Black;
var text = "A short piece of text"; var text = "A short piece of text";
using (var img = provider.GetImage()) 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); float scalingFactor = Math.Min(img.Width / size.Width, img.Height / size.Height);
//create a new font //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 center = new PointF(img.Width / 2, img.Height / 2);
var textGraphicOptions = new TextGraphicsOptions(true) var textGraphicOptions = new TextGraphicsOptions(true)
@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
Color color = Color.Black; var color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
TextDrawingComparer, TextDrawingComparer,
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
HorizontalAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left,
}; };
Color color = Color.Black; var color = Color.Black;
// Based on the reported 0.0270% difference with AccuracyMultiple = 8 // Based on the reported 0.0270% difference with AccuracyMultiple = 8
// We should avoid quality regressions leading to higher difference! // We should avoid quality regressions leading to higher difference!
@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
Color color = Color.Black; var color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
OutlinedTextDrawingComparer, OutlinedTextDrawingComparer,
@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
Color color = Color.Black; var color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
OutlinedTextDrawingComparer, OutlinedTextDrawingComparer,

4
tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs

@ -1,4 +1,4 @@
using System; using System;
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using Xunit; using Xunit;
@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
{ {
var header = new BmpFileHeader(1, 2, 3, 4); var header = new BmpFileHeader(1, 2, 3, 4);
byte[] buffer = new byte[14]; var buffer = new byte[14];
header.WriteTo(buffer); header.WriteTo(buffer);

20
tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs

@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
() => () =>
{ {
// Block8x8F block = new Block8x8F(); // Block8x8F block = new Block8x8F();
float[] block = new float[64]; var block = new float[64];
for (int i = 0; i < Block8x8F.Size; i++) for (int i = 0; i < Block8x8F.Size; i++)
{ {
block[i] = i; block[i] = i;
@ -90,8 +90,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact] [Fact]
public void Load_Store_FloatArray() public void Load_Store_FloatArray()
{ {
float[] data = new float[Block8x8F.Size]; var data = new float[Block8x8F.Size];
float[] mirror = new float[Block8x8F.Size]; var mirror = new float[Block8x8F.Size];
for (int i = 0; i < Block8x8F.Size; i++) for (int i = 0; i < Block8x8F.Size; i++)
{ {
@ -115,8 +115,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact] [Fact]
public unsafe void Load_Store_FloatArray_Ptr() public unsafe void Load_Store_FloatArray_Ptr()
{ {
float[] data = new float[Block8x8F.Size]; var data = new float[Block8x8F.Size];
float[] mirror = new float[Block8x8F.Size]; var mirror = new float[Block8x8F.Size];
for (int i = 0; i < Block8x8F.Size; i++) for (int i = 0; i < Block8x8F.Size; i++)
{ {
@ -140,8 +140,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact] [Fact]
public void Load_Store_IntArray() public void Load_Store_IntArray()
{ {
int[] data = new int[Block8x8F.Size]; var data = new int[Block8x8F.Size];
int[] mirror = new int[Block8x8F.Size]; var mirror = new int[Block8x8F.Size];
for (int i = 0; i < Block8x8F.Size; i++) for (int i = 0; i < Block8x8F.Size; i++)
{ {
@ -174,7 +174,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var dest = new Block8x8F(); var dest = new Block8x8F();
source.TransposeInto(ref dest); source.TransposeInto(ref dest);
float[] actual = new float[64]; var actual = new float[64];
dest.CopyTo(actual); dest.CopyTo(actual);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
private static float[] Create8x8ColorCropTestData() private static float[] Create8x8ColorCropTestData()
{ {
float[] result = new float[64]; var result = new float[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
@ -230,7 +230,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Block8x8F dest = block; Block8x8F dest = block;
dest.NormalizeColorsInplace(255); dest.NormalizeColorsInplace(255);
float[] array = new float[64]; var array = new float[64];
dest.CopyTo(array); dest.CopyTo(array);
this.Output.WriteLine("Result:"); this.Output.WriteLine("Result:");
this.PrintLinearData(array); this.PrintLinearData(array);

22
tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void iDCT2D8x4_LeftPart() public void iDCT2D8x4_LeftPart()
{ {
float[] sourceArray = Create8x8FloatData(); float[] sourceArray = Create8x8FloatData();
float[] expectedDestArray = new float[64]; var expectedDestArray = new float[64];
ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray, expectedDestArray); 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); FastFloatingPointDCT.IDCT8x4_LeftPart(ref source, ref dest);
float[] actualDestArray = new float[64]; var actualDestArray = new float[64];
dest.CopyTo(actualDestArray); dest.CopyTo(actualDestArray);
this.Print8x8Data(expectedDestArray); this.Print8x8Data(expectedDestArray);
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void iDCT2D8x4_RightPart() public void iDCT2D8x4_RightPart()
{ {
float[] sourceArray = Create8x8FloatData(); 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)); 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); FastFloatingPointDCT.IDCT8x4_RightPart(ref source, ref dest);
float[] actualDestArray = new float[64]; var actualDestArray = new float[64];
dest.CopyTo(actualDestArray); dest.CopyTo(actualDestArray);
this.Print8x8Data(expectedDestArray); this.Print8x8Data(expectedDestArray);
@ -118,12 +118,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var destBlock = new Block8x8F(); var destBlock = new Block8x8F();
float[] expectedDest = new float[64]; var expectedDest = new float[64];
ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D8x4_32f(src, expectedDest); ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D8x4_32f(src, expectedDest);
FastFloatingPointDCT.FDCT8x4_LeftPart(ref srcBlock, ref destBlock); FastFloatingPointDCT.FDCT8x4_LeftPart(ref srcBlock, ref destBlock);
float[] actualDest = new float[64]; var actualDest = new float[64];
destBlock.CopyTo(actualDest); destBlock.CopyTo(actualDest);
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
@ -140,12 +140,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var destBlock = new Block8x8F(); 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)); ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D8x4_32f(src.Slice(4), expectedDest.AsSpan(4));
FastFloatingPointDCT.FDCT8x4_RightPart(ref srcBlock, ref destBlock); FastFloatingPointDCT.FDCT8x4_RightPart(ref srcBlock, ref destBlock);
float[] actualDest = new float[64]; var actualDest = new float[64];
destBlock.CopyTo(actualDest); destBlock.CopyTo(actualDest);
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
@ -162,14 +162,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var destBlock = new Block8x8F(); var destBlock = new Block8x8F();
float[] expectedDest = new float[64]; var expectedDest = new float[64];
float[] temp1 = new float[64]; var temp1 = new float[64];
var temp2 = new Block8x8F(); var temp2 = new Block8x8F();
ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D_llm(src, expectedDest, temp1, downscaleBy8: true); ReferenceImplementations.LLM_FloatingPoint_DCT.fDCT2D_llm(src, expectedDest, temp1, downscaleBy8: true);
FastFloatingPointDCT.TransformFDCT(ref srcBlock, ref destBlock, ref temp2, false); FastFloatingPointDCT.TransformFDCT(ref srcBlock, ref destBlock, ref temp2, false);
float[] actualDest = new float[64]; var actualDest = new float[64];
destBlock.CopyTo(actualDest); destBlock.CopyTo(actualDest);
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));

12
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. // Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public static float[] Create8x8FloatData() public static float[] Create8x8FloatData()
{ {
float[] result = new float[64]; var result = new float[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public static int[] Create8x8IntData() public static int[] Create8x8IntData()
{ {
int[] result = new int[64]; var result = new int[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public static short[] Create8x8ShortData() public static short[] Create8x8ShortData()
{ {
short[] result = new short[64]; var result = new short[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) 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) public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42)
{ {
var rnd = new Random(seed); var rnd = new Random(seed);
int[] result = new int[64]; var result = new int[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) 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) public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42)
{ {
var rnd = new Random(seed); var rnd = new Random(seed);
float[] result = new float[64]; var result = new float[64];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)

2
tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
result[i] = resultComponent; 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++) for (int i = 0; i < result.Length; i++)
{ {

2
tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
private static double[,] InitCosLut() private static double[,] InitCosLut()
{ {
double[,] coslu = new double[8, 8]; var coslu = new double[8, 8];
int a, b; int a, b;
double tmp; double tmp;

16
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) public static Block8x8F TransformIDCT(ref Block8x8F source)
{ {
float[] s = new float[64]; var s = new float[64];
source.CopyTo(s); source.CopyTo(s);
float[] d = new float[64]; var d = new float[64];
float[] temp = new float[64]; var temp = new float[64];
iDCT2D_llm(s, d, temp); iDCT2D_llm(s, d, temp);
Block8x8F result = default; Block8x8F result = default;
@ -42,10 +42,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public static Block8x8F TransformFDCT_UpscaleBy8(ref Block8x8F source) public static Block8x8F TransformFDCT_UpscaleBy8(ref Block8x8F source)
{ {
float[] s = new float[64]; var s = new float[64];
source.CopyTo(s); source.CopyTo(s);
float[] d = new float[64]; var d = new float[64];
float[] temp = new float[64]; var temp = new float[64];
fDCT2D_llm(s, d, temp); fDCT2D_llm(s, d, temp);
Block8x8F result = default; Block8x8F result = default;
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public static float[] PrintConstants(ITestOutputHelper output) public static float[] PrintConstants(ITestOutputHelper output)
{ {
float[] r = new float[8]; var r = new float[8];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
r[i] = (float)(Cos(i / 16.0 * M_PI) * M_SQRT2); 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 t0, t1, t2, t3, t4, t5, t6, t7;
float c0, c1, c2, c3; 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); } //for(i = 0;i < 8;i++){ r[i] = (float)(cos((double)i / 16.0 * M_PI) * M_SQRT2); }
r[0] = 1.414214f; r[0] = 1.414214f;

4
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) public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block)
{ {
int[] temp = new int[Block8x8.Size]; var temp = new int[Block8x8.Size];
block.CopyTo(temp); block.CopyTo(temp);
Subtract128_TransformFDCT_Upscale8_Inplace(temp); Subtract128_TransformFDCT_Upscale8_Inplace(temp);
var result = default(Block8x8); 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!")] // [Obsolete("Looks like this method produces really bad results for bigger values!")]
public static Block8x8 TransformIDCT(ref Block8x8 block) public static Block8x8 TransformIDCT(ref Block8x8 block)
{ {
int[] temp = new int[Block8x8.Size]; var temp = new int[Block8x8.Size];
block.CopyTo(temp); block.CopyTo(temp);
TransformIDCTInplace(temp); TransformIDCTInplace(temp);
var result = default(Block8x8); var result = default(Block8x8);

6
tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs

@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
/// <returns>A new <see cref="Span{T}"/> with float values</returns> /// <returns>A new <see cref="Span{T}"/> with float values</returns>
public static float[] ConvertAllToFloat(this int[] src) 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++) for (int i = 0; i < src.Length; i++)
{ {
result[i] = src[i]; result[i] = src[i];
@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
/// <returns>A new instance of <see cref="Span{T}"/></returns> /// <returns>A new instance of <see cref="Span{T}"/></returns>
public static Span<float> AddScalarToAllValues(this Span<float> src, float scalar) public static Span<float> AddScalarToAllValues(this Span<float> src, float scalar)
{ {
float[] result = new float[src.Length]; var result = new float[src.Length];
for (int i = 0; i < src.Length; i++) for (int i = 0; i < src.Length; i++)
{ {
result[i] = src[i] + scalar; result[i] = src[i] + scalar;
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
/// <returns>A new instance of <see cref="Span{T}"/></returns> /// <returns>A new instance of <see cref="Span{T}"/></returns>
public static Span<int> AddScalarToAllValues(this Span<int> src, int scalar) public static Span<int> AddScalarToAllValues(this Span<int> src, int scalar)
{ {
int[] result = new int[src.Length]; var result = new int[src.Length];
for (int i = 0; i < src.Length; i++) for (int i = 0; i < src.Length; i++)
{ {
result[i] = src[i] + scalar; result[i] = src[i] + scalar;

2
tests/ImageSharp.Tests/Formats/Jpg/ZigZagTests.cs

@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void ZigZagCanHandleAllPossibleCoefficients() public void ZigZagCanHandleAllPossibleCoefficients()
{ {
// Mimic the behaviour of the huffman scan decoder using all possible byte values // 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(); var zigzag = ZigZag.CreateUnzigTable();
for (int h = 0; h < 255; h++) for (int h = 0; h < 255; h++)

4
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.IO;
using System.Text; using System.Text;
@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
private static string GetChunkTypeName(uint value) private static string GetChunkTypeName(uint value)
{ {
byte[] data = new byte[4]; var data = new byte[4];
BinaryPrimitives.WriteUInt32BigEndian(data, value); BinaryPrimitives.WriteUInt32BigEndian(data, value);

4
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[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray();
int[] actualData = new int[maxY]; var actualData = new int[maxY];
ParallelHelper.IterateRows( ParallelHelper.IterateRows(
rectangle, rectangle,
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rectangle = new Rectangle(0, minY, 10, maxY - minY); var rectangle = new Rectangle(0, minY, 10, maxY - minY);
int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); 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( ParallelHelper.IterateRowsWithTempBuffer(
rectangle, rectangle,

16
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
[Fact] [Fact]
public void Slice1() public void Slice1()
{ {
RowInterval rowInterval = new RowInterval(10, 20); var rowInterval = new RowInterval(10, 20);
RowInterval sliced = rowInterval.Slice(5); RowInterval sliced = rowInterval.Slice(5);
Assert.Equal(15, sliced.Min); Assert.Equal(15, sliced.Min);
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
[Fact] [Fact]
public void Slice2() public void Slice2()
{ {
RowInterval rowInterval = new RowInterval(10, 20); var rowInterval = new RowInterval(10, 20);
RowInterval sliced = rowInterval.Slice(3, 5); RowInterval sliced = rowInterval.Slice(3, 5);
Assert.Equal(13, sliced.Min); Assert.Equal(13, sliced.Min);
@ -58,8 +58,8 @@ namespace SixLabors.ImageSharp.Tests.Helpers
[Fact] [Fact]
public void Equality_WhenTrue() public void Equality_WhenTrue()
{ {
RowInterval a = new RowInterval(42, 123); var a = new RowInterval(42, 123);
RowInterval b = new RowInterval(42, 123); var b = new RowInterval(42, 123);
Assert.True(a.Equals(b)); Assert.True(a.Equals(b));
Assert.True(a.Equals((object)b)); Assert.True(a.Equals((object)b));
@ -70,9 +70,9 @@ namespace SixLabors.ImageSharp.Tests.Helpers
[Fact] [Fact]
public void Equality_WhenFalse() public void Equality_WhenFalse()
{ {
RowInterval a = new RowInterval(42, 123); var a = new RowInterval(42, 123);
RowInterval b = new RowInterval(42, 125); var b = new RowInterval(42, 125);
RowInterval c = new RowInterval(40, 123); var c = new RowInterval(40, 123);
Assert.False(a.Equals(b)); Assert.False(a.Equals(b));
Assert.False(c.Equals(a)); Assert.False(c.Equals(a));

8
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.IO
{ {
using (MemoryStream stream = this.CreateTestStream()) using (MemoryStream stream = this.CreateTestStream())
{ {
byte[] buffer = new byte[2]; var buffer = new byte[2];
byte[] expected = stream.ToArray(); byte[] expected = stream.ToArray();
var reader = new DoubleBufferedStreamReader(this.allocator, stream); var reader = new DoubleBufferedStreamReader(this.allocator, stream);
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.IO
{ {
using (MemoryStream stream = this.CreateTestStream()) using (MemoryStream stream = this.CreateTestStream())
{ {
byte[] buffer = new byte[2]; var buffer = new byte[2];
byte[] expected = stream.ToArray(); byte[] expected = stream.ToArray();
var reader = new DoubleBufferedStreamReader(this.allocator, stream); var reader = new DoubleBufferedStreamReader(this.allocator, stream);
@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests.IO
private MemoryStream CreateTestStream() private MemoryStream CreateTestStream()
{ {
byte[] buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; var buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3];
var random = new Random(); var random = new Random();
random.NextBytes(buffer); random.NextBytes(buffer);

6
tests/ImageSharp.Tests/Image/ImageCloneTests.cs

@ -1,4 +1,4 @@
using System; using System;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void CloneAs_WhenDisposed_Throws() public void CloneAs_WhenDisposed_Throws()
{ {
Image<Rgba32> image = new Image<Rgba32>(5, 5); var image = new Image<Rgba32>(5, 5);
image.Dispose(); image.Dispose();
Assert.Throws<ObjectDisposedException>(() => image.CloneAs<Bgra32>()); Assert.Throws<ObjectDisposedException>(() => image.CloneAs<Bgra32>());
@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Clone_WhenDisposed_Throws() public void Clone_WhenDisposed_Throws()
{ {
Image<Rgba32> image = new Image<Rgba32>(5, 5); var image = new Image<Rgba32>(5, 5);
image.Dispose(); image.Dispose();
Assert.Throws<ObjectDisposedException>(() => image.Clone()); Assert.Throws<ObjectDisposedException>(() => image.Clone());

18
tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void AddFrame_OfDifferentPixelType() public void AddFrame_OfDifferentPixelType()
{ {
using (Image<Bgra32> sourceImage = new Image<Bgra32>( using (var sourceImage = new Image<Bgra32>(
this.Image.GetConfiguration(), this.Image.GetConfiguration(),
this.Image.Width, this.Image.Width,
this.Image.Height, this.Image.Height,
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests
Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray(); Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray();
Assert.Equal(2, this.Collection.Count); Assert.Equal(2, this.Collection.Count);
ImageFrame<Rgba32> actualFrame = (ImageFrame<Rgba32>)this.Collection[1]; var actualFrame = (ImageFrame<Rgba32>)this.Collection[1];
actualFrame.ComparePixelBufferTo(expectedAllBlue); actualFrame.ComparePixelBufferTo(expectedAllBlue);
} }
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void InsertFrame_OfDifferentPixelType() public void InsertFrame_OfDifferentPixelType()
{ {
using (Image<Bgra32> sourceImage = new Image<Bgra32>( using (var sourceImage = new Image<Bgra32>(
this.Image.GetConfiguration(), this.Image.GetConfiguration(),
this.Image.Width, this.Image.Width,
this.Image.Height, this.Image.Height,
@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests
Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray(); Enumerable.Repeat(Rgba32.Blue, this.Image.Width * this.Image.Height).ToArray();
Assert.Equal(2, this.Collection.Count); Assert.Equal(2, this.Collection.Count);
ImageFrame<Rgba32> actualFrame = (ImageFrame<Rgba32>)this.Collection[0]; var actualFrame = (ImageFrame<Rgba32>)this.Collection[0];
actualFrame.ComparePixelBufferTo(expectedAllBlue); actualFrame.ComparePixelBufferTo(expectedAllBlue);
@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
Assert.Equal(2, img.Frames.Count); Assert.Equal(2, img.Frames.Count);
Image<TPixel> expectedClone = (Image<TPixel>)cloned; var expectedClone = (Image<TPixel>)cloned;
expectedClone.ComparePixelBufferTo(img.GetPixelSpan()); expectedClone.ComparePixelBufferTo(img.GetPixelSpan());
} }
@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
Assert.Equal(1, img.Frames.Count); Assert.Equal(1, img.Frames.Count);
Image<TPixel> expectedClone = (Image<TPixel>)cloned; var expectedClone = (Image<TPixel>)cloned;
expectedClone.ComparePixelBufferTo(sourcePixelData); expectedClone.ComparePixelBufferTo(sourcePixelData);
} }
} }
@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.Equal(2, this.Image.Frames.Count); Assert.Equal(2, this.Image.Frames.Count);
ImageFrame<Rgba32> frame = (ImageFrame<Rgba32>)this.Image.Frames[1]; var frame = (ImageFrame<Rgba32>)this.Image.Frames[1];
frame.ComparePixelBufferTo(default(Rgba32)); frame.ComparePixelBufferTo(default(Rgba32));
} }
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.Equal(2, this.Image.Frames.Count); Assert.Equal(2, this.Image.Frames.Count);
ImageFrame<Rgba32> frame = (ImageFrame<Rgba32>)this.Image.Frames[1]; var frame = (ImageFrame<Rgba32>)this.Image.Frames[1];
frame.ComparePixelBufferTo(Rgba32.HotPink); frame.ComparePixelBufferTo(Rgba32.HotPink);
} }
@ -273,7 +273,7 @@ namespace SixLabors.ImageSharp.Tests
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image source = provider.GetImage()) using (Image source = provider.GetImage())
using (Image<TPixel> dest = new Image<TPixel>(source.GetConfiguration(), source.Width, source.Height)) using (var dest = new Image<TPixel>(source.GetConfiguration(), source.Width, source.Height))
{ {
// Giphy.gif has 5 frames // Giphy.gif has 5 frames

8
tests/ImageSharp.Tests/Image/ImageSaveTests.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void SavePath() public void SavePath()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream); this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream);
this.Image.Save("path.png"); this.Image.Save("path.png");
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void SavePathWithEncoder() public void SavePathWithEncoder()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
this.fileSystem.Setup(x => x.Create("path.jpg")).Returns(stream); this.fileSystem.Setup(x => x.Create("path.jpg")).Returns(stream);
this.Image.Save("path.jpg", this.encoderNotInFormat.Object); this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void SaveStreamWithMime() public void SaveStreamWithMime()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
this.Image.Save(stream, this.localImageFormat.Object); 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));
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void SaveStreamWithEncoder() public void SaveStreamWithEncoder()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
this.Image.Save(stream, this.encoderNotInFormat.Object); this.Image.Save(stream, this.encoderNotInFormat.Object);

4
tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs

@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests
[InlineData(true)] [InlineData(true)]
public void Configuration_Bytes_Decoder_Specific(bool useSpan) public void Configuration_Bytes_Decoder_Specific(bool useSpan)
{ {
TestFormat localFormat = new TestFormat(); var localFormat = new TestFormat();
var img = useSpan ? var img = useSpan ?
Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) : Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) :
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests
[InlineData(true)] [InlineData(true)]
public void Configuration_Bytes_Decoder_Agnostic(bool useSpan) public void Configuration_Bytes_Decoder_Agnostic(bool useSpan)
{ {
TestFormat localFormat = new TestFormat(); var localFormat = new TestFormat();
var img = useSpan ? var img = useSpan ?
Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) : Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) :

4
tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Configuration_Stream_Decoder_Specific() public void Configuration_Stream_Decoder_Specific()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream, this.localDecoder.Object); var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact] [Fact]
public void Configuration_Stream_Decoder_Agnostic() public void Configuration_Stream_Decoder_Agnostic()
{ {
Stream stream = new MemoryStream(); var stream = new MemoryStream();
var img = Image.Load(this.TopLevelConfiguration, stream, this.localDecoder.Object); var img = Image.Load(this.TopLevelConfiguration, stream, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);

2
tests/ImageSharp.Tests/Image/ImageTests.Save.cs

@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests
var image = new Image<Rgba32>(5, 5); var image = new Image<Rgba32>(5, 5);
image.Dispose(); image.Dispose();
IImageEncoder encoder = Mock.Of<IImageEncoder>(); IImageEncoder encoder = Mock.Of<IImageEncoder>();
using (MemoryStream stream = new MemoryStream()) using (var stream = new MemoryStream())
{ {
Assert.Throws<ObjectDisposedException>(() => image.Save(stream, encoder)); Assert.Throws<ObjectDisposedException>(() => image.Save(stream, encoder));
} }

4
tests/ImageSharp.Tests/ImageOperationTests.cs

@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
this.provider = new FakeImageOperationsProvider(); this.provider = new FakeImageOperationsProvider();
Mock<IImageProcessor> processorMock = new Mock<IImageProcessor>(); var processorMock = new Mock<IImageProcessor>();
this.processorDefinition = processorMock.Object; this.processorDefinition = processorMock.Object;
this.image = new Image<Rgba32>(new Configuration this.image = new Image<Rgba32>(new Configuration
@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
try try
{ {
Image<Rgba32> img = new Image<Rgba32>(1, 1); var img = new Image<Rgba32>(1, 1);
img.Dispose(); img.Dispose();
img.EnsureNotDisposed(); img.EnsureNotDisposed();
} }

4
tests/ImageSharp.Tests/Memory/Buffer2DTests.cs

@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
[InlineData(5, 1, 1, 3, 2)] [InlineData(5, 1, 1, 3, 2)]
public void CopyColumns(int width, int height, int startIndex, int destIndex, int columnCount) 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<float> b = this.MemoryAllocator.Allocate2D<float>(width, height)) using (Buffer2D<float> b = this.MemoryAllocator.Allocate2D<float>(width, height))
{ {
rnd.RandomFill(b.Span, 0, 1); rnd.RandomFill(b.Span, 0, 1);
@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
[Fact] [Fact]
public void CopyColumns_InvokeMultipleTimes() public void CopyColumns_InvokeMultipleTimes()
{ {
Random rnd = new Random(123); var rnd = new Random(123);
using (Buffer2D<float> b = this.MemoryAllocator.Allocate2D<float>(100, 100)) using (Buffer2D<float> b = this.MemoryAllocator.Allocate2D<float>(100, 100))
{ {
rnd.RandomFill(b.Span, 0, 1); rnd.RandomFill(b.Span, 0, 1);

4
tests/ImageSharp.Tests/Memory/BufferAreaTests.cs

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
{ {
using (Buffer2D<int> buffer = CreateTestBuffer(20, 30)) using (Buffer2D<int> buffer = CreateTestBuffer(20, 30))
{ {
Rectangle r = new Rectangle(rx, ry, 5, 6); var r = new Rectangle(rx, ry, 5, 6);
BufferArea<int> area = buffer.GetArea(r); BufferArea<int> area = buffer.GetArea(r);
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
{ {
using (Buffer2D<int> buffer = CreateTestBuffer(20, 30)) using (Buffer2D<int> buffer = CreateTestBuffer(20, 30))
{ {
Rectangle r = new Rectangle(rx, ry, w, h); var r = new Rectangle(rx, ry, w, h);
BufferArea<int> area = buffer.GetArea(r); BufferArea<int> area = buffer.GetArea(r);

2
tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
public void CalculateHash_WithByteArray_DoesNotModifyData() public void CalculateHash_WithByteArray_DoesNotModifyData()
{ {
byte[] data = IccTestDataProfiles.Profile_Random_Array; 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); Buffer.BlockCopy(data, 0, copy, 0, data.Length);
IccProfile.CalculateHash(data); IccProfile.CalculateHash(data);

2
tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
{ {
IccWriter writer = CreateWriter(); IccWriter writer = CreateWriter();
IccProfile profile = new IccProfile var profile = new IccProfile
{ {
Header = IccTestDataProfiles.Header_Random_Write Header = IccTestDataProfiles.Header_Random_Write
}; };

22
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs

@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{ {
const int Count = 2134; const int Count = 2134;
TPixel[] source = CreatePixelTestData(Count); TPixel[] source = CreatePixelTestData(Count);
TDestPixel[] expected = new TDestPixel[Count]; var expected = new TDestPixel[Count];
PixelConverterTests.ReferenceImplementations.To<TPixel, TDestPixel>(this.Configuration, source, expected); PixelConverterTests.ReferenceImplementations.To<TPixel, TDestPixel>(this.Configuration, source, expected);
@ -457,7 +457,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToArgb32Bytes(int count) public void ToArgb32Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 4]; var expected = new byte[count * 4];
var argb = default(Argb32); var argb = default(Argb32);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -504,7 +504,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToBgr24Bytes(int count) public void ToBgr24Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 3]; var expected = new byte[count * 3];
var bgr = default(Bgr24); var bgr = default(Bgr24);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -549,7 +549,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToBgra32Bytes(int count) public void ToBgra32Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 4]; var expected = new byte[count * 4];
var bgra = default(Bgra32); var bgra = default(Bgra32);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -595,7 +595,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToRgb24Bytes(int count) public void ToRgb24Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 3]; var expected = new byte[count * 3];
var rgb = default(Rgb24); var rgb = default(Rgb24);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToRgba32Bytes(int count) public void ToRgba32Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 4]; var expected = new byte[count * 4];
var rgba = default(Rgba32); var rgba = default(Rgba32);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -686,7 +686,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToRgb48Bytes(int count) public void ToRgb48Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 6]; var expected = new byte[count * 6];
Rgb48 rgb = default; Rgb48 rgb = default;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -735,7 +735,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToRgba64Bytes(int count) public void ToRgba64Bytes(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
byte[] expected = new byte[count * 8]; var expected = new byte[count * 8];
Rgba64 rgba = default; Rgba64 rgba = default;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -787,7 +787,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToGray8(int count) public void ToGray8(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
Gray8[] expected = new Gray8[count]; var expected = new Gray8[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
@ -831,7 +831,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
public void ToGray16(int count) public void ToGray16(int count)
{ {
TPixel[] source = CreatePixelTestData(count); TPixel[] source = CreatePixelTestData(count);
Gray16[] expected = new Gray16[count]; var expected = new Gray16[count];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
@ -946,7 +946,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
internal static byte[] CreateByteTestData(int length) internal static byte[] CreateByteTestData(int length)
{ {
byte[] result = new byte[length]; var result = new byte[length];
var rnd = new Random(42); // Deterministic random values var rnd = new Random(42); // Deterministic random values
for (int i = 0; i < result.Length; i++) for (int i = 0; i < result.Length; i++)

26
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. // Licensed under the Apache License, Version 2.0.
using System.Numerics; using System.Numerics;
@ -126,8 +126,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Fact] [Fact]
public void Equality_WhenTrue() public void Equality_WhenTrue()
{ {
Rgba64 c1 = new Rgba64(100, 2000, 3000, 40000); var c1 = new Rgba64(100, 2000, 3000, 40000);
Rgba64 c2 = new Rgba64(100, 2000, 3000, 40000); var c2 = new Rgba64(100, 2000, 3000, 40000);
Assert.True(c1.Equals(c2)); Assert.True(c1.Equals(c2));
Assert.True(c1.GetHashCode() == c2.GetHashCode()); Assert.True(c1.GetHashCode() == c2.GetHashCode());
@ -136,9 +136,9 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Fact] [Fact]
public void Equality_WhenFalse() public void Equality_WhenFalse()
{ {
Rgba64 c1 = new Rgba64(100, 2000, 3000, 40000); var c1 = new Rgba64(100, 2000, 3000, 40000);
Rgba64 c2 = new Rgba64(101, 2000, 3000, 40000); var c2 = new Rgba64(101, 2000, 3000, 40000);
Rgba64 c3 = new Rgba64(100, 2000, 3000, 40001); var c3 = new Rgba64(100, 2000, 3000, 40001);
Assert.False(c1.Equals(c2)); Assert.False(c1.Equals(c2));
Assert.False(c2.Equals(c3)); Assert.False(c2.Equals(c3));
@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
var expected = new Rgba64(5140, 9766, 19532, 29555); var expected = new Rgba64(5140, 9766, 19532, 29555);
var source = new Rgba32(20, 38, 76, 115); var source = new Rgba32(20, 38, 76, 115);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
var expected = new Rgba64(5140, 9766, 19532, 29555); var expected = new Rgba64(5140, 9766, 19532, 29555);
var source = new Bgra32(20, 38, 76, 115); var source = new Bgra32(20, 38, 76, 115);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
var expected = new Rgba64(5140, 9766, 19532, 29555); var expected = new Rgba64(5140, 9766, 19532, 29555);
var source = new Argb32(20, 38, 76, 115); var source = new Argb32(20, 38, 76, 115);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue); var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue);
var source = new Rgb24(20, 38, 76); var source = new Rgb24(20, 38, 76);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{ {
var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue); var expected = new Rgba64(5140, 9766, 19532, ushort.MaxValue);
var source = new Bgr24(20, 38, 76); var source = new Bgr24(20, 38, 76);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -210,11 +210,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Fact] [Fact]
public void ConstructFrom_Vector4() 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; Rgba64 expected = default;
expected.FromScaledVector4(source); expected.FromScaledVector4(source);
Rgba64 actual = new Rgba64(source); var actual = new Rgba64(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }

4
tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
public void HistogramEqualizationTest(int luminanceLevels) public void HistogramEqualizationTest(int luminanceLevels)
{ {
// Arrange // Arrange
byte[] pixels = new byte[] var pixels = new byte[]
{ {
52, 55, 61, 59, 70, 61, 76, 61, 52, 55, 61, 59, 70, 61, 76, 61,
62, 59, 55, 104, 94, 85, 59, 71, 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, 0, 12, 53, 32, 146, 53, 174, 53,
57, 32, 12, 227, 219, 202, 32, 154, 57, 32, 12, 227, 219, 202, 32, 154,

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs

@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
// Change the number of components // Change the number of components
bytes[20] = 1; bytes[20] = 1;
byte[] orientationCodeData = new byte[8]; var orientationCodeData = new byte[8];
Array.Copy(orientation, orientationCodeData, orientation.Length); Array.Copy(orientation, orientationCodeData, orientation.Length);
ulong orientationCode = BitConverter.ToUInt64(orientationCodeData, 0); ulong orientationCode = BitConverter.ToUInt64(orientationCodeData, 0);

4
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. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
public void ImageShouldPadWithBackgroundColor<TPixel>(TestImageProvider<TPixel> provider) public void ImageShouldPadWithBackgroundColor<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = Color.Red; var color = Color.Red;
TPixel expected = color.ToPixel<TPixel>(); TPixel expected = color.ToPixel<TPixel>();
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {

4
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. // Licensed under the Apache License, Version 2.0.
using System.Collections.Generic; using System.Collections.Generic;
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
double sum = 0; double sum = 0;
double[] values = new double[right - left + 1]; var values = new double[right - left + 1];
for (int j = left; j <= right; j++) for (int j = left; j <= right; j++)
{ {

4
tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs

@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
foreach (object[] row in memberData) 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); Array.Copy(originalFactoryMethodArgs, actualFactoryMethodArgs, originalFactoryMethodArgs.Length);
actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 2] = testMethod; actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 2] = testMethod;
actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 1] = kv.Key; actualFactoryMethodArgs[actualFactoryMethodArgs.Length - 1] = kv.Key;
@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests
object factory = factoryType.GetMethod(this.GetFactoryMethodName(testMethod)) object factory = factoryType.GetMethod(this.GetFactoryMethodName(testMethod))
.Invoke(null, actualFactoryMethodArgs); .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; result[0] = factory;
Array.Copy(row, 0, result, 1, row.Length); Array.Copy(row, 0, result, 1, row.Length);
Array.Copy(this.AdditionalParameters, 0, result, 1 + row.Length, this.AdditionalParameters.Length); Array.Copy(this.AdditionalParameters, 0, result, 1 + row.Length, this.AdditionalParameters.Length);

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs

@ -198,7 +198,7 @@ namespace SixLabors.ImageSharp.Tests
int pixelCount = left * top; int pixelCount = left * top;
uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount); uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount);
TPixel c = default; TPixel c = default;
Rgba32 t = new Rgba32(0); var t = new Rgba32(0);
for (int x = left; x < right; x++) for (int x = left; x < right; x++)
{ {

10
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. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>The <see cref="float[]"/>.</returns> /// <returns>The <see cref="float[]"/>.</returns>
public static float[] GenerateRandomFloatArray(this Random rnd, int length, float minVal, float maxVal) 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); RandomFill(rnd, values, minVal, maxVal);
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>The <see cref="float[]"/>.</returns> /// <returns>The <see cref="float[]"/>.</returns>
public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int length, float minVal, float maxVal) 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++) for (int i = 0; i < length; i++)
{ {
@ -88,14 +88,14 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>The <see cref="byte[]"/>.</returns> /// <returns>The <see cref="byte[]"/>.</returns>
public static byte[] GenerateRandomByteArray(this Random rnd, int length) public static byte[] GenerateRandomByteArray(this Random rnd, int length)
{ {
byte[] values = new byte[length]; var values = new byte[length];
rnd.NextBytes(values); rnd.NextBytes(values);
return values; return values;
} }
public static short[] GenerateRandomInt16Array(this Random rnd, int length, short minVal, short maxVal) 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++) for (int i = 0; i < values.Length; i++)
{ {
values[i] = (short)rnd.Next(minVal, maxVal); values[i] = (short)rnd.Next(minVal, maxVal);

Loading…
Cancel
Save