Browse Source

Minor cleanup

pull/2346/head
James Jackson-South 4 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> /// <summary>
/// Skips over a block or reads its terminator. /// 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> /// </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) private static void SkipBlock(BufferedReadStream stream, int blockSize = 0)
{ {
if (blockSize > 0) if (blockSize > 0)
@ -363,7 +363,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
{ {
int length; int length;
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new();
while ((length = stream.ReadByte()) != 0) while ((length = stream.ReadByte()) != 0)
{ {
if (length > GifConstants.MaxCommentSubBlockLength) if (length > GifConstants.MaxCommentSubBlockLength)
@ -450,7 +450,7 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
private void ReadFrameIndices(BufferedReadStream stream, Buffer2D<byte> indices) private void ReadFrameIndices(BufferedReadStream stream, Buffer2D<byte> indices)
{ {
int minCodeSize = stream.ReadByte(); 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); lzwDecoder.DecodePixels(minCodeSize, indices);
} }

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

@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using System.Buffers; using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
@ -141,7 +140,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
private void EncodeFrames<TPixel>( private void EncodeFrames<TPixel>(
Stream stream, Stream stream,
Image<TPixel> image, Image<TPixel> image,
IndexedImageFrame<TPixel>? quantized, IndexedImageFrame<TPixel> quantized,
ReadOnlyMemory<TPixel> palette) ReadOnlyMemory<TPixel> palette)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -168,7 +167,6 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
// Clean up for the next run. // Clean up for the next run.
quantized.Dispose(); quantized.Dispose();
quantized = null;
} }
if (hasPaletteQuantizer) 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> /// <param name="size">The size in px units.</param>
protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata? metadata, Size size) protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata? metadata, Size size)
: base(pixelType, size, metadata) : base(pixelType, size, metadata)
=> this.configuration = configuration ?? Configuration.Default; => this.configuration = configuration;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Image"/> class. /// Initializes a new instance of the <see cref="Image"/> class.

Loading…
Cancel
Save