Skip to main content

ImageSnapshotNode Class

Definition​

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

Snapshot node for images. Contains image data and metadata. Can be used in both inline and block contexts.

public class ImageSnapshotNode

Inheritance: object -> SnapshotNode -> ImageSnapshotNode

Methods​

NameDescription
ChildrenOfKindEnumerates child nodes matching a specific kind. Inherited from SnapshotNode.
EnumerateDescendantsEnumerates this node and all descendants in pre-order (depth-first). Inherited from SnapshotNode.
GetFormatMetadataInherited from SnapshotNode.
SetFormatMetadataInherited from SnapshotNode.

Properties​

NameDescription
AltTextAlternative text describing the image, or when none was provided.
ChildrenChild nodes. Empty array for leaf nodes. Inherited from SnapshotNode.
CustomDataExtension-specific custom data for custom node kinds. Used by the builder path (Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder) to propagate custom data from serializer importers to snapshot nodes. Must be immutable or thread-safe for background serialization. Inherited from SnapshotNode.
EndOffsetGets the absolute end offset (exclusive). Inherited from SnapshotNode.
FormatMetadataFormat-specific metadata for round-trip fidelity. Serializers (RtfWriter, DocxWriter, etc.) can attach format-specific state here to preserve information that doesn't map cleanly to the semantic snapshot model. Not thread-safe; single-threaded access only. Inherited from SnapshotNode.
HeightDisplay height of the image in device-independent pixels.
ImageDataImage data bytes.
ImageMimeTypeMIME type of the image (e.g., "image/png", "image/jpeg").
IsBlockGets whether this is a block-level node. Inherited from SnapshotNode.
IsInlineGets whether this is an inline-level node. Inherited from SnapshotNode.
IsLeafGets whether this is a leaf node (no children). Inherited from SnapshotNode.
IsTextRunGets whether this node represents a text run with actual content. Inherited from SnapshotNode.
KindThe kind of document element this node represents. Inherited from SnapshotNode.
LengthLength of this node's content in characters. Inherited from SnapshotNode.
PixelsThe decoded pixels for a pixels-only image (one with no encoded bytes and no URI), or an empty holder otherwise. Serializers re-encode this to a supported format. Immutable and thread-safe.
SourceUriThe reference URI for a deferred/linked image (e.g. a Markdown image URL), or for an embedded-byte image. When set, Avalonia.Controls.Documents.Serialization.Snapshot.ImageSnapshotNode.ImageData is typically empty — the pixels are resolved at render time by a loader rather than carried in the document.
StartOffsetAbsolute offset in the document text where this node starts. Inherited from SnapshotNode.
TextElementFormattingBase-level formatting from Avalonia.Controls.Documents.RichTextElement. Carries font, foreground, background, and letter-spacing for every node type. Inherited from SnapshotNode.
WidthDisplay width of the image in device-independent pixels.

AltText Property​

Alternative text describing the image, or when none was provided.

public string AltText { get; set; }

Height Property​

Display height of the image in device-independent pixels.

public double Height { get; set; }

ImageData Property​

Image data bytes.

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

ImageMimeType Property​

MIME type of the image (e.g., "image/png", "image/jpeg").

public string ImageMimeType { get; set; }

Pixels Property​

The decoded pixels for a pixels-only image (one with no encoded bytes and no URI), or an empty holder otherwise. Serializers re-encode this to a supported format. Immutable and thread-safe.

public Avalonia.Controls.Documents.Imaging.PixelHolder Pixels { get; set; }

SourceUri Property​

The reference URI for a deferred/linked image (e.g. a Markdown image URL), or for an embedded-byte image. When set, Avalonia.Controls.Documents.Serialization.Snapshot.ImageSnapshotNode.ImageData is typically empty — the pixels are resolved at render time by a loader rather than carried in the document.

public string SourceUri { get; set; }

Width Property​

Display width of the image in device-independent pixels.

public double Width { get; set; }