Skip to content

Commit

Permalink
Rewrite ChunkedMemoryStream
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Oct 23, 2024
1 parent c418bb0 commit 48645f8
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 408 deletions.
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/ImageEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void EncodeWithSeekableStream<TPixel>(Image<TPixel> image, Stream stream
else
{
using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
this.Encode(image, stream, cancellationToken);
this.Encode(image, ms, cancellationToken);
ms.Position = 0;
ms.CopyTo(stream, configuration.StreamProcessingBufferSize);
}
Expand All @@ -65,7 +65,7 @@ private async Task EncodeWithSeekableStreamAsync<TPixel>(Image<TPixel> image, St
}
else
{
using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
await using ChunkedMemoryStream ms = new(configuration.MemoryAllocator);
await DoEncodeAsync(ms);
ms.Position = 0;
await ms.CopyToAsync(stream, configuration.StreamProcessingBufferSize, cancellationToken)
Expand Down
Loading

0 comments on commit 48645f8

Please sign in to comment.