Class ImageSource
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Raster image decoded once (PNG, JPEG, BMP, GIF, TIFF... through WIC) into premultiplied BGRA pixels. Device bitmaps are created lazily by each renderer and rebuilt after a device loss.
public sealed class ImageSource
- Inheritance
-
ImageSource
- Inherited Members
Remarks
PixelsPerDip describes the image density: an image exported at 2× for HiDPI (e.g. "knob@2x.png") should use 2 so that its DIP size matches the 1× design.
Properties
PixelHeight
Height in pixels.
public int PixelHeight { get; }
Property Value
PixelWidth
Width in pixels.
public int PixelWidth { get; }
Property Value
Pixels
Premultiplied BGRA pixels, row-major, stride = 4 × width.
public ReadOnlySpan<byte> Pixels { get; }
Property Value
PixelsPerDip
Image density (pixels per DIP).
public float PixelsPerDip { get; }
Property Value
Size
Natural size in DIPs.
public Size Size { get; }
Property Value
Methods
FromBytes(byte[], float)
Decodes an encoded image (any WIC-supported format).
public static ImageSource FromBytes(byte[] encoded, float pixelsPerDip = 1)
Parameters
Returns
FromFile(string, float)
Decodes an image file.
public static ImageSource FromFile(string path, float pixelsPerDip = 1)
Parameters
Returns
FromPixels(int, int, ReadOnlySpan<byte>, float)
Wraps raw premultiplied BGRA pixels (copied).
public static ImageSource FromPixels(int width, int height, ReadOnlySpan<byte> premultipliedBgra, float pixelsPerDip = 1)
Parameters
widthintheightintpremultipliedBgraReadOnlySpan<byte>pixelsPerDipfloat
Returns
FromResource(Assembly, string, float)
Decodes an embedded resource of assembly.
public static ImageSource FromResource(Assembly assembly, string resourceName, float pixelsPerDip = 1)
Parameters
Returns
FromStream(Stream, float)
Decodes an image stream.
public static ImageSource FromStream(Stream stream, float pixelsPerDip = 1)