LDicomDS::AnnCount

#include "ltdic.h"

L_UINT16 LDicomDS::AnnCount(pFileIndices, pnPrivateCreatorTag)

Gets information about the annotations stored in a DICOM data set. This function is available in the PACS Imaging/Medical Imaging Toolkits.

Parameters

L_INT *pFileIndices

Pointer to an array of integers to be updated with the indices of the annotation files that exist in the DICOM data set.

L_UINT32 *pnPrivateCreatorTag

Pointer to a variable to be updated with the private creator tag. Pass NULL if you do not wish to retrieve this information.

Returns

Value Meaning
0 SUCCESS
>0 An error occurred. Refer to Return Codes.

Comments

LEAD Annotation files can be saved as private data in a DICOM data set (LEAD native format or binary encoded format). There can be up to 256 private data tags for LEAD annotation files. Specify one of the 256 possible files by setting the nIndex parameter to be a value from 0 to 255.

Before calling this function, you must declare an array of 256 integers (L_INT). Then, pass the address of the array for the pFileIndices parameter. This function will update the array to indicate which of the possible 256 annotation files exist.

For example, suppose that a Dicom data set contains three LEAD annotation files at indices 0, 1, and 4.

Executing the following

LDicomDS DicomDS; 
L_INT FileIndices[256]; 
    
DicomDS.LoadDS("d:\work\images\a.dic", 0); 
DicomDS.AnnCount(FileIndices, NULL); 

will set the FileIndices as follows:

FileIndices[0] = 1
FileIndices[1] = 1
FileIndices[2] = 0
FileIndices[3] = 0
FileIndices[4] = 1
FileIndices[5..255] = 0

You can obtain the private creator tag used to allocate tags for the LEAD annotation files by declaring a variable of type L_UINT32 and passing the address for the pnPrivateCreatorTag argument. Pass NULL for this argument if you do not wish to retrieve this information.

NOTE: Both DICOM and DOCUMENT capabilities must be unlocked in order to work with DICOM annotations. For more information on unlocking these capabilities, refer to LSettings::SetLicenseFile.

Required DLLs and Libraries

Platforms

Win32, x64

See Also

Functions

Topics

Example

This example:

  1. Opens a dataset with annotations
  2. Finds the location of one of the annotation files
  3. Loads the annotations
  4. Changes the foreground color of the annotations to blue
  5. Saves the annotations to index to slots 250 through 255
  6. Deletes the annotation files from slot 253
    L_INT LDicomDS_AnnCountExample() 
    { 
       L_UINT16      nRet = DICOM_SUCCESS; 
       L_INT         FileIndices[256] = {0}; 
       L_UINT32      nPrivateCreatorTag = 0; 
       L_INT         i; 
       HANNOBJECT    hAnnContainer = 0; 
       L_TCHAR       szMsg[800] = {0}; 
       L_TCHAR       szTmp[100] = {0}; 
       L_INT         nIndexAnn = -1; 
       LAnnotation   AnnContainer; 
     
       // Open the dataset with annotations 
       // 'image2_withLeadAnnotations.dcm' is a DICOM dataset with LEAD annotations stored in a private tag 
       LDicomDS DicomDS; 
       nRet = DicomDS.LoadDS(MAKE_IMAGE_PATH(TEXT("image2_withLeadAnnotations.dcm")), 0); 
       if (nRet != DICOM_SUCCESS) 
          return nRet; 
     
       // Find the location of one of the annotation files 
       nRet = DicomDS.AnnCount(FileIndices, &nPrivateCreatorTag); 
       if (nRet == DICOM_ERROR_ANN_NO_EXIST) 
       { 
          wsprintf(szMsg, TEXT("There are no DICOM annotations in this file: %s"), MAKE_IMAGE_PATH(TEXT("image2_withLeadAnnotations.dcm"))); 
          MessageBox(NULL, szMsg, TEXT(""), MB_OK); 
       } 
     
       if (nRet != DICOM_SUCCESS) 
          return nRet; 
     
       wsprintf(szMsg, TEXT("Private Creator Tag: %x\n\nFiles:\n"), nPrivateCreatorTag); 
       for (i=0; i<255; i++) 
       { 
          if (FileIndices[i]) 
          { 
             nIndexAnn = i; 
             wsprintf(szTmp, TEXT("\t%d\n"), i); 
             lstrcat(szMsg, szTmp); 
          } 
       } 
       MessageBox(NULL, szMsg, TEXT(""), MB_OK); 
     
       // Loads the annotations 
       nRet = DicomDS.AnnLoad(&hAnnContainer, nIndexAnn, NULL); 
       if(nRet != DICOM_SUCCESS) 
          return nRet; 
     
       // Change the foreground color of the annotations to blue 
       AnnContainer.SetHandle (hAnnContainer); 
       AnnContainer.SetForeColor (RGB(0,0,0xFF), ANNFLAG_RECURSE); 
     
       // Save the annotations to index to slots 250 through 255 
       for (i=250; i<=255; i++) 
          nRet = DicomDS.AnnSave(hAnnContainer,ANNFMT_XML,FALSE,NULL,i,NULL); 
       if(nRet != DICOM_SUCCESS) 
          return nRet; 
     
       // Delete the annotation files from slot 253 
       nRet = DicomDS.AnnDelete(253, -1); 
       if(nRet != DICOM_SUCCESS) 
          return nRet; 
     
       // Display file info 
       nRet = DicomDS.AnnCount(FileIndices, &nPrivateCreatorTag); 
       if(nRet != DICOM_SUCCESS) 
          return nRet; 
     
       wsprintf(szMsg, TEXT("Private Creator Tag: %x\n\nFiles:\n"), nPrivateCreatorTag); 
       for (i=0; i<255; i++) 
       { 
          if (FileIndices[i]) 
          { 
             wsprintf(szTmp, TEXT("\t%d\n"), i); 
             lstrcat(szMsg, szTmp); 
          } 
       } 
       MessageBox(NULL, szMsg, TEXT(""), MB_OK); 
     
       // Save the data set 
       nRet = DicomDS.SaveDS(MAKE_IMAGE_PATH(TEXT("dicom.dcm")), 0); 
       if(nRet != DICOM_SUCCESS) 
          return nRet; 
     
       return DICOM_SUCCESS; 
    } 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.