Eyeshot 11 WinForms API Reference
WinForms Assembly / devDept.Eyeshot Namespace / ViewportLayout Class / GetTextImage Method
The text
The text font
The text color
The background color
The text alignment (used to clip the image when the background is transparent)
The rotation and flip to apply to the bitmap
If true, the text is antialiased
Example

In This Topic
    GetTextImage Method
    In This Topic
    Gets the text bitmap.
    Syntax
    'Declaration
     
    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 _
    ) As Bitmap
    protected Bitmap GetTextImage( 
       string text,
       Font font,
       Color color,
       Color fillColor,
       ContentAlignment textAlign,
       RotateFlipType rotateFlip,
       bool antialias
    )

    Parameters

    text
    The text
    font
    The text font
    color
    The text color
    fillColor
    The background color
    textAlign
    The text alignment (used to clip the image when the background is transparent)
    rotateFlip
    The rotation and flip to apply to the bitmap
    antialias
    If true, the text is antialiased

    Return Value

    The text bitmap
    Example
    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
    }
    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
    See Also