Browse Source

remove unused variables and methods (#963)

* remove unused variables and methods

* remove some redundant variables

* remove some redundant variables

* redundant variables

* Update DrawTextOnImageTests.cs

* Minor optimizations

* cleanup
pull/973/head
Simon Cropp 7 years ago
committed by James Jackson-South
parent
commit
fb033fe0b6
  1. 38
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  2. 24
      src/ImageSharp/Common/Helpers/Guard.cs
  3. 10
      src/ImageSharp/Formats/Png/Filters/SubFilter.cs
  4. 12
      src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
  5. 9
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
  6. 13
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs
  7. 1
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs
  8. 5
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs
  9. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs
  10. 8
      src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs
  11. 5
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  12. 10
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs
  13. 2
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  14. 3
      src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs
  15. 2
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs
  16. 2
      tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs
  17. 10
      tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs
  18. 10
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  19. 10
      tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs
  20. 10
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  21. 16
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  22. 12
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  23. 4
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
  24. 2
      tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
  25. 19
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  26. 4
      tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs
  27. 4
      tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs
  28. 22
      tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_PassLocalConfiguration.cs
  29. 6
      tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs
  30. 7
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs
  31. 4
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs
  32. 6
      tests/ImageSharp.Tests/Image/ImageTests.Save.cs
  33. 4
      tests/ImageSharp.Tests/ImageOperationTests.cs
  34. 3
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  35. 4
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs
  36. 3
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  37. 3
      tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs
  38. 24
      tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs
  39. 8
      tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs
  40. 8
      tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs
  41. 8
      tests/ImageSharp.Tests/Processing/Filters/FilterTest.cs
  42. 6
      tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs
  43. 8
      tests/ImageSharp.Tests/Processing/Filters/InvertTest.cs
  44. 8
      tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.cs
  45. 8
      tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs
  46. 8
      tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs
  47. 8
      tests/ImageSharp.Tests/Processing/Filters/SepiaTest.cs
  48. 6
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs
  49. 7
      tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs
  50. 1
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
  51. 33
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

38
src/ImageSharp/Advanced/AdvancedImageExtensions.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;
@ -153,42 +153,6 @@ namespace SixLabors.ImageSharp.Advanced
internal static MemoryAllocator GetMemoryAllocator(this IConfigurable source)
=> GetConfiguration(source).MemoryAllocator;
/// <summary>
/// Gets the span to the backing buffer.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The span returned from Pixel source</returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.PixelBuffer.GetSpan();
/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span returned from Pixel source
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> GetSpan(source.PixelBuffer, row);
/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span returned from Pixel source.
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(Buffer2D<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> source.GetSpan().Slice(row * source.Width, source.Width);
/// <summary>
/// Gets the configuration.
/// </summary>

24
src/ImageSharp/Common/Helpers/Guard.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;
@ -51,28 +51,6 @@ namespace SixLabors.ImageSharp
}
}
/// <summary>
/// Ensures that the enumeration is not null or empty.
/// </summary>
/// <typeparam name="T">The type of objects in the <paramref name="value"/></typeparam>
/// <param name="value">The target enumeration, which should be checked against being null or empty.</param>
/// <param name="parameterName">Name of the parameter.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="value"/> is empty.</exception>
[MethodImpl(InliningOptions.ShortMethod)]
public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
{
if (value is null)
{
ThrowArgumentNullException(parameterName);
}
if (value.Count == 0)
{
ThrowArgumentException("Must not be empty.", parameterName);
}
}
/// <summary>
/// Ensures that the specified value is less than a maximum value.
/// </summary>

10
src/ImageSharp/Formats/Png/Filters/SubFilter.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -25,12 +25,8 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
// Sub(x) + Raw(x-bpp)
int x = 1;
for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
}
int x = bytesPerPixel + 1;
Unsafe.Add(ref scanBaseRef, x);
for (; x < scanline.Length; ++x)
{
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);

12
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.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;
@ -419,16 +419,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
: default;
}
private string ReadString(int length)
{
if (this.TryReadSpan(length, out ReadOnlySpan<byte> span) && span.Length != 0)
{
return this.ConvertToString(span);
}
return null;
}
private void GetThumbnail(uint offset)
{
var values = new List<ExifValue>();

9
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.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;
@ -526,9 +526,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{
int start = this.currentIndex - 8;
// TODO: Why are we storing variable
ushort inChannelCount = this.ReadUInt16();
ushort outChannelCount = this.ReadUInt16();
this.ReadUInt16();
this.ReadUInt16();
uint elementCount = this.ReadUInt32();
var positionTable = new IccPositionNumber[elementCount];
@ -902,4 +901,4 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description);
}
}
}
}

13
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -83,16 +83,5 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{
return ((value >> (7 - position)) & 1) == 1;
}
/// <summary>
/// Gets the bit value at a specified position
/// </summary>
/// <param name="value">The value from where the bit will be extracted</param>
/// <param name="position">Position of the bit. Zero based index from left to right.</param>
/// <returns>The bit value at specified position</returns>
private bool GetBit(ushort value, int position)
{
return ((value >> (15 - position)) & 1) == 1;
}
}
}

1
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs

@ -41,7 +41,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
public int WriteResponseCurve(IccResponseCurve value)
{
int count = this.WriteUInt32((uint)value.CurveType);
int channels = value.XyzValues.Length;
foreach (IccResponseNumber[] responseArray in value.ResponseArrays)
{

5
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -37,9 +37,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
int minor = value.Minor.Clamp(0, 15);
int bugfix = value.Patch.Clamp(0, 15);
// TODO: This is not used?
byte mb = (byte)((minor << 4) | bugfix);
int version = (major << 24) | (minor << 20) | (bugfix << 16);
return this.WriteInt32(version);
}

3
src/ImageSharp/PixelFormats/PixelImplementations/Gray16.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;
@ -15,7 +15,6 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial struct Gray16 : IPixel<Gray16>, IPackedVector<ushort>
{
private const float Max = ushort.MaxValue;
private const float Average = 1 / 3F;
/// <summary>
/// Initializes a new instance of the <see cref="Gray16"/> struct.

8
src/ImageSharp/PixelFormats/PixelImplementations/Gray8.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;
@ -16,12 +16,6 @@ namespace SixLabors.ImageSharp.PixelFormats
{
private static readonly Vector4 MaxBytes = new Vector4(255F);
private static readonly Vector4 Half = new Vector4(0.5F);
private const float Average = 1 / 3F;
private static readonly Vector4 Min = new Vector4(0, 0, 0, 1f);
private static readonly Vector4 Max = Vector4.One;
private static readonly Vector4 Accumulator = new Vector4(255f * Average, 255f * Average, 255f * Average, 0.5f);
/// <summary>
/// Initializes a new instance of the <see cref="Gray8"/> struct.

5
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.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;
@ -193,11 +193,10 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
public override string ToString()
{
var vector = this.ToVector4();
return FormattableString.Invariant($"RgbaVector({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##}, {this.A:#0.##})");
}
/// <inheritdoc/>
public override int GetHashCode() => HashCode.Combine(this.R, this.G, this.B, this.A);
}
}
}

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

@ -51,10 +51,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
{
int sourceWidth = source.Width;
int sourceHeight = source.Height;
int numberOfPixels = sourceWidth * sourceHeight;
int tileWidth = (int)MathF.Ceiling(sourceWidth / (float)this.Tiles);
int tileHeight = (int)MathF.Ceiling(sourceHeight / (float)this.Tiles);
int pixelsInTile = tileWidth * tileHeight;
int tileCount = this.Tiles;
int halfTileWidth = tileWidth / 2;
int halfTileHeight = tileHeight / 2;
int luminanceLevels = this.LuminanceLevels;
@ -103,8 +102,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
float luminanceEqualized = InterpolateBetweenFourTiles(
pixel,
cdfData,
this.Tiles,
this.Tiles,
tileCount,
tileCount,
tileX,
tileY,
cdfX,
@ -467,7 +466,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
int tileWidth = this.tileWidth;
int tileHeight = this.tileHeight;
int luminanceLevels = this.luminanceLevels;
MemoryAllocator memoryAllocator = this.memoryAllocator;
Parallel.For(
0,
@ -543,4 +541,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
}
}
}
}
}

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

@ -49,8 +49,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
int numberOfPixels = source.Width * source.Height;
Span<TPixel> pixels = source.GetPixelSpan();
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
int tileWidth = source.Width / this.Tiles;

3
src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs

@ -42,7 +42,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
{
MemoryAllocator memoryAllocator = configuration.MemoryAllocator;
int numberOfPixels = source.Width * source.Height;
Span<TPixel> pixels = source.GetPixelSpan();
var workingRect = new Rectangle(0, 0, source.Width, source.Height);
using (IMemoryOwner<int> histogramBuffer = memoryAllocator.Allocate<int>(this.LuminanceLevels, AllocationOptions.Clean))
@ -104,4 +103,4 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
}
}
}
}
}

2
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

@ -156,8 +156,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
return;
}
int sourceHeight = source.Height;
PixelConversionModifiers conversionModifiers =
PixelConversionModifiers.Premultiply.ApplyCompanding(this.Compand);

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

@ -94,8 +94,6 @@ namespace SixLabors.ImageSharp.Benchmarks.General.Vectorization
int n = Count / Vector<float>.Count;
ref Vector<float> bf = ref Unsafe.As<float, Vector<float>>(ref this.data[0]);
ref Vector<int> bu = ref Unsafe.As<Vector<float>, Vector<int>>(ref bf);
var scale = new Vector<float>(1f / 255f);
for (int i = 0; i < n; i++)

10
tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.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;
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
// path is converted to a polygon before filling
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);
Assert.Equal(this.pen.StrokeFill, processor.Brush);
}
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Assert.Equal(this.noneDefault, processor.Options);
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);
Assert.Equal(this.pen.StrokeFill, processor.Brush);
}
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Assert.Equal(this.noneDefault, processor.Options);
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
Assert.IsType<ComplexPolygon>(region.Shape);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);

10
tests/ImageSharp.Tests/Drawing/Paths/FillPath.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;
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
// path is converted to a polygon before filling
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);

10
tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.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;
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
// path is converted to a polygon before filling
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);

10
tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.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;
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.Equal(this.brush, processor.Brush);
}
@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);
@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color);

16
tests/ImageSharp.Tests/Drawing/Text/DrawText.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;
@ -14,14 +14,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
public class DrawText : BaseImageOperationsExtensionTest
{
Rgba32 color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
IPath path = new SixLabors.Shapes.Path(
new LinearLineSegment(
new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), }));
private readonly FontCollection FontCollection;
private readonly Font Font;
@ -103,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
Pens.Dash(Color.Red, 1),
Vector2.Zero);
var processor = this.Verify<DrawTextProcessor>(0);
this.Verify<DrawTextProcessor>(0);
}
[Fact]
@ -111,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero);
var processor = this.Verify<DrawTextProcessor>(0);
this.Verify<DrawTextProcessor>(0);
}
[Fact]
@ -119,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
var processor = this.Verify<DrawTextProcessor>(0);
this.Verify<DrawTextProcessor>(0);
}
[Fact]

12
tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.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;
@ -41,21 +41,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
Font font = CreateFont("OpenSans-Regular.ttf", 36);
Color color = Color.Black;
float padding = 5;
var text = "A short piece of text";
using (var img = provider.GetImage())
{
float targetWidth = img.Width - (padding * 2);
float targetHeight = img.Height - (padding * 2);
// measure the text size
SizeF size = TextMeasurer.Measure(text, new RendererOptions(font));
//find out how much we need to scale the text to fill the space (up or down)
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 center = new PointF(img.Width / 2, img.Height / 2);
@ -64,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
img.Mutate(i => i.DrawText(textGraphicOptions, text, scaledFont, color, center));
}
}
@ -241,6 +237,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
return font;
}
}
}

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

@ -346,7 +346,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_ThrowsImageFormatException_OnInvalidPaletteSize<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
Assert.Throws<ImageFormatException>( () => { using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) { } });
Assert.Throws<ImageFormatException>( () => { using (provider.GetImage(new BmpDecoder())) { } });
}
[Theory]
@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
public void BmpDecoder_ThrowsNotSupportedException_OnUnsupportedBitmaps<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
Assert.Throws<NotSupportedException>(() => { using (Image<TPixel> image = provider.GetImage(new BmpDecoder())) { } });
Assert.Throws<NotSupportedException>(() => { using (provider.GetImage(new BmpDecoder())) { } });
}
[Theory]

2
tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
public void CanDecodeIntermingledImages()
{
using (var kumin1 = Image.Load(TestFile.Create(TestImages.Gif.Kumin).Bytes))
using (var icon = Image.Load(TestFile.Create(TestImages.Png.Icon).Bytes))
using (Image.Load(TestFile.Create(TestImages.Png.Icon).Bytes))
using (var kumin2 = Image.Load(TestFile.Create(TestImages.Gif.Kumin).Bytes))
{
for (int i = 0; i < kumin1.Frames.Count; i++)

19
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -107,25 +107,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
provider.Configuration.MemoryAllocator.ReleaseRetainedResources();
}
private string GetDifferenceInPercentageString<TPixel>(Image<TPixel> image, TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
var reportingComparer = ImageComparer.Tolerant(0, 0);
ImageSimilarityReport report = image.GetReferenceOutputSimilarityReports(
provider,
reportingComparer,
appendPixelTypeToFileName: false
).SingleOrDefault();
if (report?.TotalNormalizedDifference != null)
{
return report.DifferencePercentageString;
}
return "0%";
}
// DEBUG ONLY!
// The PDF.js output should be saved by "tests\ImageSharp.Tests\Formats\Jpg\pdfjs\jpeg-converter.htm"
// into "\tests\Images\ActualOutput\JpegDecoderTests\"

4
tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs

@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests
ArgumentException ex = Assert.Throws<ArgumentException>(
() =>
{
var collection = new ImageFrameCollection<Rgba32>(
new ImageFrameCollection<Rgba32>(
this.Image,
new[]
{
@ -274,7 +274,6 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AddFrame_clones_sourceFrame()
{
var pixelData = this.Image.Frames.RootFrame.GetPixelSpan().ToArray();
var otherFrame = new ImageFrame<Rgba32>(Configuration.Default, 10, 10);
var addedFrame = this.Image.Frames.AddFrame(otherFrame);
addedFrame.ComparePixelBufferTo(otherFrame.GetPixelSpan());
@ -284,7 +283,6 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void InsertFrame_clones_sourceFrame()
{
var pixelData = this.Image.Frames.RootFrame.GetPixelSpan().ToArray();
var otherFrame = new ImageFrame<Rgba32>(Configuration.Default, 10, 10);
var addedFrame = this.Image.Frames.InsertFrame(0, otherFrame);
addedFrame.ComparePixelBufferTo(otherFrame.GetPixelSpan());

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -25,8 +25,6 @@ namespace SixLabors.ImageSharp.Tests
private byte[] ByteArray => this.DataStream.ToArray();
private ReadOnlySpan<byte> ByteSpan => this.ByteArray.AsSpan();
private IImageFormat LocalImageFormat => this.localImageFormatMock.Object;
private static readonly IImageFormat ExpectedGlobalFormat =

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

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Path_Agnostic()
{
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Path_Decoder_Specific()
{
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, this.DataStream));
}
[Fact]
public void Configuration_Path_Decoder_Agnostic()
{
@ -61,10 +61,10 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Path_OutFormat_Agnostic()
{
@ -72,14 +72,14 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
}
[Fact]
public void WhenFileNotFound_Throws()
{
System.IO.FileNotFoundException ex = Assert.Throws<System.IO.FileNotFoundException>(
Assert.Throws<System.IO.FileNotFoundException>(
() =>
{
Image.Load<Rgba32>(this.TopLevelConfiguration, Guid.NewGuid().ToString());
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void WhenPathIsNull_Throws()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
Assert.Throws<ArgumentNullException>(
() =>
{
Image.Load<Rgba32>(this.TopLevelConfiguration,(string)null);
@ -97,4 +97,4 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
}
}

6
tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs

@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void WhenFileNotFound_Throws()
{
System.IO.FileNotFoundException ex = Assert.Throws<System.IO.FileNotFoundException>(
Assert.Throws<System.IO.FileNotFoundException>(
() =>
{
Image.Load<Rgba32>(Guid.NewGuid().ToString());
@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void WhenPathIsNull_Throws()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
Assert.Throws<ArgumentNullException>(
() =>
{
Image.Load<Rgba32>((string)null);
@ -100,4 +100,4 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
}
}

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

@ -18,11 +18,6 @@ namespace SixLabors.ImageSharp.Tests
private ReadOnlySpan<byte> ByteSpan => this.ByteArray.AsSpan();
private byte[] ActualImageBytes => TestFile.Create(TestImages.Bmp.F).Bytes;
private ReadOnlySpan<byte> ActualImageSpan => this.ActualImageBytes.AsSpan();
[Theory]
[InlineData(false)]
[InlineData(true)]
@ -116,4 +111,4 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
}
}

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

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests
{
Assert.Throws<UnknownImageFormatException>(() =>
{
using (var img = Image.Load(Configuration.Default, this.Stream, out IImageFormat format))
using (Image.Load(Configuration.Default, this.Stream, out IImageFormat format))
{
}
});
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests
{
Assert.Throws<UnknownImageFormatException>(() =>
{
using (var img = Image.Load<Rgba32>(Configuration.Default, this.Stream, out IImageFormat format))
using (Image.Load<Rgba32>(Configuration.Default, this.Stream, out IImageFormat format))
{
}
});

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

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests
image.Save(file);
}
using (var img = Image.Load(file, out IImageFormat mime))
using (Image.Load(file, out IImageFormat mime))
{
Assert.Equal("image/png", mime.DefaultMimeType);
}
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "UnknownExtensionsEncoding_Throws.tmp");
NotSupportedException ex = Assert.Throws<NotSupportedException>(
Assert.Throws<NotSupportedException>(
() =>
{
using (var image = new Image<Rgba32>(10, 10))
@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests
image.Save(file, new PngEncoder());
}
using (var img = Image.Load(file, out var mime))
using (Image.Load(file, out var mime))
{
Assert.Equal("image/png", mime.DefaultMimeType);
}

4
tests/ImageSharp.Tests/ImageOperationTests.cs

@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void CloneCallsImageOperationsProvider_Func_NotOnOriginal()
{
Image<Rgba32> returned = this.image.Clone(x => x.ApplyProcessor(this.processorDefinition));
this.image.Clone(x => x.ApplyProcessor(this.processorDefinition));
Assert.False(this.provider.HasCreated(this.image));
Assert.DoesNotContain(
this.processorDefinition,
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void CloneCallsImageOperationsProvider_ListOfProcessors_NotOnOriginal()
{
Image<Rgba32> returned = this.image.Clone(this.processorDefinition);
this.image.Clone(this.processorDefinition);
Assert.False(this.provider.HasCreated(this.image));
Assert.DoesNotContain(
this.processorDefinition,

3
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.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;
@ -373,7 +373,6 @@ namespace SixLabors.ImageSharp.Tests
public void ProfileToByteArray()
{
// arrange
byte[] exifBytesWithExifCode = ProfileResolver.ExifMarker.Concat(ExifConstants.LittleEndianByteOrderMarker).ToArray();
byte[] exifBytesWithoutExifCode = ExifConstants.LittleEndianByteOrderMarker;
ExifProfile expectedProfile = CreateExifProfile();
var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList();

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Icc
byte[] copy = new byte[data.Length];
Buffer.BlockCopy(data, 0, copy, 0, data.Length);
IccProfileId result = IccProfile.CalculateHash(data);
IccProfile.CalculateHash(data);
Assert.Equal(data, copy);
}

3
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.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;
@ -816,7 +816,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
for (int i = 0; i < count; i++)
{
int i2 = i * 2;
expected[i].FromGray16(source[i]);
}

3
tests/ImageSharp.Tests/PixelFormats/Short4Tests.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;
@ -61,7 +61,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
// act
var pixel = default(Short4);
pixel.FromScaledVector4(scaled);
ulong actual = pixel.PackedValue;
// assert
Assert.Equal((ulong)expected, pixel.PackedValue);

24
tests/ImageSharp.Tests/Primitives/DenseMatrixTests.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;
@ -19,37 +19,25 @@ namespace SixLabors.ImageSharp.Tests.Primitives
[Fact]
public void DenseMatrixThrowsOnNullInitializer()
{
Assert.Throws<ArgumentNullException>(() =>
{
var dense = new DenseMatrix<float>(null);
});
Assert.Throws<ArgumentNullException>(() => new DenseMatrix<float>(null));
}
[Fact]
public void DenseMatrixThrowsOnEmptyZeroWidth()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
var dense = new DenseMatrix<float>(0, 10);
});
Assert.Throws<ArgumentOutOfRangeException>(() => new DenseMatrix<float>(0, 10));
}
[Fact]
public void DenseMatrixThrowsOnEmptyZeroHeight()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
var dense = new DenseMatrix<float>(10, 0);
});
Assert.Throws<ArgumentOutOfRangeException>(() => new DenseMatrix<float>(10, 0));
}
[Fact]
public void DenseMatrixThrowsOnEmptyInitializer()
{
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
var dense = new DenseMatrix<float>(new float[0, 0]);
});
Assert.Throws<ArgumentOutOfRangeException>(() => new DenseMatrix<float>(new float[0, 0]));
}
[Fact]
@ -131,4 +119,4 @@ namespace SixLabors.ImageSharp.Tests.Primitives
Assert.Equal(3, transposed[2, 0]);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.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.Processing;
@ -13,14 +13,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
public void BlackWhite_CorrectProcessor()
{
this.operations.BlackWhite();
BlackWhiteProcessor p = this.Verify<BlackWhiteProcessor>();
this.Verify<BlackWhiteProcessor>();
}
[Fact]
public void BlackWhite_rect_CorrectProcessor()
{
this.operations.BlackWhite(this.rect);
BlackWhiteProcessor p = this.Verify<BlackWhiteProcessor>(this.rect);
this.Verify<BlackWhiteProcessor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.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;
@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
where T : IImageProcessor
{
this.operations.ColorBlindness(colorBlindness);
T p = this.Verify<T>();
this.Verify<T>();
}
[Theory]
[MemberData(nameof(TheoryData))]
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
where T : IImageProcessor
{
this.operations.ColorBlindness(colorBlindness, this.rect);
T p = this.Verify<T>(this.rect);
this.Verify<T>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/FilterTest.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 Xunit;
@ -14,14 +14,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
public void Filter_CorrectProcessor()
{
this.operations.Filter(KnownFilterMatrices.AchromatomalyFilter * KnownFilterMatrices.CreateHueFilter(90F));
FilterProcessor p = this.Verify<FilterProcessor>();
this.Verify<FilterProcessor>();
}
[Fact]
public void Filter_rect_CorrectProcessor()
{
this.operations.Filter(KnownFilterMatrices.AchromatomalyFilter * KnownFilterMatrices.CreateHueFilter(90F), this.rect);
FilterProcessor p = this.Verify<FilterProcessor>(this.rect);
this.Verify<FilterProcessor>(this.rect);
}
}
}
}

6
tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.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;
@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
where T : IImageProcessor
{
this.operations.Grayscale(mode);
var p = this.Verify<T>();
this.Verify<T>();
}
[Theory]
@ -43,4 +43,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
this.Verify<GrayscaleBt709Processor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/InvertTest.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.Processing;
@ -13,14 +13,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects
public void Invert_InvertProcessorDefaultsSet()
{
this.operations.Invert();
var processor = this.Verify<InvertProcessor>();
this.Verify<InvertProcessor>();
}
[Fact]
public void Pixelate_rect_PixelateProcessorDefaultsSet()
{
this.operations.Invert(this.rect);
var processor = this.Verify<InvertProcessor>(this.rect);
this.Verify<InvertProcessor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/KodachromeTest.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.Processing;
@ -13,14 +13,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
public void Kodachrome_amount_KodachromeProcessorDefaultsSet()
{
this.operations.Kodachrome();
var processor = this.Verify<KodachromeProcessor>();
this.Verify<KodachromeProcessor>();
}
[Fact]
public void Kodachrome_amount_rect_KodachromeProcessorDefaultsSet()
{
this.operations.Kodachrome(this.rect);
var processor = this.Verify<KodachromeProcessor>(this.rect);
this.Verify<KodachromeProcessor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/LomographTest.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 Xunit;
@ -14,14 +14,14 @@ namespace SixLabors.ImageSharp.Tests
public void Lomograph_amount_LomographProcessorDefaultsSet()
{
this.operations.Lomograph();
var processor = this.Verify<LomographProcessor>();
this.Verify<LomographProcessor>();
}
[Fact]
public void Lomograph_amount_rect_LomographProcessorDefaultsSet()
{
this.operations.Lomograph(this.rect);
var processor = this.Verify<LomographProcessor>(this.rect);
this.Verify<LomographProcessor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.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.Processing;
@ -14,14 +14,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
public void Polaroid_amount_PolaroidProcessorDefaultsSet()
{
this.operations.Polaroid();
var processor = this.Verify<PolaroidProcessor>();
this.Verify<PolaroidProcessor>();
}
[Fact]
public void Polaroid_amount_rect_PolaroidProcessorDefaultsSet()
{
this.operations.Polaroid(this.rect);
var processor = this.Verify<PolaroidProcessor>(this.rect);
this.Verify<PolaroidProcessor>(this.rect);
}
}
}
}

8
tests/ImageSharp.Tests/Processing/Filters/SepiaTest.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.Processing;
@ -13,14 +13,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
public void Sepia_amount_SepiaProcessorDefaultsSet()
{
this.operations.Sepia();
var processor = this.Verify<SepiaProcessor>();
this.Verify<SepiaProcessor>();
}
[Fact]
public void Sepia_amount_rect_SepiaProcessorDefaultsSet()
{
this.operations.Sepia(this.rect);
var processor = this.Verify<SepiaProcessor>(this.rect);
this.Verify<SepiaProcessor>(this.rect);
}
}
}
}

6
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.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;
@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
var referenceMap = ReferenceKernelMap.Calculate(resampler, destSize, srcSize);
var kernelMap = ResizeKernelMap.Calculate(resampler, destSize, srcSize, Configuration.Default.MemoryAllocator);
#if DEBUG
this.Output.WriteLine(kernelMap.Info);
@ -239,4 +239,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
return result;
}
}
}
}

7
tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.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;
@ -249,11 +249,6 @@ namespace SixLabors.ImageSharp.Tests
LocalizedString_Rand1,
LocalizedString_Rand2,
};
private static readonly IccLocalizedString[] LocalizedString_RandArr2 = new IccLocalizedString[]
{
LocalizedString_Rand2,
LocalizedString_Rand1,
};
private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr1);
private static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat

1
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs

@ -166,7 +166,6 @@ namespace SixLabors.ImageSharp.Tests
public override string ToString()
{
string provName = this.GetType().Name.Replace("Provider", "");
return $"{this.SourceFileOrDescription}[{this.PixelType}]";
}
}

33
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.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;
@ -20,17 +20,16 @@ namespace SixLabors.ImageSharp.Tests
public class TestImageProviderTests
{
public static readonly TheoryData<object> BasicData = new TheoryData<object>()
{
TestImageProvider<Rgba32>.Blank(10, 20),
TestImageProvider<HalfVector4>.Blank(10, 20),
};
{
TestImageProvider<Rgba32>.Blank(10, 20),
TestImageProvider<HalfVector4>.Blank(10, 20),
};
public static readonly TheoryData<object> FileData = new TheoryData<object>()
{
TestImageProvider<Rgba32>.File(TestImages.Bmp.Car),
TestImageProvider<HalfVector4>.File(
TestImages.Bmp.F)
};
{
TestImageProvider<Rgba32>.File(TestImages.Bmp.Car),
TestImageProvider<HalfVector4>.File(TestImages.Bmp.F)
};
public static string[] AllBmpFiles = { TestImages.Bmp.F, TestImages.Bmp.Bit8 };
@ -320,7 +319,7 @@ namespace SixLabors.ImageSharp.Tests
img.DebugSave(provider);
}
}
[Theory]
[WithTestPatternImages(20, 20, PixelTypes.Rgba32)]
public void Use_WithTestPatternImages_CustomConfiguration<TPixel>(TestImageProvider<TPixel> provider)
@ -332,13 +331,13 @@ namespace SixLabors.ImageSharp.Tests
private static void EnsureCustomConfigurationIsApplied<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (var image1 = provider.GetImage())
using (provider.GetImage())
{
var customConfiguration = Configuration.CreateDefaultInstance();
provider.Configuration = customConfiguration;
using (var image2 = provider.GetImage())
using (var image3 = provider.GetImage())
using (Image<TPixel> image2 = provider.GetImage())
using (Image<TPixel> image3 = provider.GetImage())
{
Assert.Same(customConfiguration, image2.GetConfiguration());
Assert.Same(customConfiguration, image3.GetConfiguration());
@ -379,7 +378,7 @@ namespace SixLabors.ImageSharp.Tests
this.callerName = name;
invocationCounts[name] = 0;
}
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
}
@ -418,8 +417,8 @@ namespace SixLabors.ImageSharp.Tests
this.callerName = name;
invocationCounts[name] = 0;
}
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
}
}
}
}

Loading…
Cancel
Save