Class DeviceContext4
[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
Device4The device.
options
DeviceContextOptionsThe 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
SvgGlyphStyleOn 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
GlyphImageFormatSSpecifies 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
RawVector2The origin of the baseline for the glyph run.
glyphRun
GlyphRunThe glyphs to render.
measuringMode
MeasuringModeIndicates the measuring method.
bitmapSnapOption
ColorBitmapGlyphSnapOptionSpecifies 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
RawVector2The origin of the baseline for the glyph run.
glyphRun
GlyphRunThe glyphs to render.
defaultFillBrush
BrushThe brush used to paint the specified glyphs.
svgGlyphStyle
SvgGlyphStyleValues for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.
colorPaletteIndex
intThe 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
MeasuringModeIndicates 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
stringNo documentation.
stringLength
intNo documentation.
textFormat
TextFormatNo documentation.
layoutRect
RawRectangleFNo documentation.
defaultFillBrush
BrushNo documentation.
svgGlyphStyle
SvgGlyphStyleNo documentation.
colorPaletteIndex
intNo documentation.
options
DrawTextOptionsNo documentation.
measuringMode
MeasuringModeNo 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
RawVector2The point, described in device-independent pixels, at which the upper-left corner of the text described by textLayout is drawn.
textLayout
TextLayoutThe 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
BrushThe brush used to paint the text.
svgGlyphStyle
SvgGlyphStyleThe values for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.
colorPaletteIndex
intThe index used to select a color palette within a color font.
options
DrawTextOptionsA 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
GlyphImageFormatSThe 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
RawVector2The origin for the glyph.
fontFace
FontFaceReference 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
floatThe 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
shortIndex of the glyph.
isSideways
RawBoolIf 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
floatDots per inch along the x-axis.
dpiY
floatDots per inch along the y-axis.
glyphTransform
RawMatrix3x2Output 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
ImageOn 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
RawVector2Origin of the glyph.
fontFace
FontFaceReference 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
floatThe specified font size affects the output glyphTransform, causing it to properly scale the glyph.
glyphIndex
shortIndex of the glyph to retrieve.
isSideways
RawBoolIf 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
BrushDescribes how the area is painted.
svgGlyphStyle
SvgGlyphStyleThe values for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.
colorPaletteIndex
intThe 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
RawMatrix3x2Output 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
CommandListOn completion, contains the retrieved glyph image.
Operators
explicit operator DeviceContext4(nint)
public static explicit operator DeviceContext4(nint nativePtr)
Parameters
nativePtr
nint