Skip to content

Commit

Permalink
Merge pull request #2828 from SixLabors/js/issue-2806
Browse files Browse the repository at this point in the history
Rewrite ChunkedMemoryStream
  • Loading branch information
JimBobSquarePants authored Nov 13, 2024
2 parents 114cc43 + c4fd666 commit 313a7e8
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 432 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 313a7e8

Please sign in to comment.