question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support of ReadOnlySequence and IBufferWriter

See original GitHub issue

Description

MagickImage recently began support initialization from ReadOnlySpan<byte>, which is great! But some times source memory can be fragmented and to prevent heap allocation it would be nice to have initialization from ReadOnlySequence<byte>. Also writing output is still restricted to Stream and coresponding to Span’s it would be good to have overload for IBufferWriter<byte>.

Proposal

Add constructor overload MagickImage(ReadOnlySequence<byte> data) and coresponding Read overload. Add Write overload MagickImage.Write(IBufferWriter<byte> buffer).

System Configuration

  • Magick.NET version: Magick.NET-Q16-x64 8.1.0
  • Environment (Operating system, version and so on): Windows 10 x64

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dlemstracommented, Aug 9, 2021

I added a unit test for this to make sure this works but it I only tested this with 1 byte sequences. This probably fails with sequences of a specific size will add a test for this and get this fixed.

edit: I am working on a fix and I will publish a new release in a couple hours.

1reaction
dlemstracommented, Jul 31, 2021

Just realized it might also be possible to use the ReadOnlySequence<byte>, will need to run some experiments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Buffers - .NET
They're primarily used to support PipeReader objects. IBufferWriter<T>. System.Buffers.IBufferWriter<T> is a contract for synchronous buffered ...
Read more >
How to make the fastest .NET Serializer with .NET 7 / C# 11 ...
I have been working on AOT support with code generators using Roslyn ... note: serialize parameter should be `ref readonly` but current lang ......
Read more >
Class BufferHelpers | .NEXT
Concat(IBufferWriter<char>, scoped ReadOnlySpan<string?>) ... Converts two memory blocks to ReadOnlySequence<T> data type. ... The value to add.
Read more >
My mental model of Span, Memory and ReadOnlySequence ...
After working a bit with Span , Memory , ReadOnlySequence and IBufferWriter I model it in my head in a bit different way....
Read more >
PooledGrowableBufferHelper 1.0.14
Implements IBufferWriter<byte> interface, which can be used to append data to the end of the stream. Provides a ReadOnlySequence<byte> view ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found