PixelHolder Struct
Definition
An owned, immutable decoded-pixel buffer together with the descriptor needed to interpret it. Mirrors the shape of Avalonia.Platform.ILockedFramebuffer (Avalonia.Controls.Documents.Imaging.PixelHolder.Size, Avalonia.Controls.Documents.Imaging.PixelHolder.Stride, Avalonia.Controls.Documents.Imaging.PixelHolder.Dpi, Avalonia.Controls.Documents.Imaging.PixelHolder.Format) and additionally records the Avalonia.Controls.Documents.Imaging.PixelHolder.AlphaFormat, which the framebuffer interface omits.
public struct 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
| Name | Description |
|---|---|
| PixelHolder | Initializes 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
| Name | Description |
|---|---|
| Equals (2 overloads) | Determines whether this holder and other wrap the same pixel buffer with the same descriptor. Buffer identity is by reference. |
| GetHashCode | No summary available. |
| Lock | 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. |
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
| Name | Description |
|---|---|
| AlphaFormat | Whether the alpha channel is premultiplied, straight, or absent. |
| Dpi | The intended resolution, in dots per inch. |
| Format | The pixel format describing the byte layout. |
| IsEmpty | when this holder carries no pixels. |
| Pixels | The decoded pixel bytes, row-major with Avalonia.Controls.Documents.Imaging.PixelHolder.Stride bytes per row. |
| Size | The pixel dimensions. |
| Stride | The 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; }