ImageFrame<TPixel> Class
A borrowed, typed view of one full-canvas displayed frame (or of the poster frame) of an Image<TPixel>.
public sealed class ImageFrame<TPixel> : ImageFrame where TPixel : unmanaged- Inheritance
ImageFrameImageFrame<TPixel>
Properties
| Name | Description |
|---|---|
| PixelFormat | Gets the pixel format (always the image pixel format). |
PixelFormat
ImageFrame{TPixel}.csGets the pixel format (always the image pixel format).
public override PixelFormat PixelFormat { get; }Property value
Indexers
| Name | Description |
|---|---|
| this[int, int] | Gets or sets a single pixel. Prefer ImageFrame<TPixel>.ProcessPixelRows for bulk access. |
this[int, int]
ImageFrame{TPixel}.csGets or sets a single pixel. Prefer ImageFrame<TPixel>.ProcessPixelRows for bulk access.
Parameters
Property value
TPixel
Exceptions
ArgumentOutOfRangeException- A coordinate is out of range.
InvalidOperationException- A conflicting lease is active.
ObjectDisposedException- The frame is no longer attached to a live image.
Methods
| Name | Description |
|---|---|
| CopyPixelDataTo(Span<TPixel>, int) | Copies the visible pixels to a caller buffer. Elements between rows (stride padding) are left untouched. |
| ProcessPixelRows(PixelRowsAction<TPixel>) | Gives scoped read/write access to the visible pixels, row by row. |
| ProcessPixelRows<TState>(TState, PixelRowsAction<TPixel, TState>) | Gives scoped read/write access to the visible pixels, passing caller state to avoid closure allocations. |
CopyPixelDataTo(Span<TPixel>, int)
ImageFrame{TPixel}.csCopies the visible pixels to a caller buffer. Elements between rows (stride padding) are left untouched.
Parameters
destinationSpan<TPixel>- The destination buffer.
strideInPixelsint- The distance between the starts of two consecutive destination rows, in pixels, or 0 for tightly packed rows. Must be 0 or at least
Width.
Exceptions
ArgumentOutOfRangeExceptionstrideInPixelsis invalid.ArgumentExceptiondestinationis too short (the last row only needsWidthpixels).InvalidOperationException- A conflicting lease is active.
ObjectDisposedException- The frame is no longer attached to a live image.
ProcessPixelRows overloads
ProcessPixelRows(PixelRowsAction<TPixel>)
ImageFrame{TPixel}.csGives scoped read/write access to the visible pixels, row by row.
public void ProcessPixelRows(PixelRowsAction<TPixel> action)Parameters
actionPixelRowsAction<TPixel>- The callback. It must not be asynchronous and must not retain the spans.
Exceptions
InvalidOperationException- A conflicting lease is active.
ObjectDisposedException- The frame is no longer attached to a live image.
ProcessPixelRows<TState>(TState, PixelRowsAction<TPixel, TState>)
ImageFrame{TPixel}.csGives scoped read/write access to the visible pixels, passing caller state to avoid closure allocations.
public void ProcessPixelRows<TState>(TState state, PixelRowsAction<TPixel, TState> action) where TState : allows ref structType parameters
TState- The type of the state.
Parameters
stateTState- The state passed to
action. actionPixelRowsAction<TPixel, TState>- The callback. Use a static lambda to avoid allocations. It must not retain the spans.
Exceptions
InvalidOperationException- A conflicting lease is active.
ObjectDisposedException- The frame is no longer attached to a live image.