Skip to content

Commit af0b7bf

Browse files
committed
Merge remote-tracking branch 'origin/main' into bp/modeScoreArm
# Conflicts: # tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs
2 parents 7483802 + 5de22f4 commit af0b7bf

20 files changed

+516
-572
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/Formats/Gif/GifDecoderCore.cs

Lines changed: 73 additions & 70 deletions
Large diffs are not rendered by default.

src/ImageSharp/Formats/Gif/GifEncoderCore.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3-
#nullable disable
43

54
using System.Buffers;
65
using System.Runtime.CompilerServices;
@@ -93,7 +92,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
9392
bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;
9493

9594
// Quantize the image returning a palette.
96-
IndexedImageFrame<TPixel> quantized;
95+
IndexedImageFrame<TPixel>? quantized;
9796
using (IQuantizer<TPixel> frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer<TPixel>(this.configuration))
9897
{
9998
if (useGlobalTable)
@@ -129,7 +128,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
129128
this.WriteComments(gifMetadata, stream);
130129

131130
// Write application extensions.
132-
XmpProfile xmpProfile = image.Metadata.XmpProfile ?? image.Frames.RootFrame.Metadata.XmpProfile;
131+
XmpProfile? xmpProfile = image.Metadata.XmpProfile ?? image.Frames.RootFrame.Metadata.XmpProfile;
133132
this.WriteApplicationExtensions(stream, image.Frames.Count, gifMetadata.RepeatCount, xmpProfile);
134133
}
135134

@@ -152,8 +151,8 @@ private void EncodeFrames<TPixel>(
152151
// Gather the metadata for this frame.
153152
ImageFrame<TPixel> frame = image.Frames[i];
154153
ImageFrameMetadata metadata = frame.Metadata;
155-
bool hasMetadata = metadata.TryGetGifMetadata(out GifFrameMetadata frameMetadata);
156-
bool useLocal = this.colorTableMode == GifColorTableMode.Local || (hasMetadata && frameMetadata.ColorTableMode == GifColorTableMode.Local);
154+
bool hasMetadata = metadata.TryGetGifMetadata(out GifFrameMetadata? frameMetadata);
155+
bool useLocal = this.colorTableMode == GifColorTableMode.Local || (hasMetadata && frameMetadata!.ColorTableMode == GifColorTableMode.Local);
157156

158157
if (!useLocal && !hasPaletteQuantizer && i > 0)
159158
{
@@ -164,11 +163,10 @@ private void EncodeFrames<TPixel>(
164163
paletteQuantizer = new(this.configuration, this.quantizer.Options, palette);
165164
}
166165

167-
this.EncodeFrame(stream, frame, i, useLocal, frameMetadata, ref quantized, ref paletteQuantizer);
166+
this.EncodeFrame(stream, frame, i, useLocal, frameMetadata, ref quantized!, ref paletteQuantizer);
168167

169168
// Clean up for the next run.
170169
quantized.Dispose();
171-
quantized = null;
172170
}
173171

174172
if (hasPaletteQuantizer)
@@ -182,7 +180,7 @@ private void EncodeFrame<TPixel>(
182180
ImageFrame<TPixel> frame,
183181
int frameIndex,
184182
bool useLocal,
185-
GifFrameMetadata metadata,
183+
GifFrameMetadata? metadata,
186184
ref IndexedImageFrame<TPixel> quantized,
187185
ref PaletteQuantizer<TPixel> paletteQuantizer)
188186
where TPixel : unmanaged, IPixel<TPixel>
@@ -193,7 +191,7 @@ private void EncodeFrame<TPixel>(
193191
if (useLocal)
194192
{
195193
// Reassign using the current frame and details.
196-
QuantizerOptions options = null;
194+
QuantizerOptions? options = null;
197195
int colorTableLength = metadata?.ColorTableLength ?? 0;
198196
if (colorTableLength > 0)
199197
{
@@ -338,7 +336,7 @@ private void WriteLogicalScreenDescriptor(
338336
/// <param name="frameCount">The frame count fo this image.</param>
339337
/// <param name="repeatCount">The animated image repeat count.</param>
340338
/// <param name="xmpProfile">The XMP metadata profile. Null if profile is not to be written.</param>
341-
private void WriteApplicationExtensions(Stream stream, int frameCount, ushort repeatCount, XmpProfile xmpProfile)
339+
private void WriteApplicationExtensions(Stream stream, int frameCount, ushort repeatCount, XmpProfile? xmpProfile)
342340
{
343341
// Application Extension: Loop repeat count.
344342
if (frameCount > 1 && repeatCount != 1)
@@ -350,7 +348,7 @@ private void WriteApplicationExtensions(Stream stream, int frameCount, ushort re
350348
// Application Extension: XMP Profile.
351349
if (xmpProfile != null)
352350
{
353-
GifXmpApplicationExtension xmpExtension = new(xmpProfile.Data);
351+
GifXmpApplicationExtension xmpExtension = new(xmpProfile.Data!);
354352
this.WriteExtension(xmpExtension, stream);
355353
}
356354
}
@@ -439,7 +437,7 @@ private void WriteGraphicalControlExtension(GifFrameMetadata metadata, int trans
439437
private void WriteExtension<TGifExtension>(TGifExtension extension, Stream stream)
440438
where TGifExtension : struct, IGifExtension
441439
{
442-
IMemoryOwner<byte> owner = null;
440+
IMemoryOwner<byte>? owner = null;
443441
Span<byte> extensionBuffer;
444442
int extensionSize = extension.ContentLength;
445443

src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3-
#nullable disable
43

54
using SixLabors.ImageSharp.IO;
65
using SixLabors.ImageSharp.Memory;
@@ -45,7 +44,7 @@ internal sealed class PbmDecoderCore : IImageDecoderInternals
4544
/// <summary>
4645
/// The <see cref="ImageMetadata"/> decoded by this decoder instance.
4746
/// </summary>
48-
private ImageMetadata metadata;
47+
private ImageMetadata? metadata;
4948

5049
/// <summary>
5150
/// Initializes a new instance of the <see cref="PbmDecoderCore" /> class.

0 commit comments

Comments
 (0)