LDicomDS::AnnCount

#include "ltdic.h"

L_UINT16 LDicomDS::AnnCount(pFileIndices, pnPrivateCreatorTag)

L_INT *pFileIndices;

/* pointer to an array */

L_UINT32 *pnPrivateCreatorTag;

/* pointer to the private creator tag */

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

Parameter

Description

pFileIndices

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

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

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.

Please note that both the DICOM capabilities and the 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

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

Platforms

Win32, x64

See Also

Functions:

LDicomDS::AnnLoad, LDicomDS::AnnSave, LDicomDS::AnnDelete

Topics:

Working with DICOM Annotations

 

How to Disable the Automatic Loading of the default DICOM IOD Table

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

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LDicomDS_AnnCountExample()
{
   L_UINT16      nRet;
   L_INT         FileIndices[256];
   L_UINT32      nPrivateCreatorTag;
   L_INT         i;
   HANNOBJECT    hAnnContainer;
   L_TCHAR       szMsg[800];
   L_TCHAR       szTmp[100];
   L_INT         nIndexAnn = -1;
   LAnnotation   AnnContainer;
   // Open the dataset with annotations
   LDicomDS DicomDS;
   nRet = DicomDS.LoadDS(MAKE_IMAGE_PATH(TEXT("IMAGE1.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_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_NATIVE,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;
}