AnnCount Example for Visual Basic
Private Sub AnnCount_Click()
'This example
' 1. Opens a dataset with annotations
' 2. Finds the location of one of the annotation files
' 3. Loads the annotations
' 4. Flips the annotations
' 5. Saves the annotations to index to slots 250 through 255
' 6. Deletes the annotation files from slot 253
Dim nRet As Integer
Dim i As Integer
Dim hAnnContainer As Long
Dim strMsg As String
Dim strTmp As String
Dim nIndexAnn As Integer
Dim RasterIO As New LEADRASTERIO
Dim RasterAnn As New LEADRasterAnnotation
' Open the dataset with annotations
nRet = LEADDICOM1.LoadDS ("e:\images\DicomAnn.dic", 0)
If (nRet <> DICOM_SUCCESS) Then Exit Sub
RasterIO.EnableMethodErrors = False
RasterIO.Load LEADRasterView1.Raster, "e:\images\DicomAnn.dic", 0, 0, 1
' Find the location of one of the annotation files
LEADDICOM1.AnnCount
If (nRet <> DICOM_SUCCESS) Then Exit Sub
strMsg = "Private Creator Tag: " + Hex(LEADDICOM1.AnnPrivateCreatorTag) + vbNewLine
For i = 0 To 255
If (LEADDICOM1.AnnEntries (i) = True) Then
nIndexAnn = i
strTmp = vbTab + Str(i) + vbNewLine
strMsg = strMsg + strTmp
End If
Next i
MsgBox strMsg
' Loads the annotations
LEADDICOM1.AnnLoad nIndexAnn, 1
' Flip the annotations
RasterAnn.AnnContainer = LEADDICOM1.AnnContainer
RasterAnn.AnnFlip True, LEADRasterView1.Raster.BitmapHeight / 2, False
LEADDICOM1.AnnContainer = RasterAnn.AnnContainer
' Save the annotations to index to slots 250 through 255
For i = 250 To 255
nRet = LEADDICOM1.AnnSave(i, ANN_FMT_NATIVE, False, SAVE_OVERWRITE, 1)
Next i
' Delete the annotation files from slot 253
LEADDICOM1.AnnDelete 253, -1
' Display file info
LEADDICOM1.AnnCount
If (nRet <> DICOM_SUCCESS) Then Exit Sub
strMsg = "Private Creator Tag: " + Hex(LEADDICOM1.AnnPrivateCreatorTag) + vbNewLine
For i = 0 To 255
If (LEADDICOM1.AnnEntries (i) = True) Then
strTmp = vbTab + Str(i) + vbNewLine
strMsg = strMsg + strTmp
End If
Next i
MsgBox strMsg
' Save the data set
LEADDICOM1.SaveDS "e:\erase\dicom.dic", 0
End Sub