Browse Source

Merge remote-tracking branch 'upstream/master' into feature/fixAdaptiveHistIssue

# Conflicts:
#	src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs
pull/984/head
Brian Popow 7 years ago
parent
commit
d714b6e203
  1. 2
      README.md
  2. 2
      src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
  3. 2
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
  4. 17
      src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
  5. 3
      src/ImageSharp/Advanced/AotCompilerTools.cs
  6. 4
      src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
  7. 27
      src/ImageSharp/Common/Extensions/EnumerableExtensions.cs
  8. 4
      src/ImageSharp/Common/Extensions/StreamExtensions.cs
  9. 5
      src/ImageSharp/Common/Helpers/Guard.cs
  10. 10
      src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs
  11. 4
      src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs
  12. 4
      src/ImageSharp/Common/Helpers/SimdUtils.cs
  13. 6
      src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs
  14. 20
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  15. 4
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  16. 2
      src/ImageSharp/Formats/Bmp/BmpFileHeader.cs
  17. 2
      src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs
  18. 3
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  19. 4
      src/ImageSharp/Formats/Gif/LzwDecoder.cs
  20. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  21. 12
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs
  22. 16
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt
  23. 6
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  24. 7
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs
  25. 7
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs
  26. 7
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs
  27. 7
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs
  28. 16
      src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
  29. 6
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  30. 2
      src/ImageSharp/Formats/Png/IPngDecoderOptions.cs
  31. 2
      src/ImageSharp/Formats/Png/PngConstants.cs
  32. 1
      src/ImageSharp/Formats/Png/PngDecoder.cs
  33. 6
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  34. 6
      src/ImageSharp/Image.FromBytes.cs
  35. 22
      src/ImageSharp/Image.cs
  36. 11
      src/ImageSharp/ImageExtensions.cs
  37. 2
      src/ImageSharp/ImageFrameCollection{TPixel}.cs
  38. 11
      src/ImageSharp/ImageFrame{TPixel}.cs
  39. 8
      src/ImageSharp/Image{TPixel}.cs
  40. 2
      src/ImageSharp/Memory/Buffer2DExtensions.cs
  41. 10
      src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
  42. 14
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
  43. 12
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs
  44. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs
  45. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs
  46. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs
  47. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
  48. 32
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
  49. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  50. 6
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  51. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  52. 2
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  53. 8
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  54. 110
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  55. 6
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  56. 4
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  57. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  58. 4
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  59. 4
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  60. 4
      src/ImageSharp/Primitives/ColorMatrix.cs
  61. 4
      src/ImageSharp/Primitives/Rational.cs
  62. 4
      src/ImageSharp/Primitives/SignedRational.cs
  63. 26
      src/ImageSharp/Processing/Extensions/ProcessingExtensions.cs
  64. 4
      src/ImageSharp/Processing/KnownFilterMatrices.cs
  65. 8
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  66. 13
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs
  67. 2
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  68. 6
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs
  69. 4
      src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs
  70. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs
  71. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
  72. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs
  73. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs
  74. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs
  75. 43
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs
  76. 4
      tests/ImageSharp.Benchmarks/General/CopyBuffers.cs
  77. 6
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs
  78. 2
      tests/ImageSharp.Benchmarks/General/Vector4Constants.cs
  79. 4
      tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs
  80. 6
      tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs
  81. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs
  82. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs
  83. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs
  84. 8
      tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs
  85. 12
      tests/ImageSharp.Tests/Color/ColorTests.CastFrom.cs
  86. 24
      tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs
  87. 24
      tests/ImageSharp.Tests/Color/ColorTests.ConstructFrom.cs
  88. 2
      tests/ImageSharp.Tests/Color/ColorTests.cs
  89. 2
      tests/ImageSharp.Tests/Colorspaces/RgbTests.cs
  90. 18
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
  91. 8
      tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
  92. 6
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  93. 14
      tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs
  94. 8
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  95. 4
      tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs
  96. 2
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  97. 12
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  98. 4
      tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs
  99. 6
      tests/ImageSharp.Tests/FakeImageOperationsProvider.cs
  100. 12
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

2
README.md

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

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

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

2
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
} }
float yPlusOne = y + 1; float yPlusOne = y + 1;
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction)
{ {
int pointsFound = region.Scan(subPixel + offset, buffer, configuration); int pointsFound = region.Scan(subPixel + offset, buffer, configuration);
if (pointsFound == 0) if (pointsFound == 0)

17
src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

@ -135,21 +135,22 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text
private readonly PathBuilder builder; private readonly PathBuilder builder;
private Point currentRenderPosition = default; private Point currentRenderPosition;
private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams = default; private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams;
private readonly int offset = 0; private readonly int offset;
private PointF currentPoint = default(PointF); private PointF currentPoint;
private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData> private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>
glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>(); glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>();
private readonly bool renderOutline = false; private readonly bool renderOutline;
private readonly bool renderFill = false; private readonly bool renderFill;
private bool rasterizationRequired = false; private bool rasterizationRequired;
public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill) public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill)
{ {
this.MemoryAllocator = memoryAllocator; this.MemoryAllocator = memoryAllocator;
this.currentRenderPosition = default;
this.Pen = pen; this.Pen = pen;
this.renderFill = renderFill; this.renderFill = renderFill;
this.renderOutline = pen != null; this.renderOutline = pen != null;
@ -326,7 +327,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text
bool scanlineDirty = false; bool scanlineDirty = false;
float yPlusOne = y + 1; float yPlusOne = y + 1;
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) for (float subPixel = y; subPixel < yPlusOne; subPixel += subpixelFraction)
{ {
var start = new PointF(path.Bounds.Left - 1, subPixel); var start = new PointF(path.Bounds.Left - 1, subPixel);
var end = new PointF(path.Bounds.Right + 1, subPixel); var end = new PointF(path.Bounds.Right + 1, subPixel);

3
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Dithering; using SixLabors.ImageSharp.Processing.Processors.Dithering;
using SixLabors.ImageSharp.Processing.Processors.Quantization; using SixLabors.ImageSharp.Processing.Processors.Quantization;
using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Advanced namespace SixLabors.ImageSharp.Advanced
{ {
@ -133,7 +132,7 @@ namespace SixLabors.ImageSharp.Advanced
{ {
var test = new FloydSteinbergDiffuser(); var test = new FloydSteinbergDiffuser();
TPixel pixel = default; TPixel pixel = default;
test.Dither<TPixel>(new ImageFrame<TPixel>(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0); test.Dither(new ImageFrame<TPixel>(Configuration.Default, 1, 1), pixel, pixel, 0, 0, 0, 0, 0, 0);
} }
/// <summary> /// <summary>

4
src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.Threading.Tasks; using System.Threading.Tasks;
@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
public static ParallelOptions GetParallelOptions(this Configuration configuration) public static ParallelOptions GetParallelOptions(this Configuration configuration)
{ {
return new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
} }
} }
} }

27
src/ImageSharp/Common/Extensions/EnumerableExtensions.cs

@ -11,33 +11,6 @@ namespace SixLabors.ImageSharp.Common
/// </summary> /// </summary>
internal static class EnumerableExtensions internal static class EnumerableExtensions
{ {
/// <summary>
/// Generates a sequence of integral numbers within a specified range.
/// </summary>
/// <param name="fromInclusive">
/// The start index, inclusive.
/// </param>
/// <param name="toExclusive">
/// The end index, exclusive.
/// </param>
/// <param name="step">
/// The incremental step.
/// </param>
/// <returns>
/// The <see cref="IEnumerable{Int32}"/> that contains a range of sequential integral numbers.
/// </returns>
public static IEnumerable<int> SteppedRange(int fromInclusive, int toExclusive, int step)
{
// Borrowed from Enumerable.Range
long num = (fromInclusive + toExclusive) - 1L;
if ((toExclusive < 0) || (num > 0x7fffffffL))
{
throw new ArgumentOutOfRangeException(nameof(toExclusive));
}
return RangeIterator(fromInclusive, i => i < toExclusive, step);
}
/// <summary> /// <summary>
/// Generates a sequence of integral numbers within a specified range. /// Generates a sequence of integral numbers within a specified range.
/// </summary> /// </summary>

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

5
src/ImageSharp/Common/Helpers/Guard.cs

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -231,7 +230,7 @@ namespace SixLabors.ImageSharp
{ {
if (destination.Length < source.Length) if (destination.Length < source.Length)
{ {
ThrowArgumentException($"Destination span is too short!", destinationParamName); ThrowArgumentException("Destination span is too short!", destinationParamName);
} }
} }
@ -251,7 +250,7 @@ namespace SixLabors.ImageSharp
{ {
if (destination.Length < source.Length) if (destination.Length < source.Length)
{ {
ThrowArgumentException($"Destination span is too short!", destinationParamName); ThrowArgumentException("Destination span is too short!", destinationParamName);
} }
} }

10
src/ImageSharp/Common/Helpers/SimdUtils.BasicIntrinsics256.cs

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

4
src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs

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

4
src/ImageSharp/Common/Helpers/SimdUtils.cs

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

6
src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.ParallelUtils
int verticalStep = DivideCeil(rectangle.Height, numOfSteps); int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
Parallel.For( Parallel.For(
0, 0,
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.ParallelUtils
int verticalStep = DivideCeil(rectangle.Height, numOfSteps); int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = numOfSteps }; var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
Parallel.For( Parallel.For(
0, 0,

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

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

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
return MemoryMarshal.Cast<byte, BmpFileHeader>(data)[0]; return MemoryMarshal.Cast<byte, BmpFileHeader>(data)[0];
} }
public unsafe void WriteTo(Span<byte> buffer) public void WriteTo(Span<byte> buffer)
{ {
ref BmpFileHeader dest = ref Unsafe.As<byte, BmpFileHeader>(ref MemoryMarshal.GetReference(buffer)); ref BmpFileHeader dest = ref Unsafe.As<byte, BmpFileHeader>(ref MemoryMarshal.GetReference(buffer));

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

@ -447,7 +447,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// Writes a complete Bitmap V4 header to a buffer. /// Writes a complete Bitmap V4 header to a buffer.
/// </summary> /// </summary>
/// <param name="buffer">The buffer to write to.</param> /// <param name="buffer">The buffer to write to.</param>
public unsafe void WriteV4Header(Span<byte> buffer) public void WriteV4Header(Span<byte> buffer)
{ {
ref BmpInfoHeader dest = ref Unsafe.As<byte, BmpInfoHeader>(ref MemoryMarshal.GetReference(buffer)); ref BmpInfoHeader dest = ref Unsafe.As<byte, BmpInfoHeader>(ref MemoryMarshal.GetReference(buffer));

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

@ -6,7 +6,6 @@ using System.Buffers;
using System.IO; using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
@ -84,7 +83,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global; bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;
// Quantize the image returning a palette. // Quantize the image returning a palette.
IQuantizedFrame<TPixel> quantized = null; IQuantizedFrame<TPixel> quantized;
using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration())) using (IFrameQuantizer<TPixel> frameQuantizer = this.quantizer.CreateFrameQuantizer<TPixel>(image.GetConfiguration()))
{ {
quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame); quantized = frameQuantizer.QuantizeFrame(image.Frames.RootFrame);

4
src/ImageSharp/Formats/Gif/LzwDecoder.cs

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

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

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

12
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs

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

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

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

6
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{ {
fixed (Vector4* ptr = &this.V0L) fixed (Vector4* ptr = &this.V0L)
{ {
float* fp = (float*)ptr; var fp = (float*)ptr;
for (int i = 0; i < Size; i++) for (int i = 0; i < Size; i++)
{ {
dest[i] = (int)fp[i]; dest[i] = (int)fp[i];
@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
public float[] ToArray() public float[] ToArray()
{ {
float[] result = new float[Size]; var result = new float[Size];
this.CopyTo(result); this.CopyTo(result);
return result; return result;
} }

7
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs

@ -25,11 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
var v = new Vector4(0, 0, 0, 1F); var v = new Vector4(0, 0, 0, 1F);
var scale = new Vector4( var maximum = 1 / this.MaximumValue;
1 / this.MaximumValue, var scale = new Vector4(maximum, maximum, maximum, 1F);
1 / this.MaximumValue,
1 / this.MaximumValue,
1F);
for (int i = 0; i < result.Length; i++) for (int i = 0; i < result.Length; i++)
{ {

7
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs

@ -19,11 +19,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
public override void ConvertToRgba(in ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(in ComponentValues values, Span<Vector4> result)
{ {
var scale = new Vector4( var maximum = 1 / this.MaximumValue;
1 / this.MaximumValue, var scale = new Vector4(maximum, maximum, maximum, 1F);
1 / this.MaximumValue,
1 / this.MaximumValue,
1F);
ref float sBase = ref MemoryMarshal.GetReference(values.Component0); ref float sBase = ref MemoryMarshal.GetReference(values.Component0);
ref Vector4 dBase = ref MemoryMarshal.GetReference(result); ref Vector4 dBase = ref MemoryMarshal.GetReference(result);

7
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs

@ -24,11 +24,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
var v = new Vector4(0, 0, 0, 1); var v = new Vector4(0, 0, 0, 1);
var scale = new Vector4( var maximum = 1 / this.MaximumValue;
1 / this.MaximumValue, var scale = new Vector4(maximum, maximum, maximum, 1F);
1 / this.MaximumValue,
1 / this.MaximumValue,
1F);
for (int i = 0; i < result.Length; i++) for (int i = 0; i < result.Length; i++)
{ {

7
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs

@ -25,11 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
var v = new Vector4(0, 0, 0, 1F); var v = new Vector4(0, 0, 0, 1F);
var scale = new Vector4( var maximum = 1 / this.MaximumValue;
1 / this.MaximumValue, var scale = new Vector4(maximum, maximum, maximum, 1F);
1 / this.MaximumValue,
1 / this.MaximumValue,
1F);
for (int i = 0; i < result.Length; i++) for (int i = 0; i < result.Length; i++)
{ {

16
src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs

@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
} }
} }
private unsafe void ParseBaselineDataInterleaved() private void ParseBaselineDataInterleaved()
{ {
// Interleaved // Interleaved
int mcu = 0; int mcu = 0;
@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
} }
} }
private unsafe void ParseBaselineDataNonInterleaved() private void ParseBaselineDataNonInterleaved()
{ {
JpegComponent component = this.components[this.frame.ComponentOrder[0]]; JpegComponent component = this.components[this.frame.ComponentOrder[0]];
ref HuffmanScanBuffer buffer = ref this.scanBuffer; ref HuffmanScanBuffer buffer = ref this.scanBuffer;
@ -209,7 +209,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
dcHuffmanTable.Configure(); dcHuffmanTable.Configure();
acHuffmanTable.Configure(); acHuffmanTable.Configure();
int mcu = 0;
for (int j = 0; j < h; j++) for (int j = 0; j < h; j++)
{ {
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j); Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@ -228,9 +227,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
ref dcHuffmanTable, ref dcHuffmanTable,
ref acHuffmanTable); ref acHuffmanTable);
// Every data block is an MCU, so countdown the restart interval
mcu++;
this.HandleRestart(); this.HandleRestart();
} }
} }
@ -366,7 +362,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
} }
} }
private unsafe void ParseProgressiveDataNonInterleaved() private void ParseProgressiveDataNonInterleaved()
{ {
JpegComponent component = this.components[this.frame.ComponentOrder[0]]; JpegComponent component = this.components[this.frame.ComponentOrder[0]];
ref HuffmanScanBuffer buffer = ref this.scanBuffer; ref HuffmanScanBuffer buffer = ref this.scanBuffer;
@ -379,7 +375,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DCHuffmanTableId]; ref HuffmanTable dcHuffmanTable = ref this.dcHuffmanTables[component.DCHuffmanTableId];
dcHuffmanTable.Configure(); dcHuffmanTable.Configure();
int mcu = 0;
for (int j = 0; j < h; j++) for (int j = 0; j < h; j++)
{ {
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j); Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@ -397,8 +392,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
ref Unsafe.Add(ref blockRef, i), ref Unsafe.Add(ref blockRef, i),
ref dcHuffmanTable); ref dcHuffmanTable);
// Every data block is an MCU, so countdown the restart interval
mcu++;
this.HandleRestart(); this.HandleRestart();
} }
} }
@ -408,7 +401,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
ref HuffmanTable acHuffmanTable = ref this.acHuffmanTables[component.ACHuffmanTableId]; ref HuffmanTable acHuffmanTable = ref this.acHuffmanTables[component.ACHuffmanTableId];
acHuffmanTable.Configure(); acHuffmanTable.Configure();
int mcu = 0;
for (int j = 0; j < h; j++) for (int j = 0; j < h; j++)
{ {
Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j); Span<Block8x8> blockSpan = component.SpectralBlocks.GetRowSpan(j);
@ -425,8 +417,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
ref Unsafe.Add(ref blockRef, i), ref Unsafe.Add(ref blockRef, i),
ref acHuffmanTable); ref acHuffmanTable);
// Every data block is an MCU, so countdown the restart interval
mcu++;
this.HandleRestart(); this.HandleRestart();
} }
} }

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)

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

@ -1,8 +1,6 @@
// 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.Text;
namespace SixLabors.ImageSharp.Formats.Png namespace SixLabors.ImageSharp.Formats.Png
{ {
/// <summary> /// <summary>

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

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary> /// <summary>
/// The dictionary of available color types. /// The dictionary of available color types.
/// </summary> /// </summary>
public static readonly Dictionary<PngColorType, byte[]> ColorTypes = new Dictionary<PngColorType, byte[]>() public static readonly Dictionary<PngColorType, byte[]> ColorTypes = new Dictionary<PngColorType, byte[]>
{ {
[PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 }, [PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 },
[PngColorType.Rgb] = new byte[] { 8, 16 }, [PngColorType.Rgb] = new byte[] { 8, 16 },

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

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.IO; using System.IO;
using System.Text;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Png namespace SixLabors.ImageSharp.Formats.Png

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

6
src/ImageSharp/Image.FromBytes.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp
/// <param name="config">The configuration.</param> /// <param name="config">The configuration.</param>
/// <param name="data">The byte array containing encoded image data to read the header from.</param> /// <param name="data">The byte array containing encoded image data to read the header from.</param>
/// <returns>The mime type or null if none found.</returns> /// <returns>The mime type or null if none found.</returns>
public static unsafe IImageFormat DetectFormat(Configuration config, ReadOnlySpan<byte> data) public static IImageFormat DetectFormat(Configuration config, ReadOnlySpan<byte> data)
{ {
int maxHeaderSize = config.MaxHeaderSize; int maxHeaderSize = config.MaxHeaderSize;
if (maxHeaderSize <= 0) if (maxHeaderSize <= 0)
@ -351,7 +351,7 @@ namespace SixLabors.ImageSharp
/// <param name="config">The configuration options.</param> /// <param name="config">The configuration options.</param>
/// <param name="data">The byte span containing image data.</param> /// <param name="data">The byte span containing image data.</param>
/// <returns>A new <see cref="Image"/>.</returns> /// <returns>A new <see cref="Image"/>.</returns>
public static unsafe Image Load(Configuration config, ReadOnlySpan<byte> data) => Load(config, data, out _); public static Image Load(Configuration config, ReadOnlySpan<byte> data) => Load(config, data, out _);
/// <summary> /// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte span. /// Load a new instance of <see cref="Image"/> from the given encoded byte span.

22
src/ImageSharp/Image.cs

@ -80,8 +80,22 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
Configuration IConfigurable.Configuration => this.Configuration; Configuration IConfigurable.Configuration => this.Configuration;
/// <summary>
/// Gets a value indicating whether the image instance is disposed.
/// </summary>
public bool IsDisposed { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public abstract void Dispose(); public void Dispose()
{
if (this.IsDisposed)
{
return;
}
this.IsDisposed = true;
this.DisposeImpl();
}
/// <summary> /// <summary>
/// Saves the image to the given stream using the given image encoder. /// Saves the image to the given stream using the given image encoder.
@ -93,6 +107,7 @@ namespace SixLabors.ImageSharp
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
Guard.NotNull(encoder, nameof(encoder)); Guard.NotNull(encoder, nameof(encoder));
this.EnsureNotDisposed();
EncodeVisitor visitor = new EncodeVisitor(encoder, stream); EncodeVisitor visitor = new EncodeVisitor(encoder, stream);
this.AcceptVisitor(visitor); this.AcceptVisitor(visitor);
@ -128,6 +143,11 @@ namespace SixLabors.ImageSharp
/// <param name="size">The <see cref="Size"/>.</param> /// <param name="size">The <see cref="Size"/>.</param>
protected void UpdateSize(Size size) => this.size = size; protected void UpdateSize(Size size) => this.size = size;
/// <summary>
/// Implements the Dispose logic.
/// </summary>
protected abstract void DisposeImpl();
private class EncodeVisitor : IImageVisitor private class EncodeVisitor : IImageVisitor
{ {
private readonly IImageEncoder encoder; private readonly IImageEncoder encoder;

11
src/ImageSharp/ImageExtensions.cs

@ -119,5 +119,16 @@ namespace SixLabors.ImageSharp
return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(stream.ToArray())}"; return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(stream.ToArray())}";
} }
} }
/// <summary>
/// Throws <see cref="ObjectDisposedException"/> if the image is disposed.
/// </summary>
internal static void EnsureNotDisposed(this Image image)
{
if (image.IsDisposed)
{
throw new ObjectDisposedException(nameof(image), "Trying to execute an operation on a disposed image.");
}
}
} }
} }

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

11
src/ImageSharp/ImageFrame{TPixel}.cs

@ -1,10 +1,10 @@
// 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;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata;
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThan(height, 0, nameof(height)); Guard.MustBeGreaterThan(height, 0, nameof(height));
this.PixelBuffer = this.MemoryAllocator.Allocate2D<TPixel>(width, height); this.PixelBuffer = this.MemoryAllocator.Allocate2D<TPixel>(width, height);
this.Clear(configuration.GetParallelOptions(), backgroundColor); this.Clear(backgroundColor);
} }
/// <summary> /// <summary>
@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp
ParallelHelper.IterateRows( ParallelHelper.IterateRows(
this.Bounds(), this.Bounds(),
configuration, configuration,
(rows) => rows =>
{ {
for (int y = rows.Min; y < rows.Max; y++) for (int y = rows.Min; y < rows.Max; y++)
{ {
@ -283,9 +283,8 @@ namespace SixLabors.ImageSharp
/// <summary> /// <summary>
/// Clears the bitmap. /// Clears the bitmap.
/// </summary> /// </summary>
/// <param name="parallelOptions">The parallel options.</param>
/// <param name="value">The value to initialize the bitmap with.</param> /// <param name="value">The value to initialize the bitmap with.</param>
internal void Clear(ParallelOptions parallelOptions, TPixel value) internal void Clear(TPixel value)
{ {
Span<TPixel> span = this.GetPixelSpan(); Span<TPixel> span = this.GetPixelSpan();

8
src/ImageSharp/Image{TPixel}.cs

@ -162,6 +162,8 @@ namespace SixLabors.ImageSharp
/// <returns>Returns a new <see cref="Image{TPixel}"/> with all the same pixel data as the original.</returns> /// <returns>Returns a new <see cref="Image{TPixel}"/> with all the same pixel data as the original.</returns>
public Image<TPixel> Clone(Configuration configuration) public Image<TPixel> Clone(Configuration configuration)
{ {
this.EnsureNotDisposed();
IEnumerable<ImageFrame<TPixel>> clonedFrames = IEnumerable<ImageFrame<TPixel>> clonedFrames =
this.Frames.Select<ImageFrame<TPixel>, ImageFrame<TPixel>>(x => x.Clone(configuration)); this.Frames.Select<ImageFrame<TPixel>, ImageFrame<TPixel>>(x => x.Clone(configuration));
return new Image<TPixel>(configuration, this.Metadata.DeepClone(), clonedFrames); return new Image<TPixel>(configuration, this.Metadata.DeepClone(), clonedFrames);
@ -175,17 +177,21 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel2}"/>.</returns> /// <returns>The <see cref="Image{TPixel2}"/>.</returns>
public override Image<TPixel2> CloneAs<TPixel2>(Configuration configuration) public override Image<TPixel2> CloneAs<TPixel2>(Configuration configuration)
{ {
this.EnsureNotDisposed();
IEnumerable<ImageFrame<TPixel2>> clonedFrames = IEnumerable<ImageFrame<TPixel2>> clonedFrames =
this.Frames.Select<ImageFrame<TPixel>, ImageFrame<TPixel2>>(x => x.CloneAs<TPixel2>(configuration)); this.Frames.Select<ImageFrame<TPixel>, ImageFrame<TPixel2>>(x => x.CloneAs<TPixel2>(configuration));
return new Image<TPixel2>(configuration, this.Metadata.DeepClone(), clonedFrames); return new Image<TPixel2>(configuration, this.Metadata.DeepClone(), clonedFrames);
} }
/// <inheritdoc/> /// <inheritdoc/>
public override void Dispose() => this.Frames.Dispose(); protected override void DisposeImpl() => this.Frames.Dispose();
/// <inheritdoc /> /// <inheritdoc />
internal override void AcceptVisitor(IImageVisitor visitor) internal override void AcceptVisitor(IImageVisitor visitor)
{ {
this.EnsureNotDisposed();
visitor.Visit(this); visitor.Visit(this);
} }

2
src/ImageSharp/Memory/Buffer2DExtensions.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Memory
fixed (byte* ptr = span) fixed (byte* ptr = span)
{ {
byte* basePtr = (byte*)ptr; byte* basePtr = ptr;
for (int y = 0; y < buffer.Height; y++) for (int y = 0; y < buffer.Height; y++)
{ {
byte* sPtr = basePtr + sOffset; byte* sPtr = basePtr + sOffset;

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -53,12 +53,12 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
if (this.exifIndexes.Count > 0) if (this.exifIndexes.Count > 0)
{ {
exifIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset); exifIndex = this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset);
} }
if (this.gpsIndexes.Count > 0) if (this.gpsIndexes.Count > 0)
{ {
gpsIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset); gpsIndex = this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset);
} }
uint ifdLength = 2 + this.GetLength(this.ifdIndexes) + 4; uint ifdLength = 2 + this.GetLength(this.ifdIndexes) + 4;
@ -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;
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
i = this.WriteData(startIndex, this.gpsIndexes, result, i); i = this.WriteData(startIndex, this.gpsIndexes, result, i);
} }
WriteUInt16((ushort)0, result, i); WriteUInt16(0, result, i);
return result; return result;
} }

14
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs

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

12
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs

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

6
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Metadata.Profiles.Icc namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read matrix</returns> /// <returns>The read matrix</returns>
public float[,] ReadMatrix(int xCount, int yCount, bool isSingle) public float[,] ReadMatrix(int xCount, int yCount, bool isSingle)
{ {
float[,] matrix = new float[xCount, yCount]; var matrix = new float[xCount, yCount];
for (int y = 0; y < yCount; y++) for (int y = 0; y < yCount; y++)
{ {
for (int x = 0; x < xCount; x++) for (int x = 0; x < xCount; x++)
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read matrix</returns> /// <returns>The read matrix</returns>
public float[] ReadMatrix(int yCount, bool isSingle) public float[] ReadMatrix(int yCount, bool isSingle)
{ {
float[] matrix = new float[yCount]; var matrix = new float[yCount];
for (int i = 0; i < yCount; i++) for (int i = 0; i < yCount; i++)
{ {
if (isSingle) if (isSingle)

4
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs

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

4
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{ {
string name = this.ReadAsciiString(32); string name = this.ReadAsciiString(32);
ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() };
ushort[] deviceCoord = new ushort[deviceCoordCount]; var deviceCoord = new ushort[deviceCoordCount];
for (int i = 0; i < deviceCoordCount; i++) for (int i = 0; i < deviceCoordCount; i++)
{ {

4
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
/// <returns>The read bytes</returns> /// <returns>The read bytes</returns>
public byte[] ReadBytes(int count) public byte[] ReadBytes(int count)
{ {
byte[] bytes = new byte[count]; var bytes = new byte[count];
Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count); Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count);
return bytes; return bytes;
} }

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

@ -153,12 +153,10 @@ 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[2]; values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() };
values[i][0] = this.ReadUFix16();
values[i][1] = this.ReadUFix16();
} }
return new IccChromaticityTagDataEntry(values); return new IccChromaticityTagDataEntry(values);
@ -210,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;
@ -266,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);
@ -301,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();
@ -466,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++)
{ {
@ -629,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();
@ -653,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;
@ -689,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();
@ -706,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();
@ -723,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();
@ -740,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();
@ -880,14 +878,14 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size) public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
{ {
uint ucrCount = this.ReadUInt32(); uint ucrCount = this.ReadUInt32();
ushort[] ucrCurve = new ushort[ucrCount]; var ucrCurve = new ushort[ucrCount];
for (int i = 0; i < ucrCurve.Length; i++) for (int i = 0; i < ucrCurve.Length; i++)
{ {
ucrCurve[i] = this.ReadUInt16(); ucrCurve[i] = this.ReadUInt16();
} }
uint bgCount = this.ReadUInt32(); uint bgCount = this.ReadUInt32();
ushort[] bgCurve = new ushort[bgCount]; var bgCurve = new ushort[bgCount];
for (int i = 0; i < bgCurve.Length; i++) for (int i = 0; i < bgCurve.Length; i++)
{ {
bgCurve[i] = this.ReadUInt16(); bgCurve[i] = this.ReadUInt16();

6
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs

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

6
src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
const int profileIdPos = 84; const int profileIdPos = 84;
// need to copy some values because they need to be zero for the hashing // need to copy some values because they need to be zero for the hashing
byte[] temp = new byte[24]; var temp = new byte[24];
Buffer.BlockCopy(data, profileFlagPos, temp, 0, 4); Buffer.BlockCopy(data, profileFlagPos, temp, 0, 4);
Buffer.BlockCopy(data, renderingIntentPos, temp, 4, 4); Buffer.BlockCopy(data, renderingIntentPos, temp, 4, 4);
Buffer.BlockCopy(data, profileIdPos, temp, 8, 16); Buffer.BlockCopy(data, profileIdPos, temp, 8, 16);
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{ {
if (this.data != null) if (this.data != null)
{ {
byte[] copy = new byte[this.data.Length]; var copy = new byte[this.data.Length];
Buffer.BlockCopy(this.data, 0, copy, 0, copy.Length); Buffer.BlockCopy(this.data, 0, copy, 0, copy.Length);
return copy; return copy;
} }

4
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
&& p3 >= 0x41 && p3 <= 0x5A && p3 >= 0x41 && p3 <= 0x5A
&& p4 >= 0x41 && p4 <= 0x5A) && p4 >= 0x41 && p4 <= 0x5A)
{ {
string culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); var culture = new string(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 });
return new CultureInfo(culture); return new CultureInfo(culture);
} }

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// <auto-generated /> // <auto-generated />

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

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

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

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

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

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

4
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) public void FromScaledVector4(Vector4 vector)
{ {
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; var scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One; scaled -= Vector2.One;
this.PackedValue = Pack(scaled.X, scaled.Y); this.PackedValue = Pack(scaled.X, scaled.Y);
} }

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) public void FromScaledVector4(Vector4 vector)
{ {
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; var scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One; scaled -= Vector2.One;
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) public void FromScaledVector4(Vector4 vector)
{ {
Vector2 scaled = new Vector2(vector.X, vector.Y) * 2F; var scaled = new Vector2(vector.X, vector.Y) * 2F;
scaled -= Vector2.One; scaled -= Vector2.One;
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void FromScaledVector4(Vector4 vector) public void FromScaledVector4(Vector4 vector)
{ {
Vector2 scaled = new Vector2(vector.X, vector.Y) * 65534F; var scaled = new Vector2(vector.X, vector.Y) * 65534F;
scaled -= new Vector2(32767F); scaled -= new Vector2(32767F);
this.PackedValue = Pack(scaled); this.PackedValue = Pack(scaled);
} }

4
src/ImageSharp/Primitives/ColorMatrix.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#pragma warning disable SA1117 // Parameters should be on same line or separate lines #pragma warning disable SA1117 // Parameters should be on same line or separate lines
@ -269,7 +269,7 @@ namespace SixLabors.ImageSharp.Primitives
/// </summary> /// </summary>
/// <param name="value">The source matrix.</param> /// <param name="value">The source matrix.</param>
/// <returns>The negated matrix.</returns> /// <returns>The negated matrix.</returns>
public static unsafe ColorMatrix operator -(ColorMatrix value) public static ColorMatrix operator -(ColorMatrix value)
{ {
ColorMatrix m; ColorMatrix m;

4
src/ImageSharp/Primitives/Rational.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives
{ {
if (simplify) if (simplify)
{ {
LongRational rational = new LongRational(numerator, denominator).Simplify(); var rational = new LongRational(numerator, denominator).Simplify();
this.Numerator = (uint)rational.Numerator; this.Numerator = (uint)rational.Numerator;
this.Denominator = (uint)rational.Denominator; this.Denominator = (uint)rational.Denominator;

4
src/ImageSharp/Primitives/SignedRational.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Primitives
{ {
if (simplify) if (simplify)
{ {
LongRational rational = new LongRational(numerator, denominator).Simplify(); var rational = new LongRational(numerator, denominator).Simplify();
this.Numerator = (int)rational.Numerator; this.Numerator = (int)rational.Numerator;
this.Denominator = (int)rational.Denominator; this.Denominator = (int)rational.Denominator;

26
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;
@ -21,7 +21,11 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="operation">The operation to perform on the source.</param> /// <param name="operation">The operation to perform on the source.</param>
public static void Mutate(this Image source, Action<IImageProcessingContext> operation) public static void Mutate(this Image source, Action<IImageProcessingContext> operation)
{ {
ProcessingVisitor visitor = new ProcessingVisitor(operation, true); Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
var visitor = new ProcessingVisitor(operation, true);
source.AcceptVisitor(visitor); source.AcceptVisitor(visitor);
} }
@ -34,8 +38,9 @@ namespace SixLabors.ImageSharp.Processing
public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation) public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Guard.NotNull(operation, nameof(operation));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
.CreateImageProcessingContext(source, true); .CreateImageProcessingContext(source, true);
@ -51,8 +56,9 @@ namespace SixLabors.ImageSharp.Processing
public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations) public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.NotNull(operations, nameof(operations));
source.EnsureNotDisposed();
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
.CreateImageProcessingContext(source, true); .CreateImageProcessingContext(source, true);
@ -67,7 +73,11 @@ namespace SixLabors.ImageSharp.Processing
/// <returns>The new <see cref="SixLabors.ImageSharp.Image"/>.</returns> /// <returns>The new <see cref="SixLabors.ImageSharp.Image"/>.</returns>
public static Image Clone(this Image source, Action<IImageProcessingContext> operation) public static Image Clone(this Image source, Action<IImageProcessingContext> operation)
{ {
ProcessingVisitor visitor = new ProcessingVisitor(operation, false); Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
var visitor = new ProcessingVisitor(operation, false);
source.AcceptVisitor(visitor); source.AcceptVisitor(visitor);
return visitor.ResultImage; return visitor.ResultImage;
} }
@ -82,8 +92,9 @@ namespace SixLabors.ImageSharp.Processing
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext> operation)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Guard.NotNull(operation, nameof(operation));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.NotNull(operation, nameof(operation));
source.EnsureNotDisposed();
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
.CreateImageProcessingContext(source, false); .CreateImageProcessingContext(source, false);
@ -101,8 +112,9 @@ namespace SixLabors.ImageSharp.Processing
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations) public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, params IImageProcessor[] operations)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source)); Guard.NotNull(source, nameof(source));
Guard.NotNull(operations, nameof(operations));
source.EnsureNotDisposed();
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
.CreateImageProcessingContext(source, false); .CreateImageProcessingContext(source, false);

4
src/ImageSharp/Processing/KnownFilterMatrices.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Processing
/// <summary> /// <summary>
/// Gets an approximated black and white filter /// Gets an approximated black and white filter
/// </summary> /// </summary>
public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix() public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix
{ {
M11 = 1.5F, M11 = 1.5F,
M12 = 1.5F, M12 = 1.5F,

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

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

13
src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs

@ -76,29 +76,26 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
Parallel.For( Parallel.For(
0, 0,
tileYStartPositions.Count, tileYStartPositions.Count,
new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }, new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism },
index => index =>
{ {
int cdfX = 0;
int tileX = 0;
int tileY = 0;
int y = tileYStartPositions[index].y; int y = tileYStartPositions[index].y;
int cdfYY = tileYStartPositions[index].cdfY; int cdfYY = tileYStartPositions[index].cdfY;
// It's unfortunate that we have to do this per iteration. // It's unfortunate that we have to do this per iteration.
ref TPixel sourceBase = ref source.GetPixelReference(0, 0); ref TPixel sourceBase = ref source.GetPixelReference(0, 0);
cdfX = 0; int cdfX = 0;
int x = halfTileWidth; int x = halfTileWidth;
for (int tile = 0; tile < tileCount - 1; tile++) for (int tile = 0; tile < tileCount - 1; tile++)
{ {
tileY = 0; int tileY = 0;
int yEnd = Math.Min(y + tileHeight, sourceHeight); int yEnd = Math.Min(y + tileHeight, sourceHeight);
int xEnd = Math.Min(x + tileWidth, sourceWidth); int xEnd = Math.Min(x + tileWidth, sourceWidth);
for (int dy = y; dy < yEnd; dy++) for (int dy = y; dy < yEnd; dy++)
{ {
int dyOffSet = dy * sourceWidth; int dyOffSet = dy * sourceWidth;
tileX = 0; int tileX = 0;
for (int dx = x; dx < xEnd; dx++) for (int dx = x; dx < xEnd; dx++)
{ {
ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx); ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx);
@ -474,7 +471,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
Parallel.For( Parallel.For(
0, 0,
this.tileYStartPositions.Count, this.tileYStartPositions.Count,
new ParallelOptions() { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, new ParallelOptions { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism },
index => index =>
{ {
int cdfX = 0; int cdfX = 0;

2
src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs

@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
{ {
MemoryAllocator memoryAllocator = configuration.MemoryAllocator; MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
int tileWidth = source.Width / this.Tiles; int tileWidth = source.Width / this.Tiles;
int tileHeight = tileWidth; int tileHeight = tileWidth;
int pixelInTile = tileWidth * tileHeight; int pixelInTile = tileWidth * tileHeight;

6
src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs

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

4
src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -828,7 +828,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
private void BuildCube() private void BuildCube()
{ {
this.colorCube = new Box[this.colors]; this.colorCube = new Box[this.colors];
double[] vv = new double[this.colors]; var vv = new double[this.colors];
ref Box cube = ref this.colorCube[0]; ref Box cube = ref this.colorCube[0];
cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0; cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0;

4
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{ {
public class Block8x8F_Round public class Block8x8F_Round
{ {
private Block8x8F block = default(Block8x8F); private Block8x8F block;
[GlobalSetup] [GlobalSetup]
public void Setup() public void Setup()

4
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{ {
using (var memoryStream = new MemoryStream(this.jpegBytes)) using (var memoryStream = new MemoryStream(this.jpegBytes))
{ {
var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder() { IgnoreMetadata = true }); var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder { IgnoreMetadata = true });
decoder.ParseStream(memoryStream); decoder.ParseStream(memoryStream);
decoder.Dispose(); decoder.Dispose();
} }

4
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.Drawing; using System.Drawing;
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{ {
using (var memoryStream = new MemoryStream(this.jpegBytes)) using (var memoryStream = new MemoryStream(this.jpegBytes))
{ {
using (var image = Image.Load<Rgba32>(memoryStream, new JpegDecoder() { IgnoreMetadata = true })) using (var image = Image.Load<Rgba32>(memoryStream, new JpegDecoder { IgnoreMetadata = true }))
{ {
return new CoreSize(image.Width, image.Height); return new CoreSize(image.Width, image.Height);
} }

4
tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
private static byte[] CreateTestBytes() private static byte[] CreateTestBytes()
{ {
byte[] buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3]; var buffer = new byte[DoubleBufferedStreamReader.ChunkLength * 3];
var random = new Random(); var random = new Random();
random.NextBytes(buffer); random.NextBytes(buffer);

6
tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -67,10 +67,10 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
float maxVal = 255f) float maxVal = 255f)
{ {
var rnd = new Random(42); var rnd = new Random(42);
Buffer2D<float>[] buffers = new Buffer2D<float>[componentCount]; var buffers = new Buffer2D<float>[componentCount];
for (int i = 0; i < componentCount; i++) for (int i = 0; i < componentCount; i++)
{ {
float[] values = new float[inputBufferLength]; var values = new float[inputBufferLength];
for (int j = 0; j < inputBufferLength; j++) for (int j = 0; j < inputBufferLength; j++)
{ {

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

@ -85,7 +85,6 @@ namespace SixLabors.ImageSharp.Benchmarks
} }
} }
// Waiting for C# 7 stackalloc keyword patiently ...
private static class OnStackInputCache private static class OnStackInputCache
{ {
public unsafe struct Byte public unsafe struct Byte
@ -94,7 +93,7 @@ namespace SixLabors.ImageSharp.Benchmarks
public static Byte Create(byte[] data) public static Byte Create(byte[] data)
{ {
Byte result = default(Byte); Byte result = default;
for (int i = 0; i < data.Length; i++) for (int i = 0; i < data.Length; i++)
{ {
result.Data[i] = data[i]; result.Data[i] = data[i];
@ -113,9 +112,9 @@ namespace SixLabors.ImageSharp.Benchmarks
// The operation is defined as "RGBA -> YCbCr Transform a stream of bytes into a stream of floats" // The operation is defined as "RGBA -> YCbCr Transform a stream of bytes into a stream of floats"
// We need to benchmark the whole operation, to get true results, not missing any side effects! // We need to benchmark the whole operation, to get true results, not missing any side effects!
private byte[] inputSourceRGB = null; private byte[] inputSourceRGB;
private int[] inputSourceRGBAsInteger = null; private int[] inputSourceRGBAsInteger;
[GlobalSetup] [GlobalSetup]
public void Setup() public void Setup()
@ -133,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++)
@ -159,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]
@ -195,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);
@ -211,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;
@ -265,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;
@ -300,10 +299,10 @@ 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 result = default;
float* yPtr = (float*)&result.Y; float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb; float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr; float* crPtr = (float*)&result.Cr;
@ -339,10 +338,10 @@ 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 result = default;
float* yPtr = (float*)&result.Y; float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb; float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr; float* crPtr = (float*)&result.Cr;

4
tests/ImageSharp.Benchmarks/General/CopyBuffers.cs

@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General
} }
[Benchmark(Description = "Unsafe.CopyBlock(ref)")] [Benchmark(Description = "Unsafe.CopyBlock(ref)")]
public unsafe void UnsafeCopyBlockReferences() public void UnsafeCopyBlockReferences()
{ {
Unsafe.CopyBlock(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); Unsafe.CopyBlock(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count);
} }
@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General
} }
[Benchmark(Description = "Unsafe.CopyBlockUnaligned(ref)")] [Benchmark(Description = "Unsafe.CopyBlockUnaligned(ref)")]
public unsafe void UnsafeCopyBlockUnalignedReferences() public void UnsafeCopyBlockUnalignedReferences()
{ {
Unsafe.CopyBlockUnaligned(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count); Unsafe.CopyBlockUnaligned(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count);
} }

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

@ -1,4 +1,4 @@
using System; using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -253,8 +253,8 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
private static void BitopsSimdImpl(ref Octet.OfUInt32 s, ref Octet.OfUInt32 d) private static void BitopsSimdImpl(ref Octet.OfUInt32 s, ref Octet.OfUInt32 d)
{ {
Vector<uint> sVec = Unsafe.As<Octet.OfUInt32, Vector<uint>>(ref s); Vector<uint> sVec = Unsafe.As<Octet.OfUInt32, Vector<uint>>(ref s);
Vector<uint> aMask = new Vector<uint>(0xFF00FF00); var aMask = new Vector<uint>(0xFF00FF00);
Vector<uint> bMask = new Vector<uint>(0x00FF00FF); var bMask = new Vector<uint>(0x00FF00FF);
Vector<uint> aa = sVec & aMask; Vector<uint> aa = sVec & aMask;
Vector<uint> bb = sVec & bMask; Vector<uint> bb = sVec & bMask;

2
tests/ImageSharp.Benchmarks/General/Vector4Constants.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General
private static readonly Vector4 C = new Vector4(5.6f); private static readonly Vector4 C = new Vector4(5.6f);
private static readonly Vector4 D = new Vector4(7.8f); private static readonly Vector4 D = new Vector4(7.8f);
private Random random = null; private Random random;
private Vector4 parameter; private Vector4 parameter;

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

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

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

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

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

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

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

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

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

@ -16,7 +16,7 @@ namespace ImageSharp.Benchmarks.General.Vectorization
protected Vector<T> testVector; protected Vector<T> testVector;
protected virtual T GetTestValue() => default(T); protected virtual T GetTestValue() => default;
protected virtual Vector<T> GetTestVector() => new Vector<T>(this.GetTestValue()); protected virtual Vector<T> GetTestVector() => new Vector<T>(this.GetTestValue());

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

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

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

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

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

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

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

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

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

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests
Color c1 = Color.FromRgba(111, 222, 55, 255); Color c1 = Color.FromRgba(111, 222, 55, 255);
Color c2 = c1.WithAlpha(0.5f); Color c2 = c1.WithAlpha(0.5f);
Rgba32 expected = new Rgba32(111, 222, 55, 128); var expected = new Rgba32(111, 222, 55, 128);
Assert.Equal(expected, (Rgba32)c2); Assert.Equal(expected, (Rgba32)c2);
} }

2
tests/ImageSharp.Tests/Colorspaces/RgbTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.Numerics; using System.Numerics;

18
tests/ImageSharp.Tests/Common/SimdUtilsTests.cs

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

8
tests/ImageSharp.Tests/Drawing/DrawImageTests.cs

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

6
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void PathExtendingOffEdgeOfImageShouldNotBeCropped<TPixel>(TestImageProvider<TPixel> provider) public void PathExtendingOffEdgeOfImageShouldNotBeCropped<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = Color.White; var color = Color.White;
Pen pen = Pens.Solid(color, 5f); Pen pen = Pens.Solid(color, 5f);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
for (int i = 0; i < 300; i += 20) for (int i = 0; i < 300; i += 20)
{ {
PointF[] points = new PointF[] { new Vector2(100, 2), new Vector2(-10, i) }; var points = new PointF[] { new Vector2(100, 2), new Vector2(-10, i) };
x.DrawLines(pen, points); x.DrawLines(pen, points);
} }
}, },

14
tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs

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

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -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);
@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
} }
public static readonly TheoryData<bool, string, float, PixelColorBlendingMode, float> BlendData = public static readonly TheoryData<bool, string, float, PixelColorBlendingMode, float> BlendData =
new TheoryData<bool, string, float, PixelColorBlendingMode, float>() new TheoryData<bool, string, float, PixelColorBlendingMode, float>
{ {
{ false, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f }, { false, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f },
{ false, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f }, { false, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f },

4
tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public ShapeRegionTests() public ShapeRegionTests()
{ {
this.pathMock = new Mock<MockPath>() { CallBase = true }; this.pathMock = new Mock<MockPath> { CallBase = true };
this.bounds = new RectangleF(10.5f, 10, 10, 10); this.bounds = new RectangleF(10.5f, 10, 10, 10);
this.pathMock.Setup(x => x.Bounds).Returns(this.bounds); this.pathMock.Setup(x => x.Bounds).Returns(this.bounds);

2
tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

@ -3,11 +3,9 @@
using System.Numerics; using System.Numerics;
using SixLabors.Fonts; using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Text; using SixLabors.ImageSharp.Processing.Processors.Text;
using SixLabors.Primitives; using SixLabors.Primitives;
using SixLabors.Shapes;
using Xunit; using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing.Text namespace SixLabors.ImageSharp.Tests.Drawing.Text

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

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

4
tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Tests.Drawing.Utils namespace SixLabors.ImageSharp.Tests.Drawing.Utils
@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Utils
public class QuickSortTests public class QuickSortTests
{ {
public static readonly TheoryData<float[]> Data = new TheoryData<float[]>() public static readonly TheoryData<float[]> Data = new TheoryData<float[]>
{ {
new float[]{ 3, 2, 1 }, new float[]{ 3, 2, 1 },
new float[0], new float[0],

6
tests/ImageSharp.Tests/FakeImageOperationsProvider.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.Collections.Generic; using System.Collections.Generic;
@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests
public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle)
{ {
this.Applied.Add(new AppliedOperation() this.Applied.Add(new AppliedOperation
{ {
Rectangle = rectangle, Rectangle = rectangle,
NonGenericProcessor = processor NonGenericProcessor = processor
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests
public IImageProcessingContext ApplyProcessor(IImageProcessor processor) public IImageProcessingContext ApplyProcessor(IImageProcessor processor)
{ {
this.Applied.Add(new AppliedOperation() this.Applied.Add(new AppliedOperation
{ {
NonGenericProcessor = processor NonGenericProcessor = processor
}); });

12
tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit_WithDelta<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }))
{ {
image.DebugSave(provider); image.DebugSave(provider);
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_4Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }))
{ {
image.DebugSave(provider); image.DebugSave(provider);
// The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows. // The Magick Reference Decoder can not decode 4-Bit bitmaps, so only execute this on windows.
@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_SystemDrawingRefDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }))
{ {
image.DebugSave(provider); image.DebugSave(provider);
if (TestEnvironment.IsWindows) if (TestEnvironment.IsWindows)
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit_WithDelta_MagickRefDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }))
{ {
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToOriginal(provider, new MagickReferenceDecoder()); image.CompareToOriginal(provider, new MagickReferenceDecoder());
@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.FirstColorOfPalette }))
{ {
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToOriginal(provider, new MagickReferenceDecoder()); image.CompareToOriginal(provider, new MagickReferenceDecoder());
@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage(new BmpDecoder() { RleSkippedPixelHandling = RleSkippedPixelHandling.Black })) using (Image<TPixel> image = provider.GetImage(new BmpDecoder { RleSkippedPixelHandling = RleSkippedPixelHandling.Black }))
{ {
image.DebugSave(provider); image.DebugSave(provider);

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

Loading…
Cancel
Save