PixelImageSource Class
Definition
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
Constructors
| Name | Description |
|---|---|
| PixelImageSource | Initializes 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
| Name | Description |
|---|---|
| Dispose | Releases the cached render bitmap. |
| ResolveAsync | 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. |
| TryGetIntrinsicPixelSize | No summary available. |
| TryGetPixels | No 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
| Name | Description |
|---|---|
| EncodedBytes | 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. Inherited from RichImageSource. |
| MimeType | The MIME type of Avalonia.Controls.Documents.RichImageSource.EncodedBytes, when known. Inherited from RichImageSource. |
| SourceUri | The reference URI for a deferred/linked source (e.g. an image URL), or for an embedded source. Inherited from RichImageSource. |