Skip to main content

PixelImageSource Class

Definition​

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

A Avalonia.Controls.Documents.RichImageSource backed only by decoded pixels (a Avalonia.Controls.Documents.Imaging.PixelHolder), with no encoded payload — for images created from raw pixels in code (e.g. a WriteableBitmap). Capture carries the pixel buffer into the snapshot, and serializers re-encode it to a supported format. Renders by building a bitmap from the pixels, which this source owns and disposes.

public class PixelImageSource

Inheritance: object -> RichImageSource -> PixelImageSource

Implements: IDisposable

Constructors​

NameDescription
PixelImageSourceInitializes a new Avalonia.Controls.Documents.PixelImageSource from a pixel buffer.

PixelImageSource Constructor​

Initializes a new Avalonia.Controls.Documents.PixelImageSource from a pixel buffer.

public PixelImageSource(Avalonia.Controls.Documents.Imaging.PixelHolder pixels)

Parameters​

pixels Avalonia.Controls.Documents.Imaging.PixelHolder

The decoded pixels. Owned for rendering, carried into snapshots for serialization.

Methods​

NameDescription
DisposeReleases the cached render bitmap.
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.

Dispose Method​

Releases the cached render bitmap.

public void Dispose()

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. Inherited from RichImageSource.
MimeTypeThe MIME type of Avalonia.Controls.Documents.RichImageSource.EncodedBytes, when known. Inherited from RichImageSource.
SourceUriThe reference URI for a deferred/linked source (e.g. an image URL), or for an embedded source. Inherited from RichImageSource.