/// <summary> /// Return a <see cref="Buffer2DRegion{T}"/> to the subregion represented by 'rectangle' /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <param name="rectangle">The rectangle subregion</param> /// <returns>The <see cref="Buffer2DRegion{T}"/></returns> internal static Buffer2DRegion <T> GetRegion <T>(this Buffer2D <T> buffer, Rectangle rectangle) where T : unmanaged => new Buffer2DRegion <T>(buffer, rectangle);
internal static Buffer2DRegion <T> GetRegion <T>(this Buffer2D <T> buffer, int x, int y, int width, int height) where T : unmanaged => new Buffer2DRegion <T>(buffer, new Rectangle(x, y, width, height));
/// <summary> /// Gets the backing <see cref="IMemoryGroup{T}"/>. /// </summary> /// <param name="buffer">The buffer.</param> /// <typeparam name="T">The element type.</typeparam> /// <returns>The MemoryGroup.</returns> public static IMemoryGroup <T> GetMemoryGroup <T>(this Buffer2D <T> buffer) where T : struct { Guard.NotNull(buffer, nameof(buffer)); return(buffer.FastMemoryGroup.View); }
/// <summary> /// Returns a <see cref="Rectangle"/> representing the full area of the buffer. /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <returns>The <see cref="Rectangle"/></returns> internal static Rectangle FullRectangle <T>(this Buffer2D <T> buffer) where T : struct { return(new Rectangle(0, 0, buffer.Width, buffer.Height)); }
/// <summary> /// Return a <see cref="Buffer2DRegion{T}"/> to the whole area of 'buffer' /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <returns>The <see cref="Buffer2DRegion{T}"/></returns> internal static Buffer2DRegion <T> GetRegion <T>(this Buffer2D <T> buffer) where T : unmanaged => new Buffer2DRegion <T>(buffer);
/// <summary> /// Returns the size of the buffer. /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <returns>The <see cref="Size{T}"/> of the buffer</returns> internal static Size Size <T>(this Buffer2D <T> buffer) where T : struct { return(new Size(buffer.Width, buffer.Height)); }
public static Memory <T> GetRowMemory <T>(this Buffer2D <T> buffer, int y) where T : struct { Guard.NotNull(buffer, nameof(buffer)); return(buffer.MemorySource.Memory.Slice(y * buffer.Width, buffer.Width)); }
public BufferArea(Buffer2D <T> destinationBuffer) : this(destinationBuffer, destinationBuffer.FullRectangle()) { }
/// <summary> /// Gets the <see cref="Memory{T}"/> holding the backing buffer of <paramref name="buffer"/>. /// </summary> /// <param name="buffer">The <see cref="Buffer2D{T}"/>.</param> /// <typeparam name="T">The value type.</typeparam> /// <returns>The <see cref="Memory{T}"/>.</returns> public static Memory <T> GetMemory <T>(this Buffer2D <T> buffer) where T : struct { Guard.NotNull(buffer, nameof(buffer)); return(buffer.MemorySource.Memory); }
public static Span <T> GetRowSpan <T>(this Buffer2D <T> buffer, int y) where T : struct { Guard.NotNull(buffer, nameof(buffer)); return(buffer.GetSpan().Slice(y * buffer.Width, buffer.Width)); }
/// <summary> /// Gets a span for all the pixels in <paramref name="buffer"/> defined by <paramref name="rows"/> /// </summary> internal static Span <T> GetMultiRowSpan <T>(this Buffer2D <T> buffer, in RowInterval rows)
/// <summary> /// Return a <see cref="BufferArea{T}"/> to the whole area of 'buffer' /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <returns>The <see cref="BufferArea{T}"/></returns> internal static BufferArea <T> GetArea <T>(this Buffer2D <T> buffer) where T : struct => new BufferArea <T>(buffer);
internal static BufferArea <T> GetArea <T>(this Buffer2D <T> buffer, int x, int y, int width, int height) where T : struct => new BufferArea <T>(buffer, new Rectangle(x, y, width, height));
/// <summary> /// Return a <see cref="BufferArea{T}"/> to the subarea represented by 'rectangle' /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="buffer">The <see cref="Buffer2D{T}"/></param> /// <param name="rectangle">The rectangle subarea</param> /// <returns>The <see cref="BufferArea{T}"/></returns> internal static BufferArea <T> GetArea <T>(this Buffer2D <T> buffer, in Rectangle rectangle)
public Buffer2DRegion(Buffer2D <T> buffer) : this(buffer, buffer.FullRectangle()) { }