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.currentStream.Position += 4;
this.ReadScanlines( this.ReadScanlines(chunk.Length - 4, currentFrame, pngMetadata, this.ReadNextDataChunkAndSkipSeq, lastFrameControl.Value, cancellationToken);
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);
lastFrameControl = null; lastFrameControl = null;
break; break;
case PngChunkType.Data: case PngChunkType.Data:
@ -1576,7 +1560,7 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
Span<byte> buffer = stackalloc byte[20]; 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)) if (this.TryReadChunk(buffer, out PngChunk chunk))
{ {
@ -1592,6 +1576,22 @@ internal sealed class PngDecoderCore : IImageDecoderInternals
return 0; 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> /// <summary>
/// Reads a chunk from the stream. /// Reads a chunk from the stream.
/// </summary> /// </summary>

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

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

Loading…
Cancel
Save