Browse Source

Merge branch 'main' into pt/tiff-encoder-l16

pull/2339/head
Petar Tasev 3 years ago
committed by GitHub
parent
commit
9ed23d921d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  2. 3
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  3. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  4. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  5. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  6. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  7. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  8. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  9. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  10. 3
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  11. 3
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  12. 3
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  13. 3
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  14. 3
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  15. 3
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  16. 3
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  17. 3
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  18. 3
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  19. 3
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  20. 3
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  21. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  22. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  23. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  24. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  25. 7
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  26. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  27. 3
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  28. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  29. 3
      src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs
  30. 7
      src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
  31. 9
      src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs
  32. 5
      src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs
  33. 26
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
  34. 4
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs
  35. 2
      src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs
  36. 2
      src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
  37. 10
      src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
  38. 9
      src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs
  39. 9
      src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs
  40. 5
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

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

@ -171,7 +171,10 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
quantized = null;
}
paletteQuantizer.Dispose();
if (hasPaletteQuantizer)
{
paletteQuantizer.Dispose();
}
}
private void EncodeFrame<TPixel>(

3
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -140,7 +139,7 @@ public partial struct A8 : IPixel<A8>, IPackedVector<byte>
/// </summary>
/// <param name="obj">The object to compare.</param>
/// <returns>True if the object is equal to the packed vector.</returns>
public override readonly bool Equals(object obj) => obj is A8 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is A8 other && this.Equals(other);
/// <summary>
/// Compares another A8 packed vector with the packed vector.

3
src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -335,7 +334,7 @@ public partial struct Abgr32 : IPixel<Abgr32>, IPackedVector<uint>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Abgr32 abgr32 && this.Equals(abgr32);
public override readonly bool Equals(object? obj) => obj is Abgr32 abgr32 && this.Equals(abgr32);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -334,7 +333,7 @@ public partial struct Argb32 : IPixel<Argb32>, IPackedVector<uint>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Argb32 argb32 && this.Equals(argb32);
public override readonly bool Equals(object? obj) => obj is Argb32 argb32 && this.Equals(argb32);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -232,7 +231,7 @@ public partial struct Bgr24 : IPixel<Bgr24>
public readonly bool Equals(Bgr24 other) => this.R.Equals(other.R) && this.G.Equals(other.G) && this.B.Equals(other.B);
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Bgr24 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Bgr24 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"Bgr24({this.B}, {this.G}, {this.R})";

3
src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -151,7 +150,7 @@ public partial struct Bgr565 : IPixel<Bgr565>, IPackedVector<ushort>
(this.PackedValue & 0x1F) * (1F / 31F));
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Bgr565 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Bgr565 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -287,7 +286,7 @@ public partial struct Bgra32 : IPixel<Bgra32>, IPackedVector<uint>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Bgra32 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Bgra32 other && this.Equals(other);
/// <inheritdoc/>
public readonly bool Equals(Bgra32 other) => this.Bgra.Equals(other.Bgra);

3
src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -143,7 +142,7 @@ public partial struct Bgra4444 : IPixel<Bgra4444>, IPackedVector<ushort>
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Bgra4444 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Bgra4444 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -141,7 +140,7 @@ public partial struct Byte4 : IPixel<Byte4>, IPackedVector<uint>
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Byte4 byte4 && this.Equals(byte4);
public override readonly bool Equals(object? obj) => obj is Byte4 byte4 && this.Equals(byte4);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -140,7 +139,7 @@ public partial struct HalfSingle : IPixel<HalfSingle>, IPackedVector<ushort>
public readonly float ToSingle() => HalfTypeHelper.Unpack(this.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfSingle other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is HalfSingle other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -157,7 +156,7 @@ public partial struct HalfVector2 : IPixel<HalfVector2>, IPackedVector<uint>
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfVector2 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is HalfVector2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -149,7 +148,7 @@ public partial struct HalfVector4 : IPixel<HalfVector4>, IPackedVector<ulong>
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is HalfVector4 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is HalfVector4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/L16.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -153,7 +152,7 @@ public partial struct L16 : IPixel<L16>, IPackedVector<ushort>
public void FromRgba64(Rgba64 source) => this.PackedValue = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is L16 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is L16 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -143,7 +142,7 @@ public partial struct L8 : IPixel<L8>, IPackedVector<byte>
ColorNumerics.DownScaleFrom16BitTo8Bit(source.B));
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is L8 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is L8 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/La16.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -80,7 +79,7 @@ public partial struct La16 : IPixel<La16>, IPackedVector<ushort>
public readonly bool Equals(La16 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is La16 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is La16 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"La16({this.L}, {this.A})";

3
src/ImageSharp/PixelFormats/PixelImplementations/La32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -82,7 +81,7 @@ public partial struct La32 : IPixel<La32>, IPackedVector<uint>
public readonly bool Equals(La32 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is La32 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is La32 other && this.Equals(other);
/// <inheritdoc />
public override readonly string ToString() => $"La32({this.L}, {this.A})";

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -162,7 +161,7 @@ public partial struct NormalizedByte2 : IPixel<NormalizedByte2>, IPackedVector<u
(sbyte)((this.PackedValue >> 8) & 0xFF) / MaxPos);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedByte2 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is NormalizedByte2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -154,7 +153,7 @@ public partial struct NormalizedByte4 : IPixel<NormalizedByte4>, IPackedVector<u
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedByte4 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is NormalizedByte4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -163,7 +162,7 @@ public partial struct NormalizedShort2 : IPixel<NormalizedShort2>, IPackedVector
(short)(this.PackedValue >> 0x10) / MaxPos);
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedShort2 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is NormalizedShort2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -155,7 +154,7 @@ public partial struct NormalizedShort4 : IPixel<NormalizedShort4>, IPackedVector
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is NormalizedShort4 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is NormalizedShort4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -146,7 +145,7 @@ public partial struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
public readonly Vector2 ToVector2() => new Vector2(this.PackedValue & 0xFFFF, (this.PackedValue >> 16) & 0xFFFF) / Max;
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rg32 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Rg32 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -241,7 +240,7 @@ public partial struct Rgb24 : IPixel<Rgb24>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Rgb24 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Rgb24 other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -210,7 +209,7 @@ public partial struct Rgb48 : IPixel<Rgb48>
public void FromRgb48(Rgb48 source) => this = source;
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgb48 rgb48 && this.Equals(rgb48);
public override readonly bool Equals(object? obj) => obj is Rgb48 rgb48 && this.Equals(rgb48);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -141,7 +140,7 @@ public partial struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgba1010102 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Rgba1010102 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

7
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Buffers.Binary;
using System.Globalization;
@ -267,7 +266,7 @@ public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
/// The <see cref="bool"/>.
/// </returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static bool TryParseHex(string hex, out Rgba32 result)
public static bool TryParseHex(string? hex, out Rgba32 result)
{
result = default;
if (string.IsNullOrWhiteSpace(hex))
@ -437,7 +436,7 @@ public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is Rgba32 rgba32 && this.Equals(rgba32);
public override readonly bool Equals(object? obj) => obj is Rgba32 rgba32 && this.Equals(rgba32);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -514,7 +513,7 @@ public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
/// <returns>
/// A rrggbbaa hex value.
/// </returns>
private static string ToRgbaHex(string hex)
private static string? ToRgbaHex(string hex)
{
if (hex[0] == '#')
{

3
src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -444,7 +443,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong>
}
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Rgba64 rgba64 && this.Equals(rgba64);
public override readonly bool Equals(object? obj) => obj is Rgba64 rgba64 && this.Equals(rgba64);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Globalization;
using System.Numerics;
@ -193,7 +192,7 @@ public partial struct RgbaVector : IPixel<RgbaVector>
}
/// <inheritdoc/>
public override readonly bool Equals(object obj) => obj is RgbaVector other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is RgbaVector other && this.Equals(other);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -164,7 +163,7 @@ public partial struct Short2 : IPixel<Short2>, IPackedVector<uint>
public readonly Vector2 ToVector2() => new((short)(this.PackedValue & 0xFFFF), (short)(this.PackedValue >> 0x10));
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Short2 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Short2 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -164,7 +163,7 @@ public partial struct Short4 : IPixel<Short4>, IPackedVector<ulong>
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
public override readonly bool Equals(object obj) => obj is Short4 other && this.Equals(other);
public override readonly bool Equals(object? obj) => obj is Short4 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

7
src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Collections.Concurrent;
using SixLabors.ImageSharp.PixelFormats;
@ -17,7 +16,7 @@ internal class DefaultImageProcessorContext<TPixel> : IInternalImageProcessingCo
{
private readonly bool mutate;
private readonly Image<TPixel> source;
private Image<TPixel> destination;
private Image<TPixel>? destination;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultImageProcessorContext{TPixel}"/> class.
@ -54,7 +53,7 @@ internal class DefaultImageProcessorContext<TPixel> : IInternalImageProcessingCo
this.destination = this.source.Clone();
}
return this.destination;
return this.destination!;
}
/// <inheritdoc/>
@ -87,7 +86,7 @@ internal class DefaultImageProcessorContext<TPixel> : IInternalImageProcessingCo
}
// Standard processing pipeline.
using (IImageProcessor<TPixel> specificProcessor = processor.CreatePixelSpecificProcessor(this.Configuration, this.destination, rectangle))
using (IImageProcessor<TPixel> specificProcessor = processor.CreatePixelSpecificProcessor(this.Configuration, this.destination!, rectangle))
{
specificProcessor.Execute();
}

9
src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Buffers;
using System.Runtime.CompilerServices;
@ -16,8 +15,8 @@ internal sealed class KernelSamplingMap : IDisposable
{
private readonly MemoryAllocator allocator;
private bool isDisposed;
private IMemoryOwner<int> yOffsets;
private IMemoryOwner<int> xOffsets;
private IMemoryOwner<int>? yOffsets;
private IMemoryOwner<int>? xOffsets;
/// <summary>
/// Initializes a new instance of the <see cref="KernelSamplingMap"/> class.
@ -65,10 +64,10 @@ internal sealed class KernelSamplingMap : IDisposable
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<int> GetRowOffsetSpan() => this.yOffsets.GetSpan();
public Span<int> GetRowOffsetSpan() => this.yOffsets!.GetSpan();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<int> GetColumnOffsetSpan() => this.xOffsets.GetSpan();
public Span<int> GetColumnOffsetSpan() => this.xOffsets!.GetSpan();
/// <inheritdoc/>
public void Dispose()

5
src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
@ -65,7 +64,7 @@ public class DrawImageProcessor : IImageProcessor
{
ProcessorFactoryVisitor<TPixelBg> visitor = new(configuration, this, source, sourceRectangle);
this.Image.AcceptVisitor(visitor);
return visitor.Result;
return visitor.Result!;
}
private class ProcessorFactoryVisitor<TPixelBg> : IImageVisitor
@ -84,7 +83,7 @@ public class DrawImageProcessor : IImageProcessor
this.sourceRectangle = sourceRectangle;
}
public IImageProcessor<TPixelBg> Result { get; private set; }
public IImageProcessor<TPixelBg>? Result { get; private set; }
public void Visit<TPixelFg>(Image<TPixelFg> image)
where TPixelFg : unmanaged, IPixel<TPixelFg>

26
src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
@ -29,7 +28,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
private readonly Octree octree;
private IMemoryOwner<TPixel> paletteOwner;
private ReadOnlyMemory<TPixel> palette;
private EuclideanPixelMap<TPixel> pixelMap;
private EuclideanPixelMap<TPixel>? pixelMap;
private readonly bool isDithering;
private bool isDisposed;
@ -143,7 +142,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
// pixel and a black one.
if (this.isDithering || color.Equals(default))
{
return (byte)this.pixelMap.GetClosestColor(color, out match);
return (byte)this.pixelMap!.GetClosestColor(color, out match);
}
ref TPixel paletteRef = ref MemoryMarshal.GetReference(this.palette.Span);
@ -158,8 +157,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
if (!this.isDisposed)
{
this.isDisposed = true;
this.paletteOwner?.Dispose();
this.paletteOwner = null;
this.paletteOwner.Dispose();
this.pixelMap?.Dispose();
this.pixelMap = null;
}
@ -183,7 +181,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
/// <summary>
/// Store the last node quantized
/// </summary>
private OctreeNode previousNode;
private OctreeNode? previousNode;
/// <summary>
/// Cache the previous color quantized
@ -221,7 +219,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
/// <summary>
/// Gets the array of reducible nodes
/// </summary>
private OctreeNode[] ReducibleNodes
private OctreeNode?[] ReducibleNodes
{
[MethodImpl(InliningOptions.ShortMethod)]
get;
@ -311,7 +309,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
}
// Reduce the node most recently added to the list at level 'index'
OctreeNode node = this.ReducibleNodes[index];
OctreeNode node = this.ReducibleNodes[index]!;
this.ReducibleNodes[index] = node.NextReducible;
// Decrement the leaf count after reducing the node
@ -330,7 +328,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
/// <summary>
/// Pointers to any child nodes
/// </summary>
private readonly OctreeNode[] children;
private readonly OctreeNode?[]? children;
/// <summary>
/// Flag indicating that this is a leaf node
@ -395,7 +393,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
/// <summary>
/// Gets the next reducible node
/// </summary>
public OctreeNode NextReducible
public OctreeNode? NextReducible
{
[MethodImpl(InliningOptions.ShortMethod)]
get;
@ -423,7 +421,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
// Go to the next level down in the tree
int index = GetColorIndex(ref color, level);
OctreeNode child = this.children[index];
OctreeNode? child = this.children![index];
if (child is null)
{
// Create a new child node and store it in the array
@ -448,7 +446,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
// Loop through all children and add their information to this node
for (int index = 0; index < 8; index++)
{
OctreeNode child = this.children[index];
OctreeNode? child = this.children![index];
if (child != null)
{
this.red += child.red;
@ -495,7 +493,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
// Loop through children looking for leaves
for (int i = 0; i < 8; i++)
{
this.children[i]?.ConstructPalette(palette, ref index);
this.children![i]?.ConstructPalette(palette, ref index);
}
}
}
@ -517,7 +515,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
}
int colorIndex = GetColorIndex(ref pixel, level);
OctreeNode child = this.children[colorIndex];
OctreeNode? child = this.children![colorIndex];
int index = 0;
if (child != null)

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
@ -68,7 +67,6 @@ internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
/// <inheritdoc/>
public void Dispose()
{
this.pixelMap?.Dispose();
this.pixelMap = null;
this.pixelMap.Dispose();
}
}

2
src/ImageSharp/Processing/Processors/Quantization/QuantizerOptions.cs

@ -17,7 +17,7 @@ public class QuantizerOptions
/// Gets or sets the algorithm to apply to the output image.
/// Defaults to <see cref="QuantizerConstants.DefaultDither"/>; set to <see langword="null"/> for no dithering.
/// </summary>
public IDither Dither { get; set; } = QuantizerConstants.DefaultDither;
public IDither? Dither { get; set; } = QuantizerConstants.DefaultDither;
/// <summary>
/// Gets or sets the dithering scale used to adjust the amount of dither. Range 0..1.

2
src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs

@ -146,7 +146,7 @@ public static class QuantizerUtilities
where TFrameQuantizer : struct, IQuantizer<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
IDither dither = quantizer.Options.Dither;
IDither? dither = quantizer.Options.Dither;
Buffer2D<TPixel> sourceBuffer = source.PixelBuffer;
if (dither is null)

10
src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
@ -76,7 +75,7 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
private ReadOnlyMemory<TPixel> palette;
private int maxColors;
private readonly Box[] colorCube;
private EuclideanPixelMap<TPixel> pixelMap;
private EuclideanPixelMap<TPixel>? pixelMap;
private readonly bool isDithering;
private bool isDisposed;
@ -175,7 +174,7 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
{
if (this.isDithering)
{
return (byte)this.pixelMap.GetClosestColor(color, out match);
return (byte)this.pixelMap!.GetClosestColor(color, out match);
}
Rgba32 rgba = default;
@ -203,9 +202,6 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
this.momentsOwner?.Dispose();
this.tagsOwner?.Dispose();
this.paletteOwner?.Dispose();
this.momentsOwner = null;
this.tagsOwner = null;
this.paletteOwner = null;
this.pixelMap?.Dispose();
this.pixelMap = null;
}
@ -869,7 +865,7 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
public int Volume;
/// <inheritdoc/>
public override readonly bool Equals(object obj)
public override readonly bool Equals(object? obj)
=> obj is Box box
&& this.Equals(box);

9
src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -20,8 +19,8 @@ internal class AffineTransformProcessor<TPixel> : TransformProcessor<TPixel>, IR
private readonly Size destinationSize;
private readonly Matrix3x2 transformMatrix;
private readonly IResampler resampler;
private ImageFrame<TPixel> source;
private ImageFrame<TPixel> destination;
private ImageFrame<TPixel>? source;
private ImageFrame<TPixel>? destination;
/// <summary>
/// Initializes a new instance of the <see cref="AffineTransformProcessor{TPixel}"/> class.
@ -53,8 +52,8 @@ internal class AffineTransformProcessor<TPixel> : TransformProcessor<TPixel>, IR
where TResampler : struct, IResampler
{
Configuration configuration = this.Configuration;
ImageFrame<TPixel> source = this.source;
ImageFrame<TPixel> destination = this.destination;
ImageFrame<TPixel> source = this.source!;
ImageFrame<TPixel> destination = this.destination!;
Matrix3x2 matrix = this.transformMatrix;
// Handle transforms that result in output identical to the original.

9
src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Numerics;
using System.Runtime.CompilerServices;
@ -20,8 +19,8 @@ internal class ProjectiveTransformProcessor<TPixel> : TransformProcessor<TPixel>
private readonly Size destinationSize;
private readonly IResampler resampler;
private readonly Matrix4x4 transformMatrix;
private ImageFrame<TPixel> source;
private ImageFrame<TPixel> destination;
private ImageFrame<TPixel>? source;
private ImageFrame<TPixel>? destination;
/// <summary>
/// Initializes a new instance of the <see cref="ProjectiveTransformProcessor{TPixel}"/> class.
@ -53,8 +52,8 @@ internal class ProjectiveTransformProcessor<TPixel> : TransformProcessor<TPixel>
where TResampler : struct, IResampler
{
Configuration configuration = this.Configuration;
ImageFrame<TPixel> source = this.source;
ImageFrame<TPixel> destination = this.destination;
ImageFrame<TPixel> source = this.source!;
ImageFrame<TPixel> destination = this.destination!;
Matrix4x4 matrix = this.transformMatrix;
// Handle transforms that result in output identical to the original.

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

@ -1,6 +1,5 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#nullable disable
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
@ -21,7 +20,7 @@ internal class ResizeProcessor<TPixel> : TransformProcessor<TPixel>, IResampling
private readonly int destinationHeight;
private readonly IResampler resampler;
private readonly Rectangle destinationRectangle;
private Image<TPixel> destination;
private Image<TPixel>? destination;
public ResizeProcessor(Configuration configuration, ResizeProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
: base(configuration, source, sourceRectangle)
@ -56,7 +55,7 @@ internal class ResizeProcessor<TPixel> : TransformProcessor<TPixel>, IResampling
{
Configuration configuration = this.Configuration;
Image<TPixel> source = this.Source;
Image<TPixel> destination = this.destination;
Image<TPixel> destination = this.destination!;
Rectangle sourceRectangle = this.SourceRectangle;
Rectangle destinationRectangle = this.destinationRectangle;
bool compand = this.options.Compand;

Loading…
Cancel
Save