Skip to content

Commit c80bda4

Browse files
Merge pull request #2345 from stefannikolei/sn/nullable/format_bmp
Remove nullable disable from Formats.BMP
2 parents a37b0f5 + 66d494e commit c80bda4

File tree

8 files changed

+153
-145
lines changed

8 files changed

+153
-145
lines changed

src/ImageSharp/Color/Color.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,10 @@ public TPixel ToPixel<TPixel>()
286286
/// Bulk converts a span of <see cref="Color"/> to a span of a specified <typeparamref name="TPixel"/> type.
287287
/// </summary>
288288
/// <typeparam name="TPixel">The pixel type to convert to.</typeparam>
289-
/// <param name="configuration">The configuration.</param>
290289
/// <param name="source">The source color span.</param>
291290
/// <param name="destination">The destination pixel span.</param>
292291
[MethodImpl(InliningOptions.ShortMethod)]
293-
#pragma warning disable RCS1163 // Unused parameter.
294-
public static void ToPixel<TPixel>(Configuration configuration, ReadOnlySpan<Color> source, Span<TPixel> destination)
295-
#pragma warning restore RCS1163 // Unused parameter.
292+
public static void ToPixel<TPixel>(ReadOnlySpan<Color> source, Span<TPixel> destination)
296293
where TPixel : unmanaged, IPixel<TPixel>
297294
{
298295
// TODO: Investigate bulk operations utilizing configuration parameter here.

src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

Lines changed: 96 additions & 83 deletions
Large diffs are not rendered by default.

src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

Lines changed: 47 additions & 43 deletions
Large diffs are not rendered by default.

src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public PaletteDitherProcessor(Configuration configuration, PaletteDitherProcesso
3535

3636
ReadOnlySpan<Color> sourcePalette = definition.Palette.Span;
3737
this.paletteOwner = this.Configuration.MemoryAllocator.Allocate<TPixel>(sourcePalette.Length);
38-
Color.ToPixel(this.Configuration, sourcePalette, this.paletteOwner.Memory.Span);
38+
Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span);
3939

4040
this.ditherProcessor = new DitherProcessor(
4141
this.Configuration,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
2626
private readonly int maxColors;
2727
private readonly int bitDepth;
2828
private readonly Octree octree;
29-
private IMemoryOwner<TPixel> paletteOwner;
29+
private readonly IMemoryOwner<TPixel> paletteOwner;
3030
private ReadOnlyMemory<TPixel> palette;
3131
private EuclideanPixelMap<TPixel>? pixelMap;
3232
private readonly bool isDithering;
@@ -40,9 +40,6 @@ public struct OctreeQuantizer<TPixel> : IQuantizer<TPixel>
4040
[MethodImpl(InliningOptions.ShortMethod)]
4141
public OctreeQuantizer(Configuration configuration, QuantizerOptions options)
4242
{
43-
Guard.NotNull(configuration, nameof(configuration));
44-
Guard.NotNull(options, nameof(options));
45-
4643
this.Configuration = configuration;
4744
this.Options = options;
4845

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public IQuantizer<TPixel> CreatePixelSpecificQuantizer<TPixel>(Configuration con
5151

5252
// Always use the palette length over options since the palette cannot be reduced.
5353
TPixel[] palette = new TPixel[this.colorPalette.Length];
54-
Color.ToPixel(configuration, this.colorPalette.Span, palette.AsSpan());
54+
Color.ToPixel(this.colorPalette.Span, palette.AsSpan());
5555
return new PaletteQuantizer<TPixel>(configuration, options, palette);
5656
}
5757
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization;
1717
"Design",
1818
"CA1001:Types that own disposable fields should be disposable",
1919
Justification = "https://github.com/dotnet/roslyn-analyzers/issues/6151")]
20-
internal struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
20+
internal readonly struct PaletteQuantizer<TPixel> : IQuantizer<TPixel>
2121
where TPixel : unmanaged, IPixel<TPixel>
2222
{
23-
private EuclideanPixelMap<TPixel> pixelMap;
23+
private readonly EuclideanPixelMap<TPixel> pixelMap;
2424

2525
/// <summary>
2626
/// Initializes a new instance of the <see cref="PaletteQuantizer{TPixel}"/> struct.
@@ -65,8 +65,5 @@ public readonly byte GetQuantizedColor(TPixel color, out TPixel match)
6565
=> (byte)this.pixelMap.GetClosestColor(color, out match);
6666

6767
/// <inheritdoc/>
68-
public void Dispose()
69-
{
70-
this.pixelMap.Dispose();
71-
}
68+
public void Dispose() => this.pixelMap.Dispose();
7269
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ internal struct WuQuantizer<TPixel> : IQuantizer<TPixel>
6969
/// </summary>
7070
private const int TableLength = IndexCount * IndexCount * IndexCount * IndexAlphaCount;
7171

72-
private IMemoryOwner<Moment> momentsOwner;
73-
private IMemoryOwner<byte> tagsOwner;
74-
private IMemoryOwner<TPixel> paletteOwner;
72+
private readonly IMemoryOwner<Moment> momentsOwner;
73+
private readonly IMemoryOwner<byte> tagsOwner;
74+
private readonly IMemoryOwner<TPixel> paletteOwner;
7575
private ReadOnlyMemory<TPixel> palette;
7676
private int maxColors;
7777
private readonly Box[] colorCube;

0 commit comments

Comments
 (0)