-
-
Notifications
You must be signed in to change notification settings - Fork 889
Closed
Description
Problems
We have two, somewhat related issues to address:
AdvancedImageExtensions.GetPixelSpanis now obsolete, and there is no convenient way to get a single pixel span for memory interop use-cases- Keeping the pixel span methods in
AdvancedImageExtensionsleads to poor discoverability. With all the Roslyn analyzers we have today, to detectSpan<T>misuse, I no longer consider them unsafe or "advanced". I suggest to make them instance members onImage<TPixel>andImageFrame<TPixel>. Note: this does not apply forMemory<T>orIMemoryGroup<T>stuff, since persisting heap-references to the pixel memory has some nontrivial consequences.
Proposal
Redifine Span<TPixel> methods as following:
public class Image<TPixel>
{
public bool TryGetSinglePixelSpan(out Span<TPixel> pixelSpan);
public Span<TPixel> GetPixelRowSpan(int rowIndex);
}
public class ImageFrame<TPixel>
{
public bool TryGetSinglePixelSpan(out Span<TPixel> span);
public Span<TPixel> GetPixelRowSpan(int rowIndex);
}Update: Fixed copy/paste errors in the proposal.
JimBobSquarePants and MaikuMorisaucecontrol