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.

[API Proposal] System.Drawing.Drawing2D.GraphicsPathIterator.CopyData spanify

See original GitHub issue

Background and motivation

When converting graphicsPaths I’m iterating over a lot of subpaths.

for (int i = ...
{
// ...
                   var subPathPoints = new GDIP.PointF[cnt];
                    var subPathTypes = new byte[cnt];
                    pathIterator.CopyData(ref subPathPoints, ref subPathTypes, startIndexSubPath, endIndexSubPath);
 } 

I’d like rent the subPathPoints and subPathTypes from an ArrayPool. Because the arraypool would give me larger arrays, I should need to use Spans and slice them to the actual size.

original question: Can a CopyData overload using Spans be added?

API Proposal

Something like this, I’ll let the experts decide the best method parameters/overloads and datatypes

namespace System.Drawing.Drawing2D {

  public class GraphicsPathIterator 
  {
     public int CopyData (Span<System.Drawing.PointF> points, Span<byte types, int startIndex, int endIndex);

  }
}

API Usage

for (int i = ...
{
// ...
                    pathIterator.CopyData(Span<PointF> subPathPoints, Span<byte> subPathTypes, startIndexSubPath, endIndexSubPath);
 } 

Alternative Designs

I’ll let the experts decide the best method parameters/overloads and datatypes

Risks

None

Will this feature affect UI controls

  • No, not that I’m aware of.

Only impact is performanceboost and less allocations! 😄

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
carlossanlopcommented, Apr 7, 2023

System.Drawing now lives in the dotnet/winforms repo. Transferring this issue there.

1reaction
wstaelenscommented, Apr 11, 2023

Updated the template. Thanks for pointing out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[API Proposal] System.Drawing.Drawing2D. ...
I'd like rent the subPathPoints and subPathTypes from an ArrayPool. Because the arraypool would give me larger arrays, I should need to use ......
Read more >
GraphicsPathIterator.CopyData(PointF[], Byte[], Int32 ...
Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.
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