AnnCount Example for VB.NET
'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "LEADRasterView1" of type "AxLEADRasterView" from "LEADTOOLS Toolkit".
Private Sub TestAnnCount()
'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 Short
Dim i As Short
Dim hAnnContainer As Integer
Dim strMsg As String
Dim strTmp As String
Dim nIndexAnn As Short
Dim RasterIO As New LTRASTERIOLib.LEADRasterIO
Dim RasterAnn As New LTANNLib.LEADRasterAnnotation
' Open the dataset with annotations
nRet = LEADDICOM1.LoadDS("e:\images\DicomAnn.dic",
0)
If (nRet <> LTDicomKernelLib.DicomErrorCodes.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 <> LTDicomKernelLib.DicomErrorCodes.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
MessageBox.Show(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, LTANNLib.AnnFMTConstants.ANN_FMT_NATIVE,
False, LTDICLib.DicomAnnSaveModifyConstants.SAVE_OVERWRITE, 1)
Next i
' Delete the annotation files from slot 253
LEADDICOM1.AnnDelete(253, -1)
' Display file info
LEADDICOM1.AnnCount()
If (nRet <> LTDicomKernelLib.DicomErrorCodes.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
MessageBox.Show(strMsg)
' Save the data set LEADDICOM1.SaveDS("e:\erase\dicom.dic", 0)
End Sub