Table of Contents

Class DeviceContext4

Namespace
SharpDX.Direct2D1
Assembly
SharpDX.Direct2D1.dll
[Guid("8c427831-3d90-4476-b647-c4fae349e4db")]
public class DeviceContext4 : DeviceContext3
Inheritance
DeviceContext4
Derived
Inherited Members

Constructors

DeviceContext4(Device4, DeviceContextOptions)

Initializes a new instance of the DeviceContext4 class using an existing Device4.

public DeviceContext4(Device4 device, DeviceContextOptions options)

Parameters

device Device4

The device.

options DeviceContextOptions

The options to be applied to the created device context.

Remarks

The new device context will not have a selected target bitmap. The caller must create and select a bitmap as the target surface of the context.

DeviceContext4(nint)

public DeviceContext4(nint nativePtr)

Parameters

nativePtr nint

Methods

CreateSvgGlyphStyle(out SvgGlyphStyle)

Creates an SVG glyph style object.

public void CreateSvgGlyphStyle(out SvgGlyphStyle svgGlyphStyle)

Parameters

svgGlyphStyle SvgGlyphStyle

On completion points to the created SvgGlyphStyle object.

DrawColorBitmapGlyphRun(GlyphImageFormatS, RawVector2, GlyphRun, MeasuringMode, ColorBitmapGlyphSnapOption)

Draws a color bitmap glyph run using one of the bitmap formats.

public void DrawColorBitmapGlyphRun(GlyphImageFormatS glyphImageFormat, RawVector2 baselineOrigin, GlyphRun glyphRun, MeasuringMode measuringMode, ColorBitmapGlyphSnapOption bitmapSnapOption)

Parameters

glyphImageFormat GlyphImageFormatS

Specifies the format of the glyph image. Supported formats are DWRITE_GLYPH_IMAGE_FORMATS_PNG, DWRITE_GLYPH_IMAGE_FORMATS_JPEG, DWRITE_GLYPH_IMAGE_FORMATS_TIFF, or DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8. This method will result in an error if the color glyph run does not contain the requested format.

Only one format can be specified at a time, combinations of flags are not valid input.

baselineOrigin RawVector2

The origin of the baseline for the glyph run.

glyphRun GlyphRun

The glyphs to render.

measuringMode MeasuringMode

Indicates the measuring method.

bitmapSnapOption ColorBitmapGlyphSnapOption

Specifies the pixel snapping policy when rendering color bitmap glyphs.

DrawSvgGlyphRun(RawVector2, GlyphRun, Brush, SvgGlyphStyle, int, MeasuringMode)

Draws a color glyph run that has the format of DWRITE_GLYPH_IMAGE_FORMATS_SVG.

public void DrawSvgGlyphRun(RawVector2 baselineOrigin, GlyphRun glyphRun, Brush defaultFillBrush, SvgGlyphStyle svgGlyphStyle, int colorPaletteIndex, MeasuringMode measuringMode)

Parameters

baselineOrigin RawVector2

The origin of the baseline for the glyph run.

glyphRun GlyphRun

The glyphs to render.

defaultFillBrush Brush

The brush used to paint the specified glyphs.

svgGlyphStyle SvgGlyphStyle

Values for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.

colorPaletteIndex int

The index used to select a color palette within a color font. Note that this not the same as the paletteIndex in the ColorGlyphRun struct, which is not relevant for SVG glyphs.

measuringMode MeasuringMode

Indicates the measuring method used for text layout.

DrawText(string, int, TextFormat, RawRectangleF, Brush, SvgGlyphStyle, int, DrawTextOptions, MeasuringMode)

Represents a set of state and command buffers that are used to render to a target.

The device context can render to a target bitmap or a command list.

public void DrawText(string text, int stringLength, TextFormat textFormat, RawRectangleF layoutRect, Brush defaultFillBrush, SvgGlyphStyle svgGlyphStyle, int colorPaletteIndex, DrawTextOptions options, MeasuringMode measuringMode)

Parameters

text string

No documentation.

stringLength int

No documentation.

textFormat TextFormat

No documentation.

layoutRect RawRectangleF

No documentation.

defaultFillBrush Brush

No documentation.

svgGlyphStyle SvgGlyphStyle

No documentation.

colorPaletteIndex int

No documentation.

options DrawTextOptions

No documentation.

measuringMode MeasuringMode

No documentation.

Remarks

Any resource created from a device context can be shared with any other resource created from a device context when both contexts are created on the same device.

DrawTextLayout(RawVector2, TextLayout, Brush, SvgGlyphStyle, int, DrawTextOptions)

Draws a text layout object. If the layout is not subsequently changed, this can be more efficient than DrawText when drawing the same layout repeatedly.

public void DrawTextLayout(RawVector2 origin, TextLayout textLayout, Brush defaultFillBrush, SvgGlyphStyle svgGlyphStyle, int colorPaletteIndex, DrawTextOptions options)

Parameters

origin RawVector2

The point, described in device-independent pixels, at which the upper-left corner of the text described by textLayout is drawn.

textLayout TextLayout

The formatted text to draw. Any drawing effects that do not inherit from Resource are ignored. If there are drawing effects that inherit from Resource that are not brushes, this method fails and the render target is put in an error state.

defaultFillBrush Brush

The brush used to paint the text.

svgGlyphStyle SvgGlyphStyle

The values for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.

colorPaletteIndex int

The index used to select a color palette within a color font.

options DrawTextOptions

A value that indicates whether the text should be snapped to pixel boundaries and whether the text should be clipped to the layout rectangle. The default value is D2D1_DRAW_TEXT_OPTIONS_NONE, which indicates that text should be snapped to pixel boundaries and it should not be clipped to the layout rectangle.

GetColorBitmapGlyphImage(GlyphImageFormatS, RawVector2, FontFace, float, short, RawBool, RawMatrix3x2?, float, float, out RawMatrix3x2, out Image)

Retrieves an image of the color bitmap glyph from the color glyph cache. If the cache does not already contain the requested resource, it will be created. This method may be used to extend the lifetime of a glyph image even after it is evicted from the color glyph cache.

public void GetColorBitmapGlyphImage(GlyphImageFormatS glyphImageFormat, RawVector2 glyphOrigin, FontFace fontFace, float fontEmSize, short glyphIndex, RawBool isSideways, RawMatrix3x2? worldTransform, float dpiX, float dpiY, out RawMatrix3x2 glyphTransform, out Image glyphImage)

Parameters

glyphImageFormat GlyphImageFormatS

The format for the glyph image. If there is no image data in the requested format for the requested glyph, this method will return an error.

glyphOrigin RawVector2

The origin for the glyph.

fontFace FontFace

Reference to a font face which contains font face type, appropriate file references, face identification data and various font data such as metrics, names and glyph outlines.

fontEmSize float

The specified font size affects the choice of which bitmap to use from the font. It also affects the output glyphTransform, causing it to properly scale the glyph.

glyphIndex short

Index of the glyph.

isSideways RawBool

If true, specifies that glyphs are rotated 90 degrees to the left and vertical metrics are used. Vertical writing is achieved by specifying isSideways as true and rotating the entire run 90 degrees to the right via a rotate transform.

worldTransform RawMatrix3x2?

The transform to apply to the image. This input transform affects the choice of which bitmap to use from the font. It is also factored into the output glyphTransform.

dpiX float

Dots per inch along the x-axis.

dpiY float

Dots per inch along the y-axis.

glyphTransform RawMatrix3x2

Output transform, which transforms from the glyph's space to the same output space as the worldTransform. This includes the input glyphOrigin, the glyph's offset from the glyphOrigin, and any other required transformations.

glyphImage Image

On completion contains the retrieved glyph image.

GetSvgGlyphImage(RawVector2, FontFace, float, short, RawBool, RawMatrix3x2?, Brush, SvgGlyphStyle, int, out RawMatrix3x2, out CommandList)

Retrieves an image of the SVG glyph from the color glyph cache. If the cache does not already contain the requested resource, it will be created. This method may be used to extend the lifetime of a glyph image even after it is evicted from the color glyph cache.

public void GetSvgGlyphImage(RawVector2 glyphOrigin, FontFace fontFace, float fontEmSize, short glyphIndex, RawBool isSideways, RawMatrix3x2? worldTransform, Brush defaultFillBrush, SvgGlyphStyle svgGlyphStyle, int colorPaletteIndex, out RawMatrix3x2 glyphTransform, out CommandList glyphImage)

Parameters

glyphOrigin RawVector2

Origin of the glyph.

fontFace FontFace

Reference to a font face which contains font face type, appropriate file references, face identification data and various font data such as metrics, names and glyph outlines.

fontEmSize float

The specified font size affects the output glyphTransform, causing it to properly scale the glyph.

glyphIndex short

Index of the glyph to retrieve.

isSideways RawBool

If true, specifies that glyphs are rotated 90 degrees to the left and vertical metrics are used. Vertical writing is achieved by specifying isSideways as true and rotating the entire run 90 degrees to the right via a rotate transform.

worldTransform RawMatrix3x2?

The transform to apply to the image.

defaultFillBrush Brush

Describes how the area is painted.

svgGlyphStyle SvgGlyphStyle

The values for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.

colorPaletteIndex int

The index used to select a color palette within a color font. Note that this not the same as the paletteIndex in the ColorGlyphRun struct, which is not relevant for SVG glyphs.

glyphTransform RawMatrix3x2

Output transform, which transforms from the glyph's space to the same output space as the worldTransform. This includes the input glyphOrigin, the glyph's offset from the glyphOrigin, and any other required transformations.

glyphImage CommandList

On completion, contains the retrieved glyph image.

Operators

explicit operator DeviceContext4(nint)

public static explicit operator DeviceContext4(nint nativePtr)

Parameters

nativePtr nint

Returns

DeviceContext4