Browse Source

Minor cleanup

pull/2346/head
James Jackson-South 3 years ago
parent
commit
c6e583991c
  1. 8
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  2. 4
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  3. 2
      src/ImageSharp/Image.cs

8
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -337,9 +337,9 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
/// <summary>
/// Skips over a block or reads its terminator.
/// <param name="blockSize">The length of the block to skip.</param>
/// <param name="stream">The <see cref="BufferedReadStream"/> containing image data.</param>
/// </summary>
/// <param name="stream">The <see cref="BufferedReadStream"/> containing image data.</param>
/// <param name="blockSize">The length of the block to skip.</param>
private static void SkipBlock(BufferedReadStream stream, int blockSize = 0)
{
if (blockSize > 0)
@ -363,7 +363,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
{
int length;
StringBuilder stringBuilder = new StringBuilder();
StringBuilder stringBuilder = new();
while ((length = stream.ReadByte()) != 0)
{
if (length > GifConstants.MaxCommentSubBlockLength)
@ -450,7 +450,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
private void ReadFrameIndices(BufferedReadStream stream, Buffer2D<byte> indices)
{
int minCodeSize = stream.ReadByte();
using LzwDecoder lzwDecoder = new LzwDecoder(this.configuration.MemoryAllocator, stream);
using LzwDecoder lzwDecoder = new(this.configuration.MemoryAllocator, stream);
lzwDecoder.DecodePixels(minCodeSize, indices);
}

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

@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License.
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced;
@ -141,7 +140,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
private void EncodeFrames<TPixel>(
Stream stream,
Image<TPixel> image,
IndexedImageFrame<TPixel>? quantized,
IndexedImageFrame<TPixel> quantized,
ReadOnlyMemory<TPixel> palette)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -168,7 +167,6 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
// Clean up for the next run.
quantized.Dispose();
quantized = null;
}
if (hasPaletteQuantizer)

2
src/ImageSharp/Image.cs

@ -30,7 +30,7 @@ public abstract partial class Image : ImageInfo, IDisposable, IConfigurationProv
/// <param name="size">The size in px units.</param>
protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata? metadata, Size size)
: base(pixelType, size, metadata)
=> this.configuration = configuration ?? Configuration.Default;
=> this.configuration = configuration;
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class.

Loading…
Cancel
Save