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. 4
      src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
  3. 4
      src/ImageSharp/Common/Extensions/StreamExtensions.cs
  4. 12
      src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs
  5. 6
      src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs
  6. 6
      src/ImageSharp/Common/Helpers/SimdUtils.cs
  7. 20
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  8. 4
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  9. 6
      src/ImageSharp/Formats/Gif/LzwDecoder.cs
  10. 4
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  11. 12
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
  12. 20
      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. 14
      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. 8
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  27. 6
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  28. 1084
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  29. 20
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  30. 130
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  31. 20
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  32. 6
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  33. 6
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  34. 6
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  35. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  36. 6
      src/ImageSharp/Primitives/Rational.cs
  37. 6
      src/ImageSharp/Primitives/SignedRational.cs
  38. 6
      src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
  39. 10
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  40. 8
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs
  41. 6
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  42. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs
  43. 8
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs
  44. 32
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs
  45. 8
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs
  46. 6
      tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs
  47. 8
      tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs
  48. 4
      tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs
  49. 4
      tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs
  50. 10
      tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs
  51. 36
      tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs
  52. 48
      tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs
  53. 48
      tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs
  54. 24
      tests/ImageSharp.Tests/Color/ColorTests.cs
  55. 2
      tests/ImageSharp.Tests/Colorspaces/RgbTests.cs
  56. 22
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
  57. 10
      tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
  58. 8
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  59. 40
      tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs
  60. 4
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  61. 12
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  62. 6
      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. 14
      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. 6
      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. 6
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs
  73. 4
      tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs
  74. 28
      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. 20
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs
  80. 22
      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. 12
      tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
  84. 6
      tests/ImageSharp.Tests/Memory/BufferAreaTests.cs
  85. 2
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs
  86. 6
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs
  87. 22
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  88. 88
      tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs
  89. 4
      tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs
  90. 6
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs
  91. 6
      tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs
  92. 6
      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. 12
      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;
} }

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

@ -14,9 +14,9 @@ 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);

12
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)
@ -211,4 +211,4 @@ namespace SixLabors.ImageSharp
} }
} }
} }
} }

6
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);
@ -190,4 +190,4 @@ namespace SixLabors.ImageSharp
} }
} }
} }
} }

6
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));
@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp
$"length should be divisible by {shouldBeDivisibleBy}!"); $"length should be divisible by {shouldBeDivisibleBy}!");
} }
} }
} }

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);

6
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)
@ -253,4 +253,4 @@ namespace SixLabors.ImageSharp.Formats.Gif
this.pixelStack.Dispose(); this.pixelStack.Dispose();
} }
} }
} }

4
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;
} }
@ -297,4 +297,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
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);

20
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++)
@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{ {
char destCoord = coordz[i % 4]; char destCoord = coordz[i % 4];
char destSide = (i / 4) % 2 == 0 ? 'L' : 'R'; char destSide = (i / 4) % 2 == 0 ? 'L' : 'R';
if(j > 0 && i == 0){ if(j > 0 && i == 0){
WriteLine(""); WriteLine("");
} }
@ -125,9 +125,9 @@ 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);
} }
} }
PopIndent(); PopIndent();

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();

14
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];
@ -168,4 +168,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
return new IccClut(values, gridPointCount, IccClutDataType.Float); return new IccClut(values, gridPointCount, IccClutDataType.Float);
} }
} }
} }

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++)
{ {

8
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;
} }
@ -216,4 +216,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
this.entries = reader.ReadTagData(this.data); this.entries = reader.ReadTagData(this.data);
} }
} }
} }

6
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);
} }
@ -175,4 +175,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
this.ScriptCodeCode); this.ScriptCodeCode);
} }
} }
} }

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

File diff suppressed because it is too large

20
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>
@ -82,26 +82,26 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
{ {
TPixel dest = default; TPixel dest = default;
dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1)));
return dest; return dest;
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, float amount) protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, float amount)
{ {
amount = amount.Clamp(0, 1); amount = amount.Clamp(0, 1);
for (int i = 0; i < destination.Length; i++) for (int i = 0; i < destination.Length; i++)
{ {
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount); destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount);
} }
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, ReadOnlySpan<float> amount) protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, ReadOnlySpan<float> amount)
{ {
for (int i = 0; i < destination.Length; i++) for (int i = 0; i < destination.Length; i++)
{ {
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1)); destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1));
} }
} }
} }
@ -111,4 +111,4 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
#> #>
} }
} }

130
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 />
@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity)
@ -110,7 +110,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)
@ -122,7 +121,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -134,7 +132,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -146,7 +143,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -158,7 +154,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -170,7 +165,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -182,7 +176,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -194,7 +187,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -206,7 +198,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -218,7 +209,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -230,7 +220,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -242,7 +231,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -339,7 +327,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity)
@ -348,7 +336,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)
@ -360,7 +347,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -372,7 +358,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -384,7 +369,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -396,7 +380,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -408,7 +391,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -420,7 +402,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -432,7 +413,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -444,7 +424,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -456,7 +435,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -468,7 +446,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -480,7 +457,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -577,7 +553,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity)
@ -586,7 +562,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)
@ -598,7 +573,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -610,7 +584,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -622,7 +595,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -634,7 +606,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -646,7 +617,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -658,7 +628,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -670,7 +639,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -682,7 +650,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -694,7 +661,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -706,7 +672,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -718,7 +683,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -815,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity)
@ -824,7 +788,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)
@ -836,7 +799,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -848,7 +810,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -860,7 +821,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -872,7 +832,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -884,7 +843,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -896,7 +854,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -908,7 +865,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -920,7 +876,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -932,7 +887,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -944,7 +898,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -956,7 +909,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1053,7 +1005,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity)
@ -1062,7 +1014,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)
@ -1074,7 +1025,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1086,7 +1036,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1098,7 +1047,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1110,7 +1058,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1122,7 +1069,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1134,7 +1080,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1146,7 +1091,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1158,7 +1102,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1170,7 +1113,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1182,7 +1124,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1194,7 +1135,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1291,7 +1231,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity)
@ -1300,7 +1240,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)
@ -1312,7 +1251,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1324,7 +1262,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1336,7 +1273,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1348,7 +1284,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1360,7 +1295,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1372,7 +1306,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1384,7 +1317,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1396,7 +1328,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1408,7 +1339,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1420,7 +1350,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1432,7 +1361,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1529,7 +1457,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity)
@ -1538,7 +1466,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)
@ -1550,7 +1477,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1562,7 +1488,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1574,7 +1499,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1586,7 +1510,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1598,7 +1521,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1610,7 +1532,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1622,7 +1543,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1634,7 +1554,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1646,7 +1565,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1658,7 +1576,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1670,7 +1587,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1767,7 +1683,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity)
@ -1776,7 +1692,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)
@ -1788,7 +1703,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1800,7 +1714,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1812,7 +1725,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1824,7 +1736,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1836,7 +1747,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1848,7 +1758,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1860,7 +1769,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1872,7 +1780,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1884,7 +1791,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1896,7 +1802,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -1908,7 +1813,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2005,7 +1909,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity)
@ -2014,7 +1918,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)
@ -2026,7 +1929,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2038,7 +1940,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2050,7 +1951,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2062,7 +1962,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2074,7 +1973,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2086,7 +1984,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2098,7 +1995,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2110,7 +2006,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2122,7 +2017,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2134,7 +2028,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2146,7 +2039,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return dest; return dest;
} }
[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)
@ -2159,4 +2051,4 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
} }
} }
} }

20
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.
#> #>
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
source.W *= opacity; source.W *= opacity;
return Xor(backdrop, source); return Xor(backdrop, source);
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity) public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity)
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
<# } #> <# } #>
<# void GenerateGenericPixelBlender(string blender, string composer) { #> <# void GenerateGenericPixelBlender(string blender, string composer) { #>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel <#=blender#><#=composer#><TPixel>(TPixel backdrop, TPixel source, float opacity) public static TPixel <#=blender#><#=composer#><TPixel>(TPixel backdrop, TPixel source, float opacity)
@ -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",
@ -166,12 +166,12 @@ string[] blenders = new []{
"Lighten", "Lighten",
"Overlay", "Overlay",
"HardLight" "HardLight"
}; };
foreach(var blender in blenders) foreach(var blender in blenders)
{ {
GeneratePixelBlenders(blender); GeneratePixelBlenders(blender);
foreach(var composer in composers) foreach(var composer in composers)
{ {
GenerateGenericPixelBlender(blender,composer); GenerateGenericPixelBlender(blender,composer);
@ -180,4 +180,4 @@ string[] blenders = new []{
#> #>
} }
} }

6
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);
} }
@ -173,4 +173,4 @@ namespace SixLabors.ImageSharp.PixelFormats
return num2 | num; return num2 | num;
} }
} }
} }

6
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);
} }
@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.PixelFormats
return (ushort)(byte2 | byte1); return (ushort)(byte2 | byte1);
} }
} }
} }

6
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);
} }
@ -186,4 +186,4 @@ namespace SixLabors.ImageSharp.PixelFormats
return word2 | word1; return word2 | word1;
} }
} }
} }

6
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);
} }
@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.PixelFormats
return word2 | word1; return word2 | word1;
} }
} }
} }

6
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;
@ -187,4 +187,4 @@ namespace SixLabors.ImageSharp.Primitives
return rational.ToString(provider); return rational.ToString(provider);
} }
} }
} }

6
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;
@ -187,4 +187,4 @@ namespace SixLabors.ImageSharp.Primitives
return rational.ToString(provider); return rational.ToString(provider);
} }
} }
} }

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;
} }

10
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++)
{ {
@ -126,4 +126,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
} }
} }
} }
} }

8
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,11 +71,11 @@ 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);
} }
private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null; private static IErrorDiffuser GetDiffuser(bool dither) => dither ? KnownDiffusers.FloydSteinberg : null;
} }
} }

6
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;
@ -985,4 +985,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
} }
} }
} }
} }

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);

8
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++)
{ {
@ -84,4 +84,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
return buffers; return buffers;
} }
} }
} }

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;

8
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;
@ -388,4 +388,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
// Bitops_Tuple | 64 | 75.47 ns | 1.1824 ns | 1.1060 ns | 0.91 | 0.01 | // Bitops_Tuple | 64 | 75.47 ns | 1.1824 ns | 1.1060 ns | 0.91 | 0.01 |
// BitOps_GroupAsULong | 64 | 65.42 ns | 0.7157 ns | 0.6695 ns | 0.79 | 0.01 | // BitOps_GroupAsULong | 64 | 65.42 ns | 0.7157 ns | 0.6695 ns | 0.79 | 0.01 |
} }
} }

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

@ -41,14 +41,14 @@ 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);
} }
} }
} }
} }

8
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,10 +58,10 @@ 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);
} }
} }
} }
} }

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

@ -45,10 +45,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
for (int i = 0; i < this.input.Length; i += Vector<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);
} }
} }
} }
} }

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

@ -53,10 +53,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
{ {
for (int i = 0; i < this.input.Length; i += Vector<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);
} }
} }
} }
} }

10
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;
@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
} }
} }
} }
} }

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

@ -14,8 +14,8 @@ 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;
@ -23,12 +23,12 @@ namespace SixLabors.ImageSharp.Tests
Rgba64 data = color.ToPixel<Rgba64>(); Rgba64 data = color.ToPixel<Rgba64>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -36,12 +36,12 @@ namespace SixLabors.ImageSharp.Tests
Rgba32 data = color.ToPixel<Rgba32>(); Rgba32 data = color.ToPixel<Rgba32>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -49,12 +49,12 @@ namespace SixLabors.ImageSharp.Tests
Argb32 data = color.ToPixel<Argb32>(); Argb32 data = color.ToPixel<Argb32>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -62,12 +62,12 @@ namespace SixLabors.ImageSharp.Tests
Bgra32 data = color.ToPixel<Bgra32>(); Bgra32 data = color.ToPixel<Bgra32>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -75,12 +75,12 @@ namespace SixLabors.ImageSharp.Tests
Rgb24 data = color.ToPixel<Rgb24>(); Rgb24 data = color.ToPixel<Rgb24>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
} }
} }

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

@ -14,75 +14,75 @@ 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;
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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;
@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
} }
} }

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

@ -14,75 +14,75 @@ 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>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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>();
Assert.Equal(source, data); Assert.Equal(source, data);
} }
[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>();
@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
} }
} }

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

@ -18,47 +18,47 @@ 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);
} }
[Fact] [Fact]
public void Equality_WhenTrue() public void Equality_WhenTrue()
{ {
Color c1 = new Rgba64(100, 2000, 3000, 40000); Color c1 = new Rgba64(100, 2000, 3000, 40000);
Color c2 = new Rgba64(100, 2000, 3000, 40000); Color c2 = new Rgba64(100, 2000, 3000, 40000);
Assert.True(c1.Equals(c2)); Assert.True(c1.Equals(c2));
Assert.True(c1 == c2); Assert.True(c1 == c2);
Assert.False(c1 != c2); Assert.False(c1 != c2);
Assert.True(c1.GetHashCode() == c2.GetHashCode()); Assert.True(c1.GetHashCode() == c2.GetHashCode());
} }
[Fact] [Fact]
public void Equality_WhenFalse() public void Equality_WhenFalse()
{ {
Color c1 = new Rgba64(100, 2000, 3000, 40000); Color c1 = new Rgba64(100, 2000, 3000, 40000);
Color c2 = new Rgba64(101, 2000, 3000, 40000); Color c2 = new Rgba64(101, 2000, 3000, 40000);
Color c3 = new Rgba64(100, 2000, 3000, 40001); Color 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));
Assert.False(c3.Equals(c1)); Assert.False(c3.Equals(c1));
Assert.False(c1 == c2); Assert.False(c1 == c2);
Assert.True(c1 != c2); Assert.True(c1 != c2);
Assert.False(c1.Equals(null)); Assert.False(c1.Equals(null));
} }
[Fact] [Fact]
public void ToHex() public void ToHex()
{ {
string expected = "ABCD1234"; string expected = "ABCD1234";
Color color = Color.FromHex(expected); Color color = Color.FromHex(expected);
string actual = color.ToHex(); string actual = color.ToHex();
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests
Rgba32[] actualPalette = Color.WernerPalette.ToArray().Select(c => (Rgba32)c).ToArray(); Rgba32[] actualPalette = Color.WernerPalette.ToArray().Select(c => (Rgba32)c).ToArray();
Assert.Equal(ReferencePalette.WernerColors, actualPalette); Assert.Equal(ReferencePalette.WernerColors, actualPalette);
} }
public class FromHex public class FromHex
{ {
[Fact] [Fact]
@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
} }
} }

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;

22
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);
@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Common
count, count,
(s, d) => SimdUtils.BasicIntrinsics256.BulkConvertByteToNormalizedFloat(s.Span, d.Span)); (s, d) => SimdUtils.BasicIntrinsics256.BulkConvertByteToNormalizedFloat(s.Span, d.Span));
} }
[Theory] [Theory]
[MemberData(nameof(ArraySizesDivisibleBy32))] [MemberData(nameof(ArraySizesDivisibleBy32))]
public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat(int count) public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat(int count)
@ -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];
@ -392,4 +392,4 @@ namespace SixLabors.ImageSharp.Tests.Common
} }
} }
} }
} }

10
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)
{ {
@ -197,4 +197,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing
} }
} }

8
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);
} }
}, },
@ -75,4 +75,4 @@ namespace SixLabors.ImageSharp.Tests.Drawing
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
} }
} }

40
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;
@ -28,18 +28,18 @@ 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 = 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}";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(options, color, simplePath), c => c.FillPolygon(options, color, simplePath),
outputDetails, outputDetails,
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
[Theory] [Theory]
[WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32)] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32)]
public void FillPolygon_Concave<TPixel>(TestImageProvider<TPixel> provider) public void FillPolygon_Concave<TPixel>(TestImageProvider<TPixel> provider)
@ -47,15 +47,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
var points = new SixLabors.Primitives.PointF[] var points = new SixLabors.Primitives.PointF[]
{ {
new Vector2(8, 8), new Vector2(8, 8),
new Vector2(64, 8), new Vector2(64, 8),
new Vector2(64, 64), new Vector2(64, 64),
new Vector2(120, 64), new Vector2(120, 64),
new Vector2(120, 120), new Vector2(120, 120),
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,15 +72,15 @@ 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);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(brush, simplePath), c => c.FillPolygon(brush, simplePath),
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
[Theory] [Theory]
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Png.Ducky)] [WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Png.Ducky)]
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Bmp.Car)] [WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, TestImages.Bmp.Car)]
@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (Image<TPixel> brushImage = Image.Load<TPixel>(TestFile.Create(brushImageName).Bytes)) using (Image<TPixel> brushImage = Image.Load<TPixel>(TestFile.Create(brushImageName).Bytes))
{ {
var brush = new ImageBrush(brushImage); var brush = new ImageBrush(brushImage);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(brush, simplePath), c => c.FillPolygon(brush, simplePath),
System.IO.Path.GetFileNameWithoutExtension(brushImageName), System.IO.Path.GetFileNameWithoutExtension(brushImageName),
@ -109,13 +109,13 @@ 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),
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
[Theory] [Theory]
[WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 50, 0f)] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 50, 0f)]
[WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 60, 20f)] [WithBasicTestPatternImages(200, 200, PixelTypes.Rgba32, 3, 60, 20f)]
@ -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,

6
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,11 +11,11 @@ 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);
Assert.Equal("AQACAAAAAwAAAAQAAAA=", Convert.ToBase64String(buffer)); Assert.Equal("AQACAAAAAwAAAAQAAAA=", Convert.ToBase64String(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));

14
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++)
@ -189,4 +189,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
} }
} }
} }
} }

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;

6
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);
@ -364,4 +364,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
} }
} }
} }
} }

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++)

6
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);
@ -125,4 +125,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
memStream.Position = 0; memStream.Position = 0;
} }
} }
} }

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,

28
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;
@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rows = new RowInterval(min, max); var rows = new RowInterval(min, max);
Span<int> span = buffer.GetMultiRowSpan(rows); Span<int> span = buffer.GetMultiRowSpan(rows);
ref int expected0 = ref buffer.Span[min * width]; ref int expected0 = ref buffer.Span[min * width];
int expectedLength = (max - min) * width; int expectedLength = (max - min) * width;
@ -38,9 +38,9 @@ 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);
Assert.Equal(20, sliced.Max); Assert.Equal(20, sliced.Max);
} }
@ -48,9 +48,9 @@ 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);
Assert.Equal(18, sliced.Max); Assert.Equal(18, sliced.Max);
} }
@ -58,9 +58,9 @@ 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));
Assert.True(a == b); Assert.True(a == b);
@ -70,14 +70,14 @@ 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));
Assert.False(b.Equals(c)); Assert.False(b.Equals(c));
Assert.False(a.Equals((object)b)); Assert.False(a.Equals((object)b));
Assert.False(a.Equals(null)); Assert.False(a.Equals(null));
Assert.False(a == b); Assert.False(a == b);

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);

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

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration);
} }
[Theory] [Theory]
[InlineData(false)] [InlineData(false)]
[InlineData(true)] [InlineData(true)]
@ -47,14 +47,14 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
} }
[Theory] [Theory]
[InlineData(false)] [InlineData(false)]
[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) :
Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder); Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder);
@ -62,14 +62,14 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
localFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration); localFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
} }
[Theory] [Theory]
[InlineData(false)] [InlineData(false)]
[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) :
Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder); Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder);
@ -90,10 +90,10 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.TestFormat, format); Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifySpecificDecodeCall<Bgr24>(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifySpecificDecodeCall<Bgr24>(this.Marker, this.TopLevelConfiguration);
} }
[Theory] [Theory]
[InlineData(false)] [InlineData(false)]
[InlineData(true)] [InlineData(true)]
@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.TestFormat, format); Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
} }
} }

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

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration);
} }
[Fact] [Fact]
public void Configuration_Stream_Agnostic() public void Configuration_Stream_Agnostic()
{ {
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
} }
[Fact] [Fact]
public void NonSeekableStream() public void NonSeekableStream()
{ {
@ -46,21 +46,21 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
} }
[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);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, stream)); this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, stream));
} }
[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);
@ -74,10 +74,10 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.TestFormat, format); Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
} }
[Fact] [Fact]
public void Configuration_Stream_OutFormat_Agnostic() public void Configuration_Stream_OutFormat_Agnostic()
{ {
@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.TestFormat, format); Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
} }
} }
} }
} }

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();
} }

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

@ -137,11 +137,11 @@ 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);
b.CopyColumns(startIndex, destIndex, columnCount); b.CopyColumns(startIndex, destIndex, columnCount);
for (int y = 0; y < b.Height; y++) for (int y = 0; y < b.Height; y++)
@ -150,7 +150,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
Span<float> s = row.Slice(startIndex, columnCount); Span<float> s = row.Slice(startIndex, columnCount);
Span<float> d = row.Slice(destIndex, columnCount); Span<float> d = row.Slice(destIndex, columnCount);
Xunit.Assert.True(s.SequenceEqual(d)); Xunit.Assert.True(s.SequenceEqual(d));
} }
} }
@ -159,11 +159,11 @@ 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);
b.CopyColumns(0, 50, 22); b.CopyColumns(0, 50, 22);
b.CopyColumns(0, 50, 22); b.CopyColumns(0, 50, 22);
@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
Span<float> s = row.Slice(0, 22); Span<float> s = row.Slice(0, 22);
Span<float> d = row.Slice(50, 22); Span<float> d = row.Slice(50, 22);
Xunit.Assert.True(s.SequenceEqual(d)); Xunit.Assert.True(s.SequenceEqual(d));
} }
} }

6
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);
@ -145,4 +145,4 @@ namespace SixLabors.ImageSharp.Tests.Memory
} }
} }
} }
} }

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);

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

@ -13,12 +13,12 @@ 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
}; };
byte[] output = writer.Write(profile); byte[] output = writer.Write(profile);
Assert.Equal(IccTestDataProfiles.Header_Random_Array, output); Assert.Equal(IccTestDataProfiles.Header_Random_Array, output);
} }
@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
IccWriter writer = CreateWriter(); IccWriter writer = CreateWriter();
byte[] output = writer.Write(IccTestDataProfiles.Profile_Random_Val); byte[] output = writer.Write(IccTestDataProfiles.Profile_Random_Val);
Assert.Equal(IccTestDataProfiles.Profile_Random_Array, output); Assert.Equal(IccTestDataProfiles.Profile_Random_Array, output);
} }

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++)

88
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;
@ -65,16 +65,16 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public void Rgba64_FromScaledVector4(ushort r, ushort g, ushort b, ushort a) public void Rgba64_FromScaledVector4(ushort r, ushort g, ushort b, ushort a)
{ {
// arrange // arrange
var source = new Rgba64(r, g, b, a); var source = new Rgba64(r, g, b, a);
// act // act
Vector4 scaled = source.ToScaledVector4(); Vector4 scaled = source.ToScaledVector4();
Rgba64 actual = default; Rgba64 actual = default;
actual.FromScaledVector4(scaled); actual.FromScaledVector4(scaled);
// assert // assert
Assert.Equal(source, actual); Assert.Equal(source, actual);
} }
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
// assert // assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Fact] [Fact]
public void Rgba64_FromBgra5551() public void Rgba64_FromBgra5551()
@ -126,20 +126,20 @@ 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());
} }
[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));
Assert.False(c3.Equals(c1)); Assert.False(c3.Equals(c1));
@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Rgba64 actual = default; Rgba64 actual = default;
actual.FromRgba32(source); actual.FromRgba32(source);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
@ -162,127 +162,127 @@ 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);
} }
[Fact] [Fact]
public void ConstructFrom_Bgra32() public void ConstructFrom_Bgra32()
{ {
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);
} }
[Fact] [Fact]
public void ConstructFrom_Argb32() public void ConstructFrom_Argb32()
{ {
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);
} }
[Fact] [Fact]
public void ConstructFrom_Rgb24() public void ConstructFrom_Rgb24()
{ {
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);
} }
[Fact] [Fact]
public void ConstructFrom_Bgr24() public void ConstructFrom_Bgr24()
{ {
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);
} }
[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);
} }
[Fact] [Fact]
public void ToRgba32_Retval() public void ToRgba32_Retval()
{ {
// arrange // arrange
var source = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba64(5140, 9766, 19532, 29555);
var expected = new Rgba32(20, 38, 76, 115); var expected = new Rgba32(20, 38, 76, 115);
// act // act
var actual = source.ToRgba32(); var actual = source.ToRgba32();
// assert // assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Fact] [Fact]
public void ToBgra32_Retval() public void ToBgra32_Retval()
{ {
// arrange // arrange
var source = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba64(5140, 9766, 19532, 29555);
var expected = new Bgra32(20, 38, 76, 115); var expected = new Bgra32(20, 38, 76, 115);
// act // act
var actual = source.ToBgra32(); var actual = source.ToBgra32();
// assert // assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Fact] [Fact]
public void ToArgb32_Retval() public void ToArgb32_Retval()
{ {
// arrange // arrange
var source = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba64(5140, 9766, 19532, 29555);
var expected = new Argb32(20, 38, 76, 115); var expected = new Argb32(20, 38, 76, 115);
// act // act
var actual = source.ToArgb32(); var actual = source.ToArgb32();
// assert // assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Fact] [Fact]
public void ToRgb24_Retval() public void ToRgb24_Retval()
{ {
// arrange // arrange
var source = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba64(5140, 9766, 19532, 29555);
var expected = new Rgb24(20, 38, 76); var expected = new Rgb24(20, 38, 76);
// act // act
var actual = source.ToRgb24(); var actual = source.ToRgb24();
// assert // assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Fact] [Fact]
public void ToBgr24_Retval() public void ToBgr24_Retval()
{ {
// arrange // arrange
var source = new Rgba64(5140, 9766, 19532, 29555); var source = new Rgba64(5140, 9766, 19532, 29555);
var expected = new Bgr24(20, 38, 76); var expected = new Bgr24(20, 38, 76);
// act // act
var actual = source.ToBgr24(); var actual = source.ToBgr24();

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,

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

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ {
image.Metadata.ExifProfile = new ExifProfile(); image.Metadata.ExifProfile = new ExifProfile();
image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation);
image.Mutate(x => x.AutoOrient()); image.Mutate(x => x.AutoOrient());
image.DebugSave(provider, orientation, appendPixelTypeToFileName: false); image.DebugSave(provider, orientation, appendPixelTypeToFileName: false);
image.CompareToReferenceOutput(provider, orientation, appendPixelTypeToFileName: false); image.CompareToReferenceOutput(provider, orientation, appendPixelTypeToFileName: false);
@ -71,8 +71,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
bytes[18] = (byte)dataType; bytes[18] = (byte)dataType;
// 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);

6
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())
{ {
@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
} }
} }
} }

6
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++)
{ {
@ -108,4 +108,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
} }
} }
} }

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++)
{ {

12
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);
@ -106,4 +106,4 @@ namespace SixLabors.ImageSharp.Tests
private static float GetRandomFloat(this Random rnd, float minVal, float maxVal) => ((float)rnd.NextDouble() * (maxVal - minVal)) + minVal; private static float GetRandomFloat(this Random rnd, float minVal, float maxVal) => ((float)rnd.NextDouble() * (maxVal - minVal)) + minVal;
} }
} }

Loading…
Cancel
Save