DrawText2 Method

NI Vision for Visual Basic

DrawText2 Method

Syntax

CWIMAQVision.DrawText2 SourceImage, DestImage, Origin, TextOptions, Text, Width [, Invert]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Draws text on an image.

Remarks

Use this method with U8 and RGB32 images. If the image type is U8, the CWIMAQTextOptions.ForeColor and CWIMAQTextOptions.BackColor colors must be grayscale.

Parameters

SourceImage As CWIMAQImage

The input image.

DestImage As CWIMAQImage

The resulting image.

Origin As CWIMAQPoint

The point where the method inserts the text.

TextOptions As CWIMAQTextOptions

An object that specifies how the method draws the text.

Text As String

The text that the method draws.

Width As Long

On return, the width of the text.

Invert As Variant

[Optional] True to use an inverted pen to draw the text on the image. The default is False.

Example

Private Sub Run_Click()
    Dim origin As New CWIMAQPoint
    Dim text As String
    Dim width As Long
    Dim options As New CWIMAQTextOptions
    
    ' Draw text on the image in Viewer1.
    text = "This is some text"
    origin.Initialize 50, 100
    options.Angle = 45
    options.Size = 16
    options.ForeColor = RGB(128, 128, 128)
    options.BackColor = RGB(64, 64, 64)
    
    CWIMAQVision1.DrawText2 CWIMAQViewer1.Image, CWIMAQViewer1.Image, origin, options, text, width
End Sub

Draw Text Example

See Also

CWIMAQTextOptions.ForeColor

CWIMAQTextOptions.BackColor