AnnCount Example for Delphi
//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
procedure TForm1.AnnCountClick(Sender: TObject);
var
nRet: Integer;
i: Integer;
strMsg: String;
strTmp: String;
nIndexAnn: Integer;
RasterIO: LEADRASTERIO;
RasterAnn: LEADRasterAnnotation;
begin
RasterIO:= coLEADRASTERIO.Create ();
RasterAnn:= coLEADRasterAnnotation.Create();
// Open the dataset with annotations
nRet:= LEADDicomDS1.LoadDS ('e:\images\DicomAnn.dic', 0);
if(nRet <> DICOM_SUCCESS)then
Exit;
RasterIO.EnableMethodErrors:= False;
RasterIO.Load(LEADRasterView1.Raster, 'e:\images\DicomAnn.dic', 0, 0, 1);
// Find the location of one of the annotation files
LEADDicomDS1.AnnCount ();
if(nRet <> DICOM_SUCCESS)then
Exit;
strMsg:= 'Private Creator Tag: ' + IntToStr(LEADDicomDS1.AnnPrivateCreatorTag) + Chr(13);
nIndexAnn:= 0;
for i:= 0 to 255 do
begin
if(LEADDicomDS1.AnnEntries[i] = True)then
begin
nIndexAnn:= i;
strTmp:= Chr(VK_TAB) + IntToStr(i) + Chr(13);
strMsg:= strMsg + strTmp;
end;
end;
ShowMessage(strMsg);
// Loads the annotations
LEADDicomDS1.AnnLoad(nIndexAnn, 1);
// Flip the annotations
RasterAnn.AnnContainer:= LEADDicomDS1.AnnContainer;
RasterAnn.AnnFlip(True, LEADRasterView1.Raster.BitmapHeight / 2, False);
LEADDicomDS1.AnnContainer:= RasterAnn.AnnContainer;
// Save the annotations to index to slots 250 through 255
for i:= 250 to 255 do
begin
nRet:= LEADDicomDS1.AnnSave(i, ANN_FMT_NATIVE, False, SAVE_OVERWRITE, 1);
end;
// Delete the annotation files from slot 253
LEADDicomDS1.AnnDelete(253, -1);
// Display file info
LEADDicomDS1.AnnCount ();
if(nRet <> DICOM_SUCCESS)then
Exit;
strMsg:= 'Private Creator Tag: ' + IntToStr(LEADDicomDS1.AnnPrivateCreatorTag) + Chr(13);
for i:= 0 to 255 do
begin
if(LEADDicomDS1.AnnEntries [i] = True)then
begin
strTmp:= Chr(VK_TAB) + IntToStr(i) + Chr(13);
strMsg:= strMsg + strTmp;
end;
end;
ShowMessage(strMsg);
// Save the data set
LEADDicomDS1.SaveDS('e:\erase\dicom.dic', 0);
end;