Browse Source

Cleanup (#965)

* redundant ()

* redundant stirng interpolation

* use method groups

* redundant unsafe

* redundant qualifiers

* redundant ()

* redundant init

* redundant init

* redundant casts

* redundant casts
af/merge-core
Simon Cropp 7 years ago
committed by James Jackson-South
parent
commit
270a073fc6
  1. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
  2. 17
      src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
  3. 6
      src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs
  4. 4
      src/ImageSharp/Common/Helpers/Guard.cs
  5. 8
      src/ImageSharp/Common/ParallelUtils/ParallelHelper.cs
  6. 2
      src/ImageSharp/Formats/Bmp/BmpFileHeader.cs
  7. 2
      src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs
  8. 2
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  9. 6
      src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs
  10. 2
      src/ImageSharp/Formats/Png/PngConstants.cs
  11. 8
      src/ImageSharp/Image.FromBytes.cs
  12. 4
      src/ImageSharp/ImageFrame{TPixel}.cs
  13. 4
      src/ImageSharp/Memory/Buffer2DExtensions.cs
  14. 10
      src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs
  15. 6
      src/ImageSharp/Primitives/ColorMatrix.cs
  16. 4
      src/ImageSharp/Processing/KnownFilterMatrices.cs
  17. 4
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs
  18. 2
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  19. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs
  20. 6
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs
  21. 4
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs
  22. 10
      tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs
  23. 4
      tests/ImageSharp.Benchmarks/General/CopyBuffers.cs
  24. 4
      tests/ImageSharp.Benchmarks/General/Vector4Constants.cs
  25. 4
      tests/ImageSharp.Benchmarks/General/Vectorization/SIMDBenchmarkBase.cs
  26. 6
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  27. 6
      tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs
  28. 6
      tests/ImageSharp.Tests/Drawing/Utils/QuickSortTests.cs
  29. 8
      tests/ImageSharp.Tests/FakeImageOperationsProvider.cs
  30. 12
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
  31. 2
      tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs
  32. 6
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  33. 4
      tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
  34. 4
      tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs
  35. 5
      tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs
  36. 10
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
  37. 6
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
  38. 16
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs
  39. 6
      tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs
  40. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs
  41. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs
  42. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  43. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs
  44. 2
      tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
  45. 4
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs
  46. 10
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs
  47. 6
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs
  48. 6
      tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs
  49. 4
      tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs
  50. 16
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs
  51. 10
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
  52. 6
      tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
  53. 10
      tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs
  54. 24
      tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs
  55. 6
      tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs
  56. 4
      tests/ImageSharp.Tests/Image/ImageSaveTests.cs
  57. 2
      tests/ImageSharp.Tests/ImageOperationTests.cs
  58. 4
      tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
  59. 2
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  60. 4
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs
  61. 4
      tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
  62. 4
      tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
  63. 6
      tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs
  64. 18
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs
  65. 20
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs
  66. 8
      tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs
  67. 4
      tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
  68. 6
      tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
  69. 8
      tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs
  70. 10
      tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs
  71. 8
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs
  72. 4
      tests/ImageSharp.Tests/TestFont.cs
  73. 4
      tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs
  74. 12
      tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs
  75. 4
      tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs
  76. 16
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

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

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

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

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

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

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

@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp
{
if (destination.Length < source.Length)
{
ThrowArgumentException($"Destination span is too short!", destinationParamName);
ThrowArgumentException("Destination span is too short!", destinationParamName);
}
}
@ -251,7 +251,7 @@ namespace SixLabors.ImageSharp
{
if (destination.Length < source.Length)
{
ThrowArgumentException($"Destination span is too short!", destinationParamName);
ThrowArgumentException("Destination span is too short!", destinationParamName);
}
}

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

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

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

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
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));

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.
/// </summary>
/// <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));

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

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

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

@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
}
}
private unsafe void ParseBaselineDataInterleaved()
private void ParseBaselineDataInterleaved()
{
// Interleaved
int mcu = 0;
@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
}
}
private unsafe void ParseBaselineDataNonInterleaved()
private void ParseBaselineDataNonInterleaved()
{
JpegComponent component = this.components[this.frame.ComponentOrder[0]];
ref HuffmanScanBuffer buffer = ref this.scanBuffer;
@ -366,7 +366,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
}
}
private unsafe void ParseProgressiveDataNonInterleaved()
private void ParseProgressiveDataNonInterleaved()
{
JpegComponent component = this.components[this.frame.ComponentOrder[0]];
ref HuffmanScanBuffer buffer = ref this.scanBuffer;

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

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// The dictionary of available color types.
/// </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.Rgb] = new byte[] { 8, 16 },

8
src/ImageSharp/Image.FromBytes.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp
/// <param name="config">The configuration.</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>
public static unsafe IImageFormat DetectFormat(Configuration config, ReadOnlySpan<byte> data)
public static IImageFormat DetectFormat(Configuration config, ReadOnlySpan<byte> data)
{
int maxHeaderSize = config.MaxHeaderSize;
if (maxHeaderSize <= 0)
@ -351,7 +351,7 @@ namespace SixLabors.ImageSharp
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte span containing image data.</param>
/// <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>
/// Load a new instance of <see cref="Image"/> from the given encoded byte span.
@ -395,4 +395,4 @@ namespace SixLabors.ImageSharp
}
}
}
}
}

4
src/ImageSharp/ImageFrame{TPixel}.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp
ParallelHelper.IterateRows(
this.Bounds(),
configuration,
(rows) =>
rows =>
{
for (int y = rows.Min; y < rows.Max; y++)
{

4
src/ImageSharp/Memory/Buffer2DExtensions.cs

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

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.
using System;
@ -53,12 +53,12 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
if (this.exifIndexes.Count > 0)
{
exifIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset);
exifIndex = this.GetIndex(this.ifdIndexes, ExifTag.SubIFDOffset);
}
if (this.gpsIndexes.Count > 0)
{
gpsIndex = (int)this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset);
gpsIndex = this.GetIndex(this.ifdIndexes, ExifTag.GPSIFDOffset);
}
uint ifdLength = 2 + this.GetLength(this.ifdIndexes) + 4;
@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
i = this.WriteData(startIndex, this.gpsIndexes, result, i);
}
WriteUInt16((ushort)0, result, i);
WriteUInt16(0, result, i);
return result;
}
@ -373,4 +373,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
return this.WriteValue(value.DataType, value.Value, destination, offset);
}
}
}
}

6
src/ImageSharp/Primitives/ColorMatrix.cs

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

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.
using System;
@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Processing
/// <summary>
/// Gets an approximated black and white filter
/// </summary>
public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix()
public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix
{
M11 = 1.5F,
M12 = 1.5F,

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

@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
Parallel.For(
0,
tileYStartPositions.Count,
new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism },
new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism },
index =>
{
int cdfX = 0;
@ -470,7 +470,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
Parallel.For(
0,
this.tileYStartPositions.Count,
new ParallelOptions() { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism },
new ParallelOptions { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism },
index =>
{
int cdfX = 0;

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

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

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

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

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using BenchmarkDotNet.Attributes;
@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
using (var memoryStream = new MemoryStream(this.jpegBytes))
{
var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder() { IgnoreMetadata = true });
var decoder = new JpegDecoderCore(Configuration.Default, new Formats.Jpeg.JpegDecoder { IgnoreMetadata = true });
decoder.ParseStream(memoryStream);
decoder.Dispose();
}
@ -65,4 +65,4 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
// | 'System.Drawing FULL' | Core | Core | Jpg/b(...)f.jpg [28] | 17.68 ms | 2.711 ms | 0.1486 ms | 1.00 | 0.00 | 343.7500 | - | - | 757.04 KB |
// | JpegDecoderCore.ParseStream | Core | Core | Jpg/b(...)f.jpg [28] | 14.27 ms | 3.671 ms | 0.2012 ms | 0.81 | 0.00 | - | - | - | 11.76 KB |
}
}
}

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.
using System.Drawing;
@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
{
using (var memoryStream = new MemoryStream(this.jpegBytes))
{
using (var image = Image.Load<Rgba32>(memoryStream, new JpegDecoder() { IgnoreMetadata = true }))
using (var image = Image.Load<Rgba32>(memoryStream, new JpegDecoder { IgnoreMetadata = true }))
{
return new CoreSize(image.Width, image.Height);
}

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

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Benchmarks
public static Byte Create(byte[] data)
{
Byte result = default(Byte);
Byte result = default;
for (int i = 0; i < data.Length; i++)
{
result.Data[i] = data[i];
@ -113,9 +113,9 @@ namespace SixLabors.ImageSharp.Benchmarks
// The operation is defined as "RGBA -> YCbCr Transform a stream of bytes into a stream of floats"
// We need to benchmark the whole operation, to get true results, not missing any side effects!
private byte[] inputSourceRGB = null;
private byte[] inputSourceRGB;
private int[] inputSourceRGBAsInteger = null;
private int[] inputSourceRGBAsInteger;
[GlobalSetup]
public void Setup()
@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.Benchmarks
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output:
Result result = default(Result);
Result result = default;
float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr;
@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.Benchmarks
OnStackInputCache.Byte input = OnStackInputCache.Byte.Create(this.inputSourceRGB);
// On-stack output:
Result result = default(Result);
Result result = default;
float* yPtr = (float*)&result.Y;
float* cbPtr = (float*)&result.Cb;
float* crPtr = (float*)&result.Cr;

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

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

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

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General
private static readonly Vector4 C = new Vector4(5.6f);
private static readonly Vector4 D = new Vector4(7.8f);
private Random random = null;
private Random random;
private Vector4 parameter;
@ -58,4 +58,4 @@ namespace SixLabors.ImageSharp.Benchmarks.General
private float GetRandomFloat() => (float)this.random.NextDouble();
}
}
}

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

@ -16,7 +16,7 @@ namespace ImageSharp.Benchmarks.General.Vectorization
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());
@ -66,4 +66,4 @@ namespace ImageSharp.Benchmarks.General.Vectorization
}
}
}

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

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

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

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

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

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

8
tests/ImageSharp.Tests/FakeImageOperationsProvider.cs

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

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)
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);
// 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)
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);
// 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)
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);
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)
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.CompareToOriginal(provider, new MagickReferenceDecoder());
@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_8Bit<TPixel>(TestImageProvider<TPixel> provider)
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.CompareToOriginal(provider, new MagickReferenceDecoder());
@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_CanDecode_RunLengthEncoded_24Bit<TPixel>(TestImageProvider<TPixel> provider)
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);

2
tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
[Fact]
public void CloneIsDeep()
{
var meta = new BmpMetadata() { BitsPerPixel = BmpBitsPerPixel.Pixel24 };
var meta = new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Pixel24 };
var clone = (BmpMetadata)meta.DeepClone();
clone.BitsPerPixel = BmpBitsPerPixel.Pixel32;

6
tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests
using (Image<TPixel> image = provider.GetImage())
{
image.DebugSave(provider, new PngEncoder() { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName);
image.DebugSave(provider, new PngEncoder { ColorType = PngColorType.Palette, Quantizer = quantizer }, testOutputDetails: quantizerName);
}
provider.Configuration.MemoryAllocator.ReleaseRetainedResources();
@ -201,4 +201,4 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
}
}

4
tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
{
using (Image<TPixel> image = provider.GetImage())
{
var encoder = new GifEncoder()
var encoder = new GifEncoder
{
// Use the palette quantizer without dithering to ensure results
// are consistent
@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
GifMetadata metaData = image.Metadata.GetFormatMetadata(GifFormat.Instance);
GifFrameMetadata frameMetaData = image.Frames.RootFrame.Metadata.GetFormatMetadata(GifFormat.Instance);
GifColorTableMode colorMode = metaData.ColorTableMode;
var encoder = new GifEncoder()
var encoder = new GifEncoder
{
ColorTableMode = colorMode,
Quantizer = new OctreeQuantizer(frameMetaData.ColorTableLength)

4
tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats.Gif;
@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
[Fact]
public void CloneIsDeep()
{
var meta = new GifFrameMetadata()
var meta = new GifFrameMetadata
{
FrameDelay = 1,
DisposalMethod = GifDisposalMethod.RestoreToBackground,

5
tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs

@ -27,13 +27,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
[Fact]
public void CloneIsDeep()
{
var meta = new GifMetadata()
var meta = new GifMetadata
{
RepeatCount = 1,
ColorTableMode = GifColorTableMode.Global,
GlobalColorTableLength = 2,
Comments = new List<string>() { "Foo" }
Comments = new List<string> { "Foo" }
};
var clone = (GifMetadata)meta.DeepClone();

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// Uncomment this to turn unit tests into benchmarks:
@ -426,7 +426,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
for (int i = 0; i < Block8x8F.Size; i++)
{
Assert.Equal((float)data[i], dest[i]);
Assert.Equal(data[i], dest[i]);
}
}
@ -441,14 +441,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
short[] data = Create8x8ShortData();
var source = new Block8x8(data);
Block8x8F dest = default;
dest.LoadFromInt16ExtendedAvx2(ref source);
for (int i = 0; i < Block8x8F.Size; i++)
{
Assert.Equal((float)data[i], dest[i]);
Assert.Equal(data[i], dest[i]);
}
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs

@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact]
public unsafe void Indexer_GetScalarAt_SetScalarAt()
{
int sum = 0;
int sum;
var block = default(Block8x8);
for (int i = 0; i < Block8x8.Size; i++)
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
for (int i = 0; i < Block8x8F.Size; i++)
{
Assert.Equal((float)data[i], dest[i]);
Assert.Equal(data[i], dest[i]);
}
}
@ -141,4 +141,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(15, d);
}
}
}
}

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

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact]
public void iDCT2D8x4_LeftPart()
{
float[] sourceArray = JpegFixture.Create8x8FloatData();
float[] sourceArray = Create8x8FloatData();
float[] expectedDestArray = new float[64];
ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray, expectedDestArray);
@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact]
public void iDCT2D8x4_RightPart()
{
float[] sourceArray = JpegFixture.Create8x8FloatData();
float[] sourceArray = Create8x8FloatData();
float[] expectedDestArray = new float[64];
ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D8x4_32f(sourceArray.AsSpan(4), expectedDestArray.AsSpan(4));
@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(3)]
public void LLM_TransformIDCT_CompareToNonOptimized(int seed)
{
float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed);
float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed);
var source = Block8x8F.Load(sourceArray);
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(3)]
public void LLM_TransformIDCT_CompareToAccurate(int seed)
{
float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed);
float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed);
var source = Block8x8F.Load(sourceArray);
@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)]
public void FDCT8x4_LeftPart(int seed)
{
Span<float> src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed);
Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed);
var srcBlock = new Block8x8F();
srcBlock.LoadFrom(src);
@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)]
public void FDCT8x4_RightPart(int seed)
{
Span<float> src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed);
Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed);
var srcBlock = new Block8x8F();
srcBlock.LoadFrom(src);
@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)]
public void TransformFDCT(int seed)
{
Span<float> src = JpegFixture.Create8x8RoundedRandomFloatData(-200, 200, seed);
Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed);
var srcBlock = new Block8x8F();
srcBlock.LoadFrom(src);
@ -177,4 +177,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
for (int j = 0; j < 10; j++)
{
var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), (byte)200, (byte)255);
var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), 200, 255);
var color = default(TPixel);
color.FromRgba32(rgba);
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgb24 | PixelTypes.Rgba32)]
public unsafe void LoadAndStretchCorners_WithOffset<TPixel>(TestImageProvider<TPixel> provider)
public void LoadAndStretchCorners_WithOffset<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> s = provider.GetImage())
@ -121,4 +121,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(expected77, block[7, 7]);
}
}
}
}

4
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs

@ -36,6 +36,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Theory]
[WithFileCollection(nameof(UnrecoverableTestJpegs), PixelTypes.Rgba32)]
public void UnrecoverableImagesShouldThrowCorrectError<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> => Assert.Throws<ImageFormatException>(() => provider.GetImage());
where TPixel : struct, IPixel<TPixel> => Assert.Throws<ImageFormatException>(provider.GetImage);
}
}
}

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs

@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(true)]
public void IgnoreMetaData_ControlsWhetherMetaDataIsParsed(bool ignoreMetaData)
{
var decoder = new JpegDecoder() { IgnoreMetadata = ignoreMetaData };
var decoder = new JpegDecoder { IgnoreMetadata = ignoreMetaData };
// Snake.jpg has both Exif and ICC profiles defined:
var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake);

6
tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
// There is no alpha in Jpeg!
image.Mutate(c => c.MakeOpaque());
var encoder = new JpegEncoder()
var encoder = new JpegEncoder
{
Subsample = subsample,
Quality = quality
@ -198,4 +198,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats.Jpeg;
@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact]
public void CloneIsDeep()
{
var meta = new JpegMetadata() { Quality = 50 };
var meta = new JpegMetadata { Quality = 50 };
var clone = (JpegMetadata)meta.DeepClone();
clone.Quality = 99;
@ -19,4 +19,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.False(meta.Quality.Equals(clone.Quality));
}
}
}
}

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

@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
this.Output.WriteLine(sb.ToString());
}
public static readonly TheoryData<string, int, object, object> ComponentVerificationData = new TheoryData<string, int, object, object>()
public static readonly TheoryData<string, int, object, object> ComponentVerificationData = new TheoryData<string, int, object, object>
{
{ TestImages.Jpeg.Baseline.Jpeg444, 3, new Size(1, 1), new Size(1, 1) },
{ TestImages.Jpeg.Baseline.Jpeg420Exif, 3, new Size(2, 2), new Size(1, 1) },

4
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)]
public void ForwardThenInverse(int seed)
{
float[] data = JpegFixture.Create8x8RandomFloatData(-1000, 1000, seed);
float[] data = Create8x8RandomFloatData(-1000, 1000, seed);
var b0 = default(Block8x8F);
b0.LoadFrom(data);
@ -36,4 +36,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
}
}
}
}

10
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2, 0)]
public void LLM_ForwardThenInverse(int seed, int startAt)
{
int[] data = JpegFixture.Create8x8RandomIntData(-1000, 1000, seed);
int[] data = Create8x8RandomIntData(-1000, 1000, seed);
float[] original = data.ConvertAllToFloat();
float[] src = data.ConvertAllToFloat();
float[] dest = new float[64];
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2, 200)]
public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range)
{
float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-range, range, seed);
float[] sourceArray = Create8x8RoundedRandomFloatData(-range, range, seed);
var source = Block8x8F.Load(sourceArray);
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)]
public void LLM_FDCT_IsEquivalentTo_AccurateImplementation(int seed)
{
float[] floatData = JpegFixture.Create8x8RandomFloatData(-1000, 1000);
float[] floatData = Create8x8RandomFloatData(-1000, 1000);
Block8x8F source = default;
source.LoadFrom(floatData);
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2, 200)]
public void GT_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range)
{
int[] intData = JpegFixture.Create8x8RandomIntData(-range, range, seed);
int[] intData = Create8x8RandomIntData(-range, range, seed);
float[] floatSrc = intData.ConvertAllToFloat();
ReferenceImplementations.AccurateDCT.TransformIDCTInplace(intData);
@ -120,4 +120,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs

@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2, 0)]
public void ForwardThenInverse(int seed, int startAt)
{
Span<int> original = JpegFixture.Create8x8RandomIntData(-200, 200, seed);
Span<int> original = Create8x8RandomIntData(-200, 200, seed);
Span<int> block = original.AddScalarToAllValues(128);
@ -80,11 +80,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
for (int i = startAt; i < 64; i++)
{
float expected = original[i];
float actual = (float)block[i];
float actual = block[i];
Assert.Equal(expected, actual, new ApproximateFloatComparer(3f));
}
}
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs

@ -52,8 +52,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
internal void MakeBlock(short[] data, int y, int x)
{
this.MinVal = Math.Min((short)this.MinVal, data.Min());
this.MaxVal = Math.Max((short)this.MaxVal, data.Max());
this.MinVal = Math.Min(this.MinVal, data.Min());
this.MaxVal = Math.Max(this.MaxVal, data.Max());
this.SpectralBlocks[x, y] = new Block8x8(data);
}
@ -189,4 +189,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
}
}
}
}
}

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

@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
TestFile testFile = TestFile.Create(inputFile);
string outDir = TestEnvironment.CreateOutputDirectory(".Temp", $"JpegCoeffs");
string outDir = TestEnvironment.CreateOutputDirectory(".Temp", "JpegCoeffs");
string fn = $"{Path.GetFileName(inputFile)}-{new Random().Next(1000)}.dctcoeffs";
string coeffFileFullPath = Path.Combine(outDir, fn);
@ -139,4 +139,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
}
}
}
}
}

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

@ -14,12 +14,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
/// /* reference idct taken from "ieeetest.c"
/// * Written by Tom Lane (tgl@cs.cmu.edu).
/// * Released to public domain 11/22/93.
/// */
/// */
/// </summary>
internal static class AccurateDCT
{
private static double[,] CosLut = InitCosLut();
public static Block8x8 TransformIDCT(ref Block8x8 block)
{
Block8x8F temp = block.AsFloatBlock();
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
for (v=0; v<8; v++) {
tmp2 = 0.0;
for (u=0; u<8; u++) {
tmp2 += (double) block[v * 8 + u] * CosLut[x, u];
tmp2 += block[v * 8 + u] * CosLut[x, u];
}
tmp += CosLut[y, v] * tmp2;
}
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
}
return res;
}
public static Block8x8F TransformFDCT(ref Block8x8F block)
{
int x, y, u, v;
@ -88,14 +88,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
tmp2 = 0.0;
for (x = 0; x < 8; x++)
{
tmp2 += (double)block[y * 8 + x] * CosLut[x,u];
tmp2 += block[y * 8 + x] * CosLut[x,u];
}
tmp += CosLut[y, v] * tmp2;
}
res[v * 8 + u] = (float) tmp;
}
}
return res;
}
@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
for (a = 0; a < 8; a++)
for (b = 0; b < 8; b++)
{
tmp = Math.Cos((double)((a + a + 1) * b) * (3.14159265358979323846 / 16.0));
tmp = Math.Cos((a + a + 1) * b * (3.14159265358979323846 / 16.0));
if (b == 0)
{
tmp /= Math.Sqrt(2.0);
@ -119,4 +119,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
}
}
}
}
}

10
tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs

@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float[] r = new float[8];
for (int i = 0; i < 8; i++)
{
r[i] = (float)(Cos((double)i / 16.0 * M_PI) * M_SQRT2);
r[i] = (float)(Cos(i / 16.0 * M_PI) * M_SQRT2);
output?.WriteLine($"float r{i} = {r[i]:R}f;");
}
return r;
@ -267,13 +267,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public static void fDCT8x8_llm_sse(Span<float> s, Span<float> d, Span<float> temp)
{
ReferenceImplementations.Transpose8x8(s, temp);
Transpose8x8(s, temp);
fDCT2D8x4_32f(temp, d);
fDCT2D8x4_32f(temp.Slice(4), d.Slice(4));
ReferenceImplementations.Transpose8x8(d, temp);
Transpose8x8(d, temp);
fDCT2D8x4_32f(temp, d);
@ -535,14 +535,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
fDCT1Dllm_32f(sWorker.Slice(j * 8), temp.Slice(j * 8));
}
ReferenceImplementations.Transpose8x8(temp, d);
Transpose8x8(temp, d);
for (int j = 0; j < 8; j++)
{
fDCT1Dllm_32f(d.Slice(j * 8), temp.Slice(j * 8));
}
ReferenceImplementations.Transpose8x8(temp, d);
Transpose8x8(temp, d);
if (downscaleBy8)
{

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float[] result = new float[src.Length];
for (int i = 0; i < src.Length; i++)
{
result[i] = (float)src[i];
result[i] = src[i];
}
return result;
@ -118,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
return result;
}
}
}
}

10
tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs

@ -24,13 +24,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
[Fact]
public void CloneIsDeep()
{
var meta = new PngMetadata()
var meta = new PngMetadata
{
BitDepth = PngBitDepth.Bit16,
ColorType = PngColorType.GrayscaleWithAlpha,
InterlaceMethod = PngInterlaceMode.Adam7,
Gamma = 2,
TextData = new List<PngTextData>() { new PngTextData("name", "value", "foo", "bar") }
TextData = new List<PngTextData> { new PngTextData("name", "value", "foo", "bar") }
};
var clone = (PngMetadata)meta.DeepClone();
@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance);
inputMetadata.TextData.Add(expectedText);
inputMetadata.TextData.Add(expectedTextNoneLatin);
input.Save(memoryStream, new PngEncoder()
input.Save(memoryStream, new PngEncoder
{
TextCompressionThreshold = 50
});
@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
[Fact]
public void Decode_IgnoreMetadataIsFalse_TextChunkIsRead()
{
var options = new PngDecoder()
var options = new PngDecoder
{
IgnoreMetadata = false
};
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
[Fact]
public void Decode_IgnoreMetadataIsTrue_TextChunksAreIgnored()
{
var options = new PngDecoder()
var options = new PngDecoder
{
IgnoreMetadata = true
};

24
tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
public class ParallelHelperTests
{
private readonly ITestOutputHelper Output;
public ParallelHelperTests(ITestOutputHelper output)
{
this.Output = output;
@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
/// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength
/// </summary>
public static TheoryData<int, int, int, int, int> IterateRows_OverMinimumPixelsLimit_Data =
new TheoryData<int, int, int, int, int>()
new TheoryData<int, int, int, int, int>
{
{ 1, 0, 100, -1, 100 },
{ 2, 0, 9, 5, 4 },
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rectangle = new Rectangle(0, minY, 10, maxY - minY);
int actualNumberOfSteps = 0;
ParallelHelper.IterateRows(
rectangle,
parallelSettings,
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
actualData[y] = y;
}
});
Assert.Equal(expectedData, actualData);
}
@ -144,7 +144,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
int step = rows.Max - rows.Min;
int expected = rows.Max < maxY ? expectedStepLength : expectedLastStepLength;
Interlocked.Increment(ref actualNumberOfSteps);
Assert.Equal(expected, step);
});
@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
}
public static TheoryData<int, int, int, int, int, int, int> IterateRows_WithEffectiveMinimumPixelsLimit_Data =
new TheoryData<int, int, int, int, int, int, int>()
new TheoryData<int, int, int, int, int, int, int>
{
{ 2, 200, 50, 2, 1, -1, 2 },
{ 2, 200, 200, 1, 1, -1, 1 },
@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
Configuration.Default.MemoryAllocator);
var rectangle = new Rectangle(0, 0, width, height);
int actualNumberOfSteps = 0;
ParallelHelper.IterateRowsWithTempBuffer(
rectangle,
@ -277,7 +277,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
}
public static readonly TheoryData<int, int, int, int, int, int, int> IterateRectangularBuffer_Data =
new TheoryData<int, int, int, int, int, int, int>()
new TheoryData<int, int, int, int, int, int, int>
{
{ 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox
{ 2, 582, 453, 10, 10, 291, 226 },
@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
using (Buffer2D<Point> actual = memoryAllocator.Allocate2D<Point>(bufferWidth, bufferHeight, AllocationOptions.Clean))
{
var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight);
void FillRow(int y, Buffer2D<Point> buffer)
{
for (int x = rect.Left; x < rect.Right; x++)
@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rect = new Rectangle(0, 0, width, height);
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(
() => ParallelHelper.IterateRows(rect, parallelSettings, (rows) => { }));
() => ParallelHelper.IterateRows(rect, parallelSettings, rows => { }));
Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message);
}
@ -370,4 +370,4 @@ namespace SixLabors.ImageSharp.Tests.Helpers
Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message);
}
}
}
}

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

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests
this.Image.GetConfiguration(),
this.Image.Width,
this.Image.Height,
(Bgra32)Color.Blue))
Color.Blue))
{
this.Collection.AddFrame(sourceImage.Frames.RootFrame);
}
@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests
this.Image.GetConfiguration(),
this.Image.Width,
this.Image.Height,
(Bgra32)Color.Blue))
Color.Blue))
{
this.Collection.InsertFrame(0, sourceImage.Frames.RootFrame);
}
@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() =>
{
this.Collection.AddFrame((ImageFrame<Rgba32>)null);
this.Collection.AddFrame(null);
});
Assert.StartsWith("Value cannot be null.", ex.Message);

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests
this.encoderNotInFormat = new Mock<IImageEncoder>();
this.fileSystem = new Mock<IFileSystem>();
var config = new Configuration()
var config = new Configuration
{
FileSystem = this.fileSystem.Object
};

2
tests/ImageSharp.Tests/ImageOperationTests.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests
Mock<IImageProcessor> processorMock = new Mock<IImageProcessor>();
this.processorDefinition = processorMock.Object;
this.image = new Image<Rgba32>(new Configuration()
this.image = new Image<Rgba32>(new Configuration
{
ImageOperationsProvider = this.provider
}, 1, 1);

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

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
ref T actual = ref MemoryMarshal.GetReference(span);
ref T expected = ref Unsafe.Add(ref buffer.GetReference(), bufferOffset);
Assert.True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position");
True(Unsafe.AreSame(ref expected, ref actual), "span does not point to the expected position");
}
}
@ -179,4 +179,4 @@ namespace SixLabors.ImageSharp.Tests.Memory
}
}
}
}
}

2
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests
Png
}
private static readonly Dictionary<ExifTag, object> TestProfileValues = new Dictionary<ExifTag, object>()
private static readonly Dictionary<ExifTag, object> TestProfileValues = new Dictionary<ExifTag, object>
{
{ ExifTag.Software, "Software" },
{ ExifTag.Copyright, "Copyright" },

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
{
IccWriter writer = CreateWriter();
IccProfile profile = new IccProfile()
IccProfile profile = new IccProfile
{
Header = IccTestDataProfiles.Header_Random_Write
};

4
tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
public static readonly TheoryData<byte, byte, byte> ColorData =
new TheoryData<byte, byte, byte>() { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
new TheoryData<byte, byte, byte> { { 1, 2, 3 }, { 4, 5, 6 }, { 0, 255, 42 } };
[Theory]
[MemberData(nameof(ColorData))]
@ -129,4 +129,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(255, bgr.B);
}
}
}
}

4
tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs

@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
public static readonly TheoryData<byte, byte, byte, byte> ColorData =
new TheoryData<byte, byte, byte, byte>()
new TheoryData<byte, byte, byte, byte>
{
{ 1, 2, 3, 4 }, { 4, 5, 6, 7 }, { 0, 255, 42, 0 }, { 1, 2, 3, 255 }
};
@ -141,4 +141,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(expected, bgra.PackedValue);
}
}
}
}

6
tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{
public class Gray8Tests
{
public static readonly TheoryData<byte> LuminanceData = new TheoryData<byte>()
public static readonly TheoryData<byte> LuminanceData = new TheoryData<byte>
{
0,
1,
@ -279,4 +279,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
}
}
}
}

18
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
{
public class PorterDuffFunctionsTests
{
public static TheoryData<TestVector4, TestVector4, float, TestVector4> NormalBlendFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> NormalBlendFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) },
};
@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
Assert.Equal(expected, actual);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> MultiplyFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> MultiplyFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) },
{
@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> AddFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> AddFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) },
{
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> SubtractFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> SubtractFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(0,0,0,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1, 1f) },
{
@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> ScreenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> ScreenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1, 1f) },
{
@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> DarkenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> DarkenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(.6f,.6f,.6f, 1f) },
{
@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> LightenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> LightenFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1,1f) },
{
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> OverlayFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> OverlayFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(1,1,1,1f) },
{
@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, actual, 5);
}
public static TheoryData<TestVector4, TestVector4, float, TestVector4> HardLightFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4>() {
public static TheoryData<TestVector4, TestVector4, float, TestVector4> HardLightFunctionData = new TheoryData<TestVector4, TestVector4, float, TestVector4> {
{ new TestVector4(1,1,1,1), new TestVector4(1,1,1,1), 1, new TestVector4(1,1,1,1) },
{ new TestVector4(1,1,1,1), new TestVector4(0,0,0,.8f), .5f, new TestVector4(0.6f,0.6f,0.6f,1f) },
{

20
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
return new Span<T>(new[] { value });
}
public static TheoryData<object, object, float, object> NormalBlendFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> NormalBlendFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(0.6f, 0.6f, 0.6f, 1) },
};
@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
public void NormalBlendFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected)
where TPixel : struct, IPixel<TPixel>
{
TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)(TPixel)back, source, amount);
TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)back, source, amount);
VectorAssert.Equal(expected, actual, 2);
}
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> MultiplyFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> MultiplyFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(0.6f, 0.6f, 0.6f, 1) },
{
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> AddFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> AddFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(1f, 1f, 1f, 1f) },
{
@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> SubtractFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> SubtractFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(0,0,0,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(1,1,1, 1f) },
{
@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> ScreenFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> ScreenFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(1,1,1, 1f) },
{
@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> DarkenFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> DarkenFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(.6f,.6f,.6f, 1f) },
{
@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> LightenFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> LightenFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(1,1,1,1f) },
{
@ -286,7 +286,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> OverlayFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> OverlayFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(1,1,1,1f) },
{
@ -325,7 +325,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
VectorAssert.Equal(expected, dest[0], 2);
}
public static TheoryData<object, object, float, object> HardLightFunctionData = new TheoryData<object, object, float, object>() {
public static TheoryData<object, object, float, object> HardLightFunctionData = new TheoryData<object, object, float, object> {
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(1,1,1,1), 1, new TestPixel<Rgba32>(1,1,1,1) },
{ new TestPixel<Rgba32>(1,1,1,1), new TestPixel<Rgba32>(0,0,0,.8f), .5f, new TestPixel<Rgba32>(0.6f,0.6f,0.6f,1f) },
{

8
tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
{
public class PixelBlenderTests
{
public static TheoryData<object, Type, PixelColorBlendingMode> BlenderMappings = new TheoryData<object, Type, PixelColorBlendingMode>()
public static TheoryData<object, Type, PixelColorBlendingMode> BlenderMappings = new TheoryData<object, Type, PixelColorBlendingMode>
{
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.NormalSrcOver), PixelColorBlendingMode.Normal },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.ScreenSrcOver), PixelColorBlendingMode.Screen },
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.IsType(type, blender);
}
public static TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32> ColorBlendingExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32>()
public static TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32> ColorBlendingExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelColorBlendingMode, Rgba32>
{
{ Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Normal, Rgba32.MidnightBlue },
{ Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) },
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(actualResult.ToVector4(), expectedResult.ToVector4());
}
public static TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32> AlphaCompositionExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32>()
public static TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32> AlphaCompositionExpectedResults = new TheoryData<Rgba32, Rgba32, float, PixelAlphaCompositionMode, Rgba32>
{
{ Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) },
{ Rgba32.MistyRose, Rgba32.MidnightBlue, 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) },

4
tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class Rgb24Tests
{
public static readonly TheoryData<byte, byte, byte> ColorData =
new TheoryData<byte, byte, byte>()
new TheoryData<byte, byte, byte>
{
{ 1, 2, 3 },
{ 4, 5, 6 },
@ -130,4 +130,4 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(255, rgb.B);
}
}
}
}

6
tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
public static void Equal(ReadOnlySpan<Color> a, ReadOnlySpan<Color> b)
{
Xunit.Assert.True(a.SequenceEqual(b));
True(a.SequenceEqual(b));
}
}
@ -112,4 +112,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
Assert.Equal(this.TestPalette, p.Palette);
}
}
}
}

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
};
// Act
image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions()
image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions
{
LuminanceLevels = luminanceLevels
}));
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
{
using (Image<TPixel> image = provider.GetImage())
{
var options = new HistogramEqualizationOptions()
var options = new HistogramEqualizationOptions
{
Method = HistogramEqualizationMethod.AdaptiveSlidingWindow,
LuminanceLevels = 256,
@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
{
using (Image<TPixel> image = provider.GetImage())
{
var options = new HistogramEqualizationOptions()
var options = new HistogramEqualizationOptions
{
Method = HistogramEqualizationMethod.AdaptiveTileInterpolation,
LuminanceLevels = 256,

10
tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays
public static string[] InputImages = { TestImages.Png.Ducky, TestImages.Png.Splash };
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f);
[Theory]
[WithFileCollection(nameof(InputImages), nameof(ColorNames), PixelTypes.Rgba32)]
public void FullImage_ApplyColor<TPixel>(TestImageProvider<TPixel> provider, string colorName)
@ -52,13 +52,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays
where TPixel : struct, IPixel<TPixel>
{
provider.Utility.TestGroupName = this.GetType().Name;
provider.RunRectangleConstrainedValidatingProcessorTest((x, rect) => this.Apply(x, rect));
provider.RunRectangleConstrainedValidatingProcessorTest(this.Apply);
}
protected abstract void Apply(IImageProcessingContext ctx, Color color);
protected abstract void Apply(IImageProcessingContext ctx, float radiusX, float radiusY);
protected abstract void Apply(IImageProcessingContext ctx, Rectangle rect);
}
}
}

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -23,10 +23,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ ExifDataType.SignedByte, new byte[] { 2 } },
{ ExifDataType.SignedShort, BitConverter.GetBytes((short) 3) },
{ ExifDataType.Long, BitConverter.GetBytes((uint) 4) },
{ ExifDataType.SignedLong, BitConverter.GetBytes((int) 5) }
{ ExifDataType.SignedLong, BitConverter.GetBytes(5) }
};
public static readonly TheoryData<ushort> ExifOrientationValues = new TheoryData<ushort>()
public static readonly TheoryData<ushort> ExifOrientationValues = new TheoryData<ushort>
{
0,
1,
@ -87,4 +87,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
}
}
}
}
}

4
tests/ImageSharp.Tests/TestFont.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests
AddFormatsDirectoryFromTestAssemblyPath(directories);
string directory = directories.FirstOrDefault(x => Directory.Exists(x));
string directory = directories.FirstOrDefault(Directory.Exists);
if (directory != null)
{

4
tests/ImageSharp.Tests/TestUtilities/ImageComparison/Exceptions/ImageDimensionsMismatchException.cs

@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
public class ImageDimensionsMismatchException : ImagesSimilarityException
{
public ImageDimensionsMismatchException(Size expectedSize, Size actualSize)
: base((string)$"The image dimensions {actualSize} do not match the expected {expectedSize}!")
: base($"The image dimensions {actualSize} do not match the expected {expectedSize}!")
{
this.ExpectedSize = expectedSize;
this.ActualSize = actualSize;
@ -17,4 +17,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison
public Size ExpectedSize { get; }
public Size ActualSize { get; }
}
}
}

12
tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
public void BenchmarkMagickPngDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Png");
this.BenchmarkDecoderImpl(PngBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Png");
}
[Theory(Skip = SkipBenchmarks)]
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
public void BenchmarkSystemDrawingPngDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Png");
this.BenchmarkDecoderImpl(PngBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Png");
}
[Theory(Skip = SkipBenchmarks)]
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
public void BenchmarkMagickBmpDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), $@"Magick Decode Bmp");
this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new MagickReferenceDecoder(), "Magick Decode Bmp");
}
[Theory(Skip = SkipBenchmarks)]
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
public void BenchmarkSystemDrawingBmpDecoder<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), $@"System.Drawing Decode Bmp");
this.BenchmarkDecoderImpl(BmpBenchmarkFiles, new SystemDrawingReferenceDecoder(), "System.Drawing Decode Bmp");
}
private void BenchmarkDecoderImpl(IEnumerable<string> testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount)
@ -93,4 +93,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
info);
}
}
}
}

4
tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs

@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
sourceImage.Mutate(c => c.MakeOpaque());
}
var encoder = new PngEncoder() { ColorType = pngColorType };
var encoder = new PngEncoder { ColorType = pngColorType };
return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder);
}
}
@ -133,4 +133,4 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
}
}
}
}
}

16
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

@ -19,13 +19,13 @@ namespace SixLabors.ImageSharp.Tests
{
public class TestImageProviderTests
{
public static readonly TheoryData<object> BasicData = new TheoryData<object>()
public static readonly TheoryData<object> BasicData = new TheoryData<object>
{
TestImageProvider<Rgba32>.Blank(10, 20),
TestImageProvider<HalfVector4>.Blank(10, 20),
};
public static readonly TheoryData<object> FileData = new TheoryData<object>()
public static readonly TheoryData<object> FileData = new TheoryData<object>
{
TestImageProvider<Rgba32>.File(TestImages.Bmp.Car),
TestImageProvider<HalfVector4>.File(TestImages.Bmp.F)
@ -114,10 +114,10 @@ namespace SixLabors.ImageSharp.Tests
string testName = nameof(this
.GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual);
var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 42 };
var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 42 };
decoder1.InitCaller(testName);
var decoder2 = new TestDecoderWithParameters() { Param1 = "LoL", Param2 = 42 };
var decoder2 = new TestDecoderWithParameters { Param1 = "LoL", Param2 = 42 };
decoder2.InitCaller(testName);
provider.GetImage(decoder1);
@ -148,10 +148,10 @@ namespace SixLabors.ImageSharp.Tests
string testName = nameof(this
.GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual);
var decoder1 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 };
var decoder1 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 };
decoder1.InitCaller(testName);
var decoder2 = new TestDecoderWithParameters() { Param1 = "Lol", Param2 = 666 };
var decoder2 = new TestDecoderWithParameters { Param1 = "Lol", Param2 = 666 };
decoder2.InitCaller(testName);
provider.GetImage(decoder1);
@ -354,7 +354,7 @@ namespace SixLabors.ImageSharp.Tests
private static readonly object Monitor = new object();
private string callerName = null;
private string callerName;
public static void DoTestThreadSafe(Action action)
{
@ -389,7 +389,7 @@ namespace SixLabors.ImageSharp.Tests
private static readonly object Monitor = new object();
private string callerName = null;
private string callerName;
public string Param1 { get; set; }

Loading…
Cancel
Save