Skip to main content

PixelHolder Struct

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents
public struct PixelHolder

Inheritance: ValueType -> PixelHolder

Implements: IEquatable<PixelHolder>

Remarks​

The pixels are plain managed memory: immutable (never mutated after construction), garbage-collected, and free of platform or UI affinity — so a Avalonia.Controls.Documents.Imaging.PixelHolder is safe to carry into a document snapshot and read from a background serializer. Call Avalonia.Controls.Documents.Imaging.PixelHolder.Lock for a transient Avalonia.Platform.ILockedFramebuffer view when handing the pixels to an Avalonia bitmap or an image codec; the holder keeps owning the buffer.

Constructors​

NameDescription
PixelHolderInitializes a new Avalonia.Controls.Documents.Imaging.PixelHolder that takes ownership of pixels.

PixelHolder Constructor​

Initializes a new Avalonia.Controls.Documents.Imaging.PixelHolder that takes ownership of pixels.

public PixelHolder(byte[] pixels, Avalonia.PixelSize size, int stride, Avalonia.Platform.PixelFormat format, Avalonia.Platform.AlphaFormat alphaFormat, Avalonia.Vector dpi)

Parameters​

pixels byte[]

The decoded pixel bytes, row-major. Must not be mutated after this call.

size Avalonia.PixelSize

The pixel dimensions.

stride int

The number of bytes per pixel row.

format Avalonia.Platform.PixelFormat

The pixel format describing the byte layout.

alphaFormat Avalonia.Platform.AlphaFormat

Whether the alpha channel is premultiplied, straight, or absent.

dpi Avalonia.Vector

The intended resolution, in dots per inch.

Methods​

NameDescription
Equals (2 overloads)Determines whether this holder and other wrap the same pixel buffer with the same descriptor. Buffer identity is by reference.
GetHashCodeNo summary available.
LockPins the pixel buffer and returns a transient Avalonia.Platform.ILockedFramebuffer view over it for interop with Avalonia bitmaps or an image codec. Dispose the returned framebuffer to unpin; the pixels remain owned by this holder.

Equals overloads​

Equals Method​

Determines whether this holder and other wrap the same pixel buffer with the same descriptor. Buffer identity is by reference.

public bool Equals(Avalonia.Controls.Documents.Imaging.PixelHolder other)
Parameters​

other Avalonia.Controls.Documents.Imaging.PixelHolder

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

GetHashCode Method​

public int GetHashCode()

Returns​

int

Lock Method​

Pins the pixel buffer and returns a transient Avalonia.Platform.ILockedFramebuffer view over it for interop with Avalonia bitmaps or an image codec. Dispose the returned framebuffer to unpin; the pixels remain owned by this holder.

public Avalonia.Platform.ILockedFramebuffer Lock()

Returns​

Avalonia.Platform.ILockedFramebuffer

Exceptions​

Properties​

NameDescription
AlphaFormatWhether the alpha channel is premultiplied, straight, or absent.
DpiThe intended resolution, in dots per inch.
FormatThe pixel format describing the byte layout.
IsEmptywhen this holder carries no pixels.
PixelsThe decoded pixel bytes, row-major with Avalonia.Controls.Documents.Imaging.PixelHolder.Stride bytes per row.
SizeThe pixel dimensions.
StrideThe number of bytes per pixel row.

AlphaFormat Property​

Whether the alpha channel is premultiplied, straight, or absent.

public Avalonia.Platform.AlphaFormat AlphaFormat { get; set; }

Dpi Property​

The intended resolution, in dots per inch.

public Avalonia.Vector Dpi { get; set; }

Format Property​

The pixel format describing the byte layout.

public Avalonia.Platform.PixelFormat Format { get; set; }

IsEmpty Property​

when this holder carries no pixels.

public bool IsEmpty { get; set; }

Pixels Property​

The decoded pixel bytes, row-major with Avalonia.Controls.Documents.Imaging.PixelHolder.Stride bytes per row.

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

Size Property​

The pixel dimensions.

public Avalonia.PixelSize Size { get; set; }

Stride Property​

The number of bytes per pixel row.

public int Stride { get; set; }