Table of Contents

Interface IPlatformRenderInterface

Namespace
Avalonia.Platform
Assembly
Avalonia.Base.dll

Defines the main platform-specific interface for the rendering subsystem.

[Unstable]
[PrivateApi]
public interface IPlatformRenderInterface

Properties

DefaultAlphaFormat

Default AlphaFormat used on this platform.

AlphaFormat DefaultAlphaFormat { get; }

Property Value

AlphaFormat

DefaultPixelFormat

Default PixelFormat used on this platform.

PixelFormat DefaultPixelFormat { get; }

Property Value

PixelFormat

SupportsIndividualRoundRects

Gets a value indicating whether the platform directly supports rectangles with rounded corners.

bool SupportsIndividualRoundRects { get; }

Property Value

bool

Remarks

Some platform renderers can't directly handle rounded corners on rectangles. In this case, code that requires rounded corners must generate and retain a geometry instead.

SupportsRegions

bool SupportsRegions { get; }

Property Value

bool

Methods

BuildGlyphRunGeometry(GlyphRun)

Created a geometry implementation for the glyph run.

IGeometryImpl BuildGlyphRunGeometry(GlyphRun glyphRun)

Parameters

glyphRun GlyphRun

The glyph run to build a geometry from.

Returns

IGeometryImpl

The geometry returned contains the combined geometry of all glyphs in the glyph run.

CreateBackendContext(IPlatformGraphicsContext?)

Creates a backend-specific object using a low-level API graphics context

IPlatformRenderInterfaceContext CreateBackendContext(IPlatformGraphicsContext? graphicsApiContext)

Parameters

graphicsApiContext IPlatformGraphicsContext

An underlying low-level graphics context (e. g. wrapped OpenGL context, Vulkan device, D3DDevice, etc)

Returns

IPlatformRenderInterfaceContext

CreateCombinedGeometry(GeometryCombineMode, IGeometryImpl, IGeometryImpl)

Creates a geometry group implementation.

IGeometryImpl CreateCombinedGeometry(GeometryCombineMode combineMode, IGeometryImpl g1, IGeometryImpl g2)

Parameters

combineMode GeometryCombineMode

The combine mode

g1 IGeometryImpl

The first geometry.

g2 IGeometryImpl

The second geometry.

Returns

IGeometryImpl

A combined geometry.

CreateEllipseGeometry(Rect)

Creates an ellipse geometry implementation.

IGeometryImpl CreateEllipseGeometry(Rect rect)

Parameters

rect Rect

The bounds of the ellipse.

Returns

IGeometryImpl

An ellipse geometry.

CreateGeometryGroup(FillRule, IReadOnlyList<IGeometryImpl>)

Creates a geometry group implementation.

IGeometryImpl CreateGeometryGroup(FillRule fillRule, IReadOnlyList<IGeometryImpl> children)

Parameters

fillRule FillRule

The fill rule.

children IReadOnlyList<IGeometryImpl>

The geometries to group.

Returns

IGeometryImpl

A combined geometry.

CreateGlyphRun(IGlyphTypeface, double, IReadOnlyList<GlyphInfo>, Point)

Creates a platform implementation of a glyph run.

IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList<GlyphInfo> glyphInfos, Point baselineOrigin)

Parameters

glyphTypeface IGlyphTypeface

The glyph typeface.

fontRenderingEmSize double

The font rendering em size.

glyphInfos IReadOnlyList<GlyphInfo>

The list of glyphs.

baselineOrigin Point

The baseline origin of the run. Can be null.

Returns

IGlyphRunImpl

An IGlyphRunImpl.

CreateLineGeometry(Point, Point)

Creates a line geometry implementation.

IGeometryImpl CreateLineGeometry(Point p1, Point p2)

Parameters

p1 Point

The start of the line.

p2 Point

The end of the line.

Returns

IGeometryImpl

A line geometry.

CreateRectangleGeometry(Rect)

Creates a rectangle geometry implementation.

IGeometryImpl CreateRectangleGeometry(Rect rect)

Parameters

rect Rect

The bounds of the rectangle.

Returns

IGeometryImpl

A rectangle.

CreateRegion()

IPlatformRenderInterfaceRegion CreateRegion()

Returns

IPlatformRenderInterfaceRegion

CreateRenderTargetBitmap(PixelSize, Vector)

Creates a render target bitmap implementation.

IRenderTargetBitmapImpl CreateRenderTargetBitmap(PixelSize size, Vector dpi)

Parameters

size PixelSize

The size of the bitmap in device pixels.

dpi Vector

The DPI of the bitmap.

Returns

IRenderTargetBitmapImpl

An IRenderTargetBitmapImpl.

CreateStreamGeometry()

Creates a stream geometry implementation.

IStreamGeometryImpl CreateStreamGeometry()

Returns

IStreamGeometryImpl

An IStreamGeometryImpl.

CreateWriteableBitmap(PixelSize, Vector, PixelFormat, AlphaFormat)

Creates a writeable bitmap implementation.

IWriteableBitmapImpl CreateWriteableBitmap(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat)

Parameters

size PixelSize

The size of the bitmap in device pixels.

dpi Vector

The DPI of the bitmap.

format PixelFormat

Pixel format.

alphaFormat AlphaFormat

Alpha format .

Returns

IWriteableBitmapImpl

An IWriteableBitmapImpl.

IsSupportedBitmapPixelFormat(PixelFormat)

bool IsSupportedBitmapPixelFormat(PixelFormat format)

Parameters

format PixelFormat

Returns

bool

LoadBitmap(PixelFormat, AlphaFormat, nint, PixelSize, Vector, int)

Loads a bitmap implementation from a pixels in memory.

IBitmapImpl LoadBitmap(PixelFormat format, AlphaFormat alphaFormat, nint data, PixelSize size, Vector dpi, int stride)

Parameters

format PixelFormat

The pixel format.

alphaFormat AlphaFormat

The alpha format.

data nint

The pointer to source bytes.

size PixelSize

The size of the bitmap in device pixels.

dpi Vector

The DPI of the bitmap.

stride int

The number of bytes per row.

Returns

IBitmapImpl

An IBitmapImpl.

LoadBitmap(Stream)

Loads a bitmap implementation from a file..

IBitmapImpl LoadBitmap(Stream stream)

Parameters

stream Stream

The stream to read the bitmap from.

Returns

IBitmapImpl

An IBitmapImpl.

LoadBitmap(string)

Loads a bitmap implementation from a file..

IBitmapImpl LoadBitmap(string fileName)

Parameters

fileName string

The filename of the bitmap.

Returns

IBitmapImpl

An IBitmapImpl.

LoadBitmapToHeight(Stream, int, BitmapInterpolationMode)

Loads a bitmap implementation from a stream to a specified height maintaining aspect ratio.

IBitmapImpl LoadBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)

Parameters

stream Stream

The stream to read the bitmap from.

height int

The desired height of the resulting bitmap.

interpolationMode BitmapInterpolationMode

The BitmapInterpolationMode to use should resizing be required.

Returns

IBitmapImpl

An IBitmapImpl.

LoadBitmapToWidth(Stream, int, BitmapInterpolationMode)

Loads a bitmap implementation from a stream to a specified width maintaining aspect ratio.

IBitmapImpl LoadBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)

Parameters

stream Stream

The stream to read the bitmap from.

width int

The desired width of the resulting bitmap.

interpolationMode BitmapInterpolationMode

The BitmapInterpolationMode to use should resizing be required.

Returns

IBitmapImpl

An IBitmapImpl.

LoadWriteableBitmap(Stream)

Loads a WriteableBitmap implementation from a file.

IWriteableBitmapImpl LoadWriteableBitmap(Stream stream)

Parameters

stream Stream

The stream to read the bitmap from.

Returns

IWriteableBitmapImpl

An IBitmapImpl.

LoadWriteableBitmap(string)

Loads a WriteableBitmap implementation from a file.

IWriteableBitmapImpl LoadWriteableBitmap(string fileName)

Parameters

fileName string

The filename of the bitmap.

Returns

IWriteableBitmapImpl

An IBitmapImpl.

LoadWriteableBitmapToHeight(Stream, int, BitmapInterpolationMode)

Loads a WriteableBitmap implementation from a stream to a specified height maintaining aspect ratio.

IWriteableBitmapImpl LoadWriteableBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)

Parameters

stream Stream

The stream to read the bitmap from.

height int

The desired height of the resulting bitmap.

interpolationMode BitmapInterpolationMode

The BitmapInterpolationMode to use should resizing be required.

Returns

IWriteableBitmapImpl

An IBitmapImpl.

LoadWriteableBitmapToWidth(Stream, int, BitmapInterpolationMode)

Loads a WriteableBitmap implementation from a stream to a specified width maintaining aspect ratio.

IWriteableBitmapImpl LoadWriteableBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)

Parameters

stream Stream

The stream to read the bitmap from.

width int

The desired width of the resulting bitmap.

interpolationMode BitmapInterpolationMode

The BitmapInterpolationMode to use should resizing be required.

Returns

IWriteableBitmapImpl

An IWriteableBitmapImpl.

ResizeBitmap(IBitmapImpl, PixelSize, BitmapInterpolationMode)

IBitmapImpl ResizeBitmap(IBitmapImpl bitmapImpl, PixelSize destinationSize, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)

Parameters

bitmapImpl IBitmapImpl
destinationSize PixelSize
interpolationMode BitmapInterpolationMode

Returns

IBitmapImpl