Skip to main content

DeferredImageSource Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

A Avalonia.Controls.Documents.RichImageSource backed by an asynchronous resolver — typically a URL fetched by a loader. The image is produced only when presented and off the UI thread; the document carries a Avalonia.Controls.Documents.DeferredImageSource.SourceUri reference rather than embedded bytes.

public class DeferredImageSource

Inheritance: object -> RichImageSource -> DeferredImageSource

Constructors​

NameDescription
DeferredImageSourceNo summary available.

DeferredImageSource Constructor​

public DeferredImageSource(Func<System.Threading.Tasks.Task<Avalonia.Media.IImage>> resolver, string sourceUri, string mimeType)

Parameters​

resolver Func<System.Threading.Tasks.Task<Avalonia.Media.IImage>>

sourceUri string

mimeType string

Methods​

NameDescription
ResolveAsyncResolves the decoded image. Embedded sources complete synchronously; deferred sources fetch/decode in the background. Returns when the image cannot be produced. Callers must not dispose the returned image — its lifetime is owned by the source (or its loader); a source that owns a decoded bitmap implements IDisposable.
TryGetIntrinsicPixelSizeInherited from RichImageSource.
TryGetPixelsInherited from RichImageSource.

ResolveAsync Method​

Resolves the decoded image. Embedded sources complete synchronously; deferred sources fetch/decode in the background. Returns when the image cannot be produced. Callers must not dispose the returned image — its lifetime is owned by the source (or its loader); a source that owns a decoded bitmap implements IDisposable.

public System.Threading.Tasks.Task<Avalonia.Media.IImage> ResolveAsync()

Returns​

System.Threading.Tasks.Task<Avalonia.Media.IImage>

Properties​

NameDescription
EncodedBytesThe encoded image bytes when the payload is embedded in the document, or an empty buffer for reference (URI) sources. Serializers that embed pixel data read this. Inherited from RichImageSource.
MimeTypeThe MIME type of Avalonia.Controls.Documents.RichImageSource.EncodedBytes, when known.
SourceUriThe reference URI for a deferred/linked source (e.g. an image URL), or for an embedded source.

MimeType Property​

The MIME type of Avalonia.Controls.Documents.RichImageSource.EncodedBytes, when known.

public string MimeType { get; set; }

SourceUri Property​

The reference URI for a deferred/linked source (e.g. an image URL), or for an embedded source.

public string SourceUri { get; set; }