Skip to main content

EmbeddedImageSource Class

Definition​

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

A Avalonia.Controls.Documents.RichImageSource whose encoded pixel bytes are embedded in the document. Decodes once from the retained bytes, caches and owns the decoded bitmap, and reports the intrinsic size from the image header without a full decode. Dispose to release the cached bitmap.

public class EmbeddedImageSource

Inheritance: object -> RichImageSource -> EmbeddedImageSource

Implements: IDisposable

Constructors​

NameDescription
EmbeddedImageSourceNo summary available.

EmbeddedImageSource Constructor​

public EmbeddedImageSource(ReadOnlyMemory<byte> data, string mimeType)

Parameters​

data ReadOnlyMemory<byte>

mimeType string

Methods​

NameDescription
DisposeReleases the cached decoded bitmap. Subsequent Avalonia.Controls.Documents.EmbeddedImageSource.ResolveAsync calls return .
ResolveAsyncResolves the decoded image, decoding once and caching the result. The returned bitmap is owned by this source and released by Avalonia.Controls.Documents.EmbeddedImageSource.Dispose; callers must not dispose it. Returns once disposed or when the payload cannot be decoded.
TryGetIntrinsicPixelSizeNo summary available.
TryGetPixelsInherited from RichImageSource.

Dispose Method​

Releases the cached decoded bitmap. Subsequent Avalonia.Controls.Documents.EmbeddedImageSource.ResolveAsync calls return .

public void Dispose()

ResolveAsync Method​

Resolves the decoded image, decoding once and caching the result. The returned bitmap is owned by this source and released by Avalonia.Controls.Documents.EmbeddedImageSource.Dispose; callers must not dispose it. Returns once disposed or when the payload cannot be decoded.

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

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. Inherited from RichImageSource.

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