Skip to main content

RichImageSource Class

Definition​

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

Describes where a Avalonia.Controls.Documents.RichImage's pixels come from and how they are obtained. Embedded sources carry their encoded payload in the document and decode synchronously; deferred sources resolve asynchronously (e.g. from a URL via a loader) and only when the image is actually presented.

public class RichImageSource

Inheritance: object -> RichImageSource

Remarks​

A Avalonia.Controls.Documents.RichImageSourceConverter lets a source be authored in XAML from an absolute URI string, e.g. Source="avares://MyApp/Assets/picture.png".

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.
TryGetIntrinsicPixelSizeNo summary available.
TryGetPixelsNo summary available.

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>

TryGetIntrinsicPixelSize Method​

public bool TryGetIntrinsicPixelSize(int& width, int& height)

Parameters​

width int&

height int&

Returns​

bool

TryGetPixels Method​

public bool TryGetPixels(Avalonia.Controls.Documents.Imaging.PixelHolder& pixels)

Parameters​

pixels Avalonia.Controls.Documents.Imaging.PixelHolder&

Returns​

bool

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.
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.

EncodedBytes Property​

The 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.

public ReadOnlyMemory<byte> EncodedBytes { get; set; }

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; }