Loading a Data Set (Delphi)
Take the following steps to start a project and to add some code that loads a DICOM Data Set and prints information about the data set:
1. |
Start Delphi. |
|
2. |
On the Project pull-down menu, use the Import Type library… and select LEAD DICOM DS COM Object Library (14.5) and LEAD DICOM Kernel COM Object Library (14.5) then press OK. |
|
3. |
Select LEAD DICOM DS and LEAD DICOM Factory from the ActiveX tab and add them to your form. |
|
4. |
Add a button to your form and name it as follows: |
|
|
Name |
Caption |
|
btnLoadImage |
Load Image |
5. |
Code the main form's Create procedure as follows. |
procedure TForm1.FormCreate(Sender: TObject);
var
strLic: String;
DicomKernel: LEADDicomKernel;
begin
//Unlock DICOM support.
//Note that this is a sample key, which will not work in your toolkit.
strLic:= 'LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc.';
DicomKernel:= LEADDicomFactory1.CreateObject ('LEADDicomKernel.LEADDicomKernel', strLic) as LEADDicomKernel;
DicomKernel.UnlockSupport (L_SUPPORT_MEDICAL, 'TestKey');
end;
6. |
Code the btnLoadImage button's click procedure as follows: |
procedure TForm1.btnLoadImageClick(Sender: TObject);
var
nRet: Integer;
nCount: Integer;
bResult: Boolean;
begin
LEADDicomDS1.EnableMethodErrors:= False;
nRet:= LEADDicomDS1.LoadDS ('D:\lead14\dist\images\dicom\image1.dic', 0);
if(nRet <> DICOM_SUCCESS)then
begin
ShowMessage('Error ' + IntToStr(nRet) + ' loading file!');
Exit;
end;
nCount:= LEADDicomDS1.GetModuleCount ();
LEADDicomDS1.FindIndexModule (0);
bResult:= LEADDicomDS1.SetCurrentElement (LEADDicomDS1.DefaultInterface.Get_CurrentModule().Element[0].hElement);
if(bResult)then
begin
ShowMessage('There are ' + IntToStr(nCount) + ' modules in this data set.' + (Chr(13)) +
'The first module has ' + IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentModule().ElementCount) +
' elements.' + (Chr(13)) + 'The first element has: ' + (Chr(13)) + 'Tag number:' +
IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentElement().Tag) + (Chr(13)) + 'VR: ' +
IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentElement().VR));
end;
LEADDicomDS1.EnableMethodErrors:= True;
end;
7. |
Run your program to test it. |
8. |
Save the project to be used as a starting point for other tasks in this tutorial. |