Available in the LEADTOOLS Imaging toolkit. |
SetTag example for Visual Basic
Private Sub SetAndRead_Click()
Dim myArray(4) As Long
' initialize the array
myArray(0) = 1
myArray(1) = 2
myArray(2) = 3
myArray(3) = 127
' set a tag using one of the following:
LEAD1.SetTag 32768, TAG_ASCII, 0, "My text string"
' LEAD1.SetTag 32768, TAG_BYTE, 4, myArray
' LEAD1.SetTag 32768, TAG_DOUBLE, 4, myArray
' LEAD1.SetTag 32768, TAG_FLOAT, 4, myArray
' LEAD1.SetTag 32768, TAG_LONG, 4, myArray
' LEAD1.SetTag 32768, TAG_RATIONAL, 2, myArray
' LEAD1.SetTag 32768, TAG_SBYTE, 4, myArray
' LEAD1.SetTag 32768, TAG_SHORT, 4, myArray
' LEAD1.SetTag 32768, TAG_SLONG, 4, myArray
' LEAD1.SetTag 32768, TAG_SRATIONAL, 2, myArray
' LEAD1.SetTag 32768, TAG_SSHORT, 4, myArray
' LEAD1.SetTag 32768, TAG_UNDEFINED, 4, myArray
' Write the tag
LEAD1.WriteTag Text1.Text, 1
Call ReadTag_Click
End Sub
Private Sub ReadTag_Click()
' read the tag back
LEAD1.ReadTag Text1.Text, 1, 32768
Call GetAndDisplayTag(0)
End Sub
' This sub will get a certain tag and display it according to the tag type.
Private Sub GetAndDisplayTag(lTag As Long)
Dim myVar As Variant
Dim Msg$
Dim i As Long
Dim count As Long
myVar = LEAD1.GetTagData (lTag)
count = LEAD1.GetTagCount (lTag)
Msg$ = "Type = " + CStr(LEAD1.GetTagType (lTag))
Msg$ = Msg$ + Chr$(10) + Chr$(13) + "count = " + CStr(count)
If LEAD1.GetTagType(lTag) = TAG_ASCII Then
Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data = " + myVar
ElseIf LEAD1.GetTagType(lTag) = TAG_RATIONAL Or LEAD1.GetTagType(lTag) = TAG_SRATIONAL Then
For i = 0 To count - 1
Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data(" + CStr(i) + ") = " + CStr(myVar(i * 2)) + "/" + CStr(myVar(i * 2 + 1))
Next i
Else
For i = 0 To count - 1
Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data(" + CStr(i) + ") = " + CStr(myVar(i))
Next
End If
MsgBox Msg$
End Sub