Skip to content

Commit 1464064

Browse files
committed
Fix: replace lambda with method
1 parent c253f39 commit 1464064

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
213213
}
214214

215215
this.currentStream.Position += 4;
216-
this.ReadScanlines(
217-
chunk.Length - 4,
218-
currentFrame,
219-
pngMetadata,
220-
() =>
221-
{
222-
int length = this.ReadNextDataChunk();
223-
if (this.ReadNextDataChunk() is 0)
224-
{
225-
return length;
226-
}
227-
228-
this.currentStream.Position += 4; // Skip sequence number
229-
return length - 4;
230-
},
231-
lastFrameControl.Value,
232-
cancellationToken);
216+
this.ReadScanlines(chunk.Length - 4, currentFrame, pngMetadata, this.ReadNextDataChunkAndSkipSeq, lastFrameControl.Value, cancellationToken);
233217
lastFrameControl = null;
234218
break;
235219
case PngChunkType.Data:
@@ -1576,7 +1560,7 @@ private int ReadNextDataChunk()
15761560

15771561
Span<byte> buffer = stackalloc byte[20];
15781562

1579-
this.currentStream.Read(buffer, 0, 4);
1563+
_ = this.currentStream.Read(buffer, 0, 4);
15801564

15811565
if (this.TryReadChunk(buffer, out PngChunk chunk))
15821566
{
@@ -1592,6 +1576,22 @@ private int ReadNextDataChunk()
15921576
return 0;
15931577
}
15941578

1579+
/// <summary>
1580+
/// Reads the next data chunk and skip sequence number.
1581+
/// </summary>
1582+
/// <returns>Count of bytes in the next data chunk, or 0 if there are no more data chunks left.</returns>
1583+
private int ReadNextDataChunkAndSkipSeq()
1584+
{
1585+
int length = this.ReadNextDataChunk();
1586+
if (this.ReadNextDataChunk() is 0)
1587+
{
1588+
return length;
1589+
}
1590+
1591+
this.currentStream.Position += 4; // Skip sequence number
1592+
return length - 4;
1593+
}
1594+
15951595
/// <summary>
15961596
/// Reads a chunk from the stream.
15971597
/// </summary>

src/ImageSharp/Formats/Png/PngEncoderCore.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ private static void ClearTransparentPixels<TPixel>(Image<TPixel> image)
240240
}
241241
});
242242
}
243-
244243
}
245244

246245
/// <summary>

0 commit comments

Comments
 (0)