Table of Contents

Class GDIPlusExtensions

Namespace
OFT.Rendering.Context.GDIPlus
Assembly
OFT.Rendering.dll

Conversions between the backend-neutral drawing tools (RenderPen, RenderFont, RenderStringFormat) and the System.Drawing (GDI+) objects. In ATAS X builds the pen and font conversions use the cross-platform UniversalPen and UniversalFont types instead of Pen and Font.

public static class GDIPlusExtensions
Inheritance
object
GDIPlusExtensions

Methods

ToBrush(Color)

Returns a GDI+ solid brush of color. For the known colors Color.White and Color.Black it returns the shared system brushes, which must not be disposed; for other colors it creates a new brush that the caller owns.

public static SolidBrush ToBrush(this Color color)

Parameters

color Color

Brush color.

Returns

SolidBrush

The brush.

ToGDIPlus(RenderFont?, double)

Creates a GDI+ font with the family, style and unit of font and its size multiplied by dpiY. The caller owns and disposes the result.

Added in ATAS 8.0.15.

public static Font? ToGDIPlus(this RenderFont? font, double dpiY = 1)

Parameters

font RenderFont

Font to convert, can be null.

dpiY double

Vertical DPI scale applied to the size, 1.0 for 96 DPI.

Returns

Font

The new GDI+ font, or null when font is null.

ToGDIPlus(RenderStringFormat?)

Creates a GDI+ string format with the alignment, line alignment, format flags and trimming of stringFormat. The caller owns and disposes the result.

Added in ATAS 8.0.15.

public static StringFormat? ToGDIPlus(this RenderStringFormat? stringFormat)

Parameters

stringFormat RenderStringFormat

Format to convert, can be null.

Returns

StringFormat

The new GDI+ format, or null when stringFormat is null.

ToPen(RenderPen, float)

Creates a GDI+ pen from renderPen. Width and arrow cap sizes are multiplied by scale; the line join is MiterClipped. The caller owns and disposes the result.

Added in ATAS 8.0.15.

public static Pen ToPen(this RenderPen renderPen, float scale = 1)

Parameters

renderPen RenderPen

Pen to convert.

scale float

Scale factor for the width and cap sizes.

Returns

Pen

The new pen.

Exceptions

ArgumentNullException

renderPen is null.

ArgumentException

The dash pattern of renderPen is rejected by GDI+; the error is logged before rethrowing.

ToRender(Font?, double)

Converts a GDI+ font to a RenderFont with the same family name, size, style, unit and character set.

Added in ATAS 8.0.15.

public static RenderFont? ToRender(this Font? font, double dpiY = 1)

Parameters

font Font

Font to convert, can be null.

dpiY double

Ignored; the size is not scaled.

Returns

RenderFont

The new render font, or null when font is null.

ToRender(Pen?)

Converts a GDI+ pen to a RenderPen: color, width, dash style, a custom dash pattern and adjustable arrow caps.

Added in ATAS 8.0.15.

public static RenderPen? ToRender(this Pen? pen)

Parameters

pen Pen

Pen to convert, can be null.

Returns

RenderPen

The new render pen, or null when pen is null.

ToRender(StringFormat?)

Converts a GDI+ string format to a RenderStringFormat with the same alignment, line alignment, format flags and trimming.

Added in ATAS 8.0.15.

public static RenderStringFormat? ToRender(this StringFormat? stringFormat)

Parameters

stringFormat StringFormat

Format to convert, can be null.

Returns

RenderStringFormat

The new render format, or null when stringFormat is null.