Environment.GetTextImage Method
Protected Function GetTextImage( _
ByVal text As String, _
ByVal font As Font, _
ByVal color As Color, _
ByVal fillColor As Color, _
ByVal textAlign As ContentAlignment, _
ByVal rotateFlip As RotateFlipType, _
Optional ByVal antialias As Boolean = true _
) As Bitmap
This language is not supported or no code example is available.
Parameters
- text
- string
The text
- font
- Font
The text font
- color
- Color
The text color
- fillColor
- Color
The background color
- textAlign
- ContentAlignment
The text alignment (used to clip the image when the background is transparent)
- rotateFlip
- RotateFlipType
The rotation and flip to apply to the bitmap
- antialias
- bool
If true, the text is antialiased
Return Value
BitmapThe text bitmap
The following code demonstrates how to efficiently draw a text on screen
private TextureBase texture1; private bool firstTime = false; protected override void DrawOverlay(DrawSceneParams data) { base.DrawOverlay(data); if (!firstTime) { firstTime = true; Font font = new Font("Tahoma", 50, FontStyle.Italic); Image image1 = GetTextImage("My Text", font, Color.Red, Color.Transparent, ContentAlignment.TopRight, RotateFlipType.RotateNoneFlipY); texture1 = renderContext.CreateTexture2D(image1, textureFilteringFunctionType.Nearest, textureFilteringFunctionType.Nearest, true, true); image1.Dispose(); font.Dispose(); } DrawTexture(texture1, 100, 100, ContentAlignment.BottomLeft); // Remember to Dispose the texture when it is no more needed, or before quitting the application }
This language is not supported or no code example is available.
Private texture1 As TextureBase Private firstTime As Boolean = False Protected Overrides Sub DrawOverlay(data As DrawSceneParams) MyBase.DrawOverlay(data) If Not firstTime Then firstTime = True Dim font As New Font("Tahoma", 50, FontStyle.Italic) Dim image1 As Image = GetTextImage("My Text", font, Color.Red, Color.Transparent, ContentAlignment.TopRight, RotateFlipType.RotateNoneFlipY) texture1 = renderContext.CreateTexture2D(image1, textureFilteringFunctionType.Nearest, textureFilteringFunctionType.Nearest, True, True) image1.Dispose() font.Dispose() End If DrawTexture(texture1, 100, 100, ContentAlignment.BottomLeft) ' Remember to Dispose the texture when it is no more needed, or before quitting the application End Sub
This language is not supported or no code example is available.