Skip to content

Commit 48645f8

Browse files
Rewrite ChunkedMemoryStream
1 parent c418bb0 commit 48645f8

File tree

5 files changed

+361
-408
lines changed

5 files changed

+361
-408
lines changed

src/ImageSharp/Formats/ImageEncoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void EncodeWithSeekableStream<TPixel>(Image<TPixel> image, Stream stream
4949
else
5050
{
5151
using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
52-
this.Encode(image, stream, cancellationToken);
52+
this.Encode(image, ms, cancellationToken);
5353
ms.Position = 0;
5454
ms.CopyTo(stream, configuration.StreamProcessingBufferSize);
5555
}
@@ -65,7 +65,7 @@ private async Task EncodeWithSeekableStreamAsync<TPixel>(Image<TPixel> image, St
6565
}
6666
else
6767
{
68-
using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
68+
await using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
6969
await DoEncodeAsync(ms);
7070
ms.Position = 0;
7171
await ms.CopyToAsync(stream, configuration.StreamProcessingBufferSize, cancellationToken)

0 commit comments

Comments
 (0)