API Reference · Capturing a frame

CapturedFrame

Namespace: Ava3D

public sealed class CapturedFrame

One frame of an Ava3DView, read back into memory. See Ava3DView.CaptureAsync.

Properties

MemberDescription
Rendering.CameraSnapshot Camera { get; }

The camera the frame was drawn from.

CaptureFormat Format { get; }

What CapturedFrame.Pixels holds.

long FrameId { get; }

Which frame this is: the number the view's FrameTrace gives the same frame, so a capture can be lined up with the trace's record of it. Frames are counted from one for the life of the view's renderer, rendered and reused alike.

ReadOnlyMemory<byte> Pixels { get; }

The pixels, in CapturedFrame.Format: straight alpha, rows top to bottom, tightly packed — four bytes a pixel for CaptureFormat.Rgba8, eight for CaptureFormat.RgbaF16; for CaptureFormat.Png the encoded file. Empty once disposed.

PixelSize Size { get; }

The picture's size in pixels.

Methods

MemberDescription
void Dispose()

Lets go of the pixels. The frame's metadata stays readable.

Threading.Tasks.Task SaveAsync(string path, Threading.CancellationToken cancellationToken = default)

Writes the frame to path as a PNG. Encoding and the write both happen on the thread pool, never on the thread that called this and never on the render thread.

Imaging.Bitmap ToBitmap()

The frame as an Avalonia bitmap, for showing in an Image or drawing into a DrawingContext. A copy: the bitmap is the caller's to dispose. A CaptureFormat.RgbaF16 frame is clamped and gamma-encoded for it, with no tone map — the picture will not match the screen, which is what the format was asked for.

See also