Browse Source

Fix build

Code analysis in rider did not catch that. only the build failed.
pull/2338/head
Stefan Nikolei 3 years ago
parent
commit
e7bcc5f132
  1. 5
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
  2. 5
      src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer{TPixel}.cs

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

@ -26,7 +26,6 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
private readonly int maxColors;
private readonly int bitDepth;
private readonly Octree octree;
[NotNull]
private IMemoryOwner<TPixel>? paletteOwner;
private ReadOnlyMemory<TPixel> palette;
private EuclideanPixelMap<TPixel>? pixelMap;
@ -99,7 +98,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
}
int paletteIndex = 0;
Span<TPixel> paletteSpan = this.paletteOwner.GetSpan();
Span<TPixel> paletteSpan = this.paletteOwner!.GetSpan();
// On very rare occasions, (blur.png), the quantizer does not preserve a
// transparent entry when palletizing the captured colors.
@ -113,7 +112,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
}
this.octree.Palletize(paletteSpan, max, ref paletteIndex);
ReadOnlyMemory<TPixel> result = this.paletteOwner.Memory[..paletteSpan.Length];
ReadOnlyMemory<TPixel> result = this.paletteOwner!.Memory[..paletteSpan.Length];
// When called multiple times by QuantizerUtilities.BuildPalette
// this prevents memory churn caused by reallocation.

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

@ -20,7 +20,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization;
internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
[NotNull]
private EuclideanPixelMap<TPixel>? pixelMap;
/// <summary>
@ -47,7 +46,7 @@ internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
public QuantizerOptions Options { get; }
/// <inheritdoc/>
public ReadOnlyMemory<TPixel> Palette => this.pixelMap.Palette;
public ReadOnlyMemory<TPixel> Palette => this.pixelMap!.Palette;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -63,7 +62,7 @@ internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public readonly byte GetQuantizedColor(TPixel color, out TPixel match)
=> (byte)this.pixelMap.GetClosestColor(color, out match);
=> (byte)this.pixelMap!.GetClosestColor(color, out match);
/// <inheritdoc/>
public void Dispose()

Loading…
Cancel
Save