Table of Contents

Class AvaloniaControlCapture

Namespace
EncDotNet.S100.Renderers.Mapsui.Avalonia
Assembly
EncDotNet.S100.Renderers.Mapsui.Avalonia.dll

Captures an Avalonia control as PNG bytes while coordinating with live Mapsui painting.

public static class AvaloniaControlCapture
Inheritance
AvaloniaControlCapture
Inherited Members

Methods

CapturePngAsync(Control, double, CancellationToken)

Renders target to PNG-encoded bytes on Avalonia's UI thread at scale device pixels per logical pixel.

public static Task<byte[]?> CapturePngAsync(Control target, double scale, CancellationToken cancellationToken = default)

Parameters

target Control

The control to capture.

scale double

Device pixels per logical pixel: 1 renders at 96 dpi, 2 matches a Retina / HiDPI display.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<byte[]>

PNG bytes, or null when the target has no positive laid-out size.

Exceptions

ArgumentNullException

target is null.

ArgumentOutOfRangeException

scale is not a positive, finite number.

OperationCanceledException

cancellationToken is canceled.

InvalidOperationException

The target contains a Mapsui control that does not derive from CaptureSynchronizedMapControl.

CapturePngAsync(Control, CancellationToken)

Renders target to PNG-encoded bytes on Avalonia's UI thread.

public static Task<byte[]?> CapturePngAsync(Control target, CancellationToken cancellationToken = default)

Parameters

target Control

The control to capture.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<byte[]>

PNG bytes, or null when the target has no positive laid-out size.

Exceptions

ArgumentNullException

target is null.

OperationCanceledException

cancellationToken is canceled.

InvalidOperationException

The target contains a Mapsui control that does not derive from CaptureSynchronizedMapControl.