Table of Contents

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

int

PixelWidth

Width in pixels.

public int PixelWidth { get; }

Property Value

int

Pixels

Premultiplied BGRA pixels, row-major, stride = 4 × width.

public ReadOnlySpan<byte> Pixels { get; }

Property Value

ReadOnlySpan<byte>

PixelsPerDip

Image density (pixels per DIP).

public float PixelsPerDip { get; }

Property Value

float

Size

Natural size in DIPs.

public Size Size { get; }

Property Value

Size

Methods

FromBytes(byte[], float)

Decodes an encoded image (any WIC-supported format).

public static ImageSource FromBytes(byte[] encoded, float pixelsPerDip = 1)

Parameters

encoded byte[]
pixelsPerDip float

Returns

ImageSource

FromFile(string, float)

Decodes an image file.

public static ImageSource FromFile(string path, float pixelsPerDip = 1)

Parameters

path string
pixelsPerDip float

Returns

ImageSource

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

width int
height int
premultipliedBgra ReadOnlySpan<byte>
pixelsPerDip float

Returns

ImageSource

FromResource(Assembly, string, float)

Decodes an embedded resource of assembly.

public static ImageSource FromResource(Assembly assembly, string resourceName, float pixelsPerDip = 1)

Parameters

assembly Assembly
resourceName string
pixelsPerDip float

Returns

ImageSource

FromStream(Stream, float)

Decodes an image stream.

public static ImageSource FromStream(Stream stream, float pixelsPerDip = 1)

Parameters

stream Stream
pixelsPerDip float

Returns

ImageSource