Environment.GetTextOutlinedImage Method

Gets the outlined text image.
Protected Friend Shared Function GetTextOutlinedImage( _ 
ByVal text As String, _ 
ByVal font As Font, _ 
ByVal color As Color, _ 
ByVal outlineColor As Color, _ 
ByVal rotateFlip As RotateFlipType, _ 
ByVal thickness As Single
) As Bitmap
This language is not supported or no code example is available.
internal protected static Bitmap GetTextOutlinedImage( 
string text
Font font
Color color
Color outlineColor
RotateFlipType rotateFlip
float thickness 
)
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

outlineColor
Color

The outline color

rotateFlip
RotateFlipType

The rotation and flip to apply to the bitmap

thickness
float

The outline thickness

Return Value

Bitmap

The text bitmap

Example
 
The following code demonstrates how to efficiently draw an outlined 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 = GetTextOutlinedImage("My Text", font, Color.Red, Color.Black, RotateFlipType.RotateNoneFlipY, 1);
         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 = GetTextOutlinedImage("My Text", font, Color.Red, Color.Black, RotateFlipType.RotateNoneFlipY, 1)
 		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.

.NET Framework

Supported in: 4.5, 4.6, 4.7

In this article

Definition