ImageSource class
Backend-agnostic image source created from encoded image bytes (PNG, JPEG, BMP) or pre-decoded BGRA32 pixels.
public sealed class ImageSource : IDisposable, IOrientedImageSourcePublic Members
Section titled “Public Members”| name | description |
|---|---|
| static FromBgraPixels(…) | Wraps a pre-decoded BGRA32 array without copying it; the caller must not mutate the array afterwards. (3 methods) |
| static FromBytes(…) | Creates an ImageSource from encoded image bytes. |
| static FromFile(…) | Loads an ImageSource from a file path. |
| static FromResource(…) | Loads an embedded resource from the specified assembly; throws FileNotFoundException when the resource does not exist. |
| static FromResource<TAnchor>(…) | Loads an embedded resource using an anchor type’s assembly (recommended for AOT). |
| FormatId { get; } | Gets the format id detected by registered decoders, or null when unknown; for diagnostics only. |
| HasAlpha { get; } | Gets whether the source carries a meaningful alpha channel. |
| Orientation { get; } | Gets the orientation parsed from the source metadata without decoding pixels; Identity for raw-pixel sources and formats without orientation metadata. |
| PixelHeight { get; } | Gets the intrinsic pixel height, read from metadata without decoding when the format supports it; 0 when unavailable. |
| PixelWidth { get; } | Gets the intrinsic pixel width, read from metadata without decoding when the format supports it; 0 when unavailable. |
| CopyPixels(…) | Copies the decoded pixels into destination in BGRA32 order with the given stride, decoding first when needed. |
| CreateImage(…) | Creates a backend image for rendering. (2 methods) |
| Dispose() | Releases decoded pixels and retires cached backend realizations owned by this source. |
| EnsureDecode() | Decodes the pixels at intrinsic size when they are not already resident. |
| EnsureDecode(…) | Decodes the pixels for a known device-pixel footprint, never exceeding the intrinsic size. |
| static TryFromResource(…) | Attempts to load an embedded resource from the specified assembly. |
| static TryFromResource<TAnchor>(…) | Attempts to load an embedded resource using an anchor type’s assembly (recommended for AOT). |
Remarks
Section titled “Remarks”For built-in backends, decoded pixels are shared and cached so rendering and pixel sampling (TryPeekColor) reuse a single buffer. After a successful decode the encoded bytes are released once the full intrinsic variant is resident; target-sized variants retain their backing so a later, larger request can replace them. Sources created from raw pixels skip the decoder path entirely.
See Also
Section titled “See Also”- interface IOrientedImageSource
- namespace Aprillz.MewUI