Browse Source

Fix: replace lambda with method

pull/2511/head
Poker 3 years ago
parent
commit
146406494a
No known key found for this signature in database GPG Key ID: 720AFAD63099D9CB
  1. 36
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  2. 1
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

36
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -213,23 +213,7 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
}
this.currentStream.Position += 4;
this.ReadScanlines(
chunk.Length - 4,
currentFrame,
pngMetadata,
() =>
{
int length = this.ReadNextDataChunk();
if (this.ReadNextDataChunk() is 0)
{
return length;
}
this.currentStream.Position += 4; // Skip sequence number
return length - 4;
},
lastFrameControl.Value,
cancellationToken);
this.ReadScanlines(chunk.Length - 4, currentFrame, pngMetadata, this.ReadNextDataChunkAndSkipSeq, lastFrameControl.Value, cancellationToken);
lastFrameControl = null;
break;
case PngChunkType.Data:
@ -1576,7 +1560,7 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
Span<byte> buffer = stackalloc byte[20];
this.currentStream.Read(buffer, 0, 4);
_ = this.currentStream.Read(buffer, 0, 4);
if (this.TryReadChunk(buffer, out PngChunk chunk))
{
@ -1592,6 +1576,22 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
return 0;
}
/// <summary>
/// Reads the next data chunk and skip sequence number.
/// </summary>
/// <returns>Count of bytes in the next data chunk, or 0 if there are no more data chunks left.</returns>
private int ReadNextDataChunkAndSkipSeq()
{
int length = this.ReadNextDataChunk();
if (this.ReadNextDataChunk() is 0)
{
return length;
}
this.currentStream.Position += 4; // Skip sequence number
return length - 4;
}
/// <summary>
/// Reads a chunk from the stream.
/// </summary>

1
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -240,7 +240,6 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
}
});
}
}
/// <summary>

Loading…
Cancel
Save