ImageEn, unit imageenio

TImageEnIO.InjectDICOMTags

TImageEnIO.InjectDICOMTags


Declaration

function InjectDICOMTags(const FileName: WideString): boolean; overload;
function InjectDICOMTags(const InputFileName, OutputFileName: WideString): boolean; overload;
function InjectDICOMTags(InputStream, OutputStream: TStream): boolean; overload;


Description

Replaces the DICOM Tags information in the specified DICOM file or stream with the current Tags (in Params) without loading or modifying the original image.
OutputStream contains the modified stream.
The method returns false if the operation could not be performed.

Note: Only single frame DICOM files are supported


Examples

// Create an anonymized version of a dicom file (strip all personal identification details)
ImageEnView1.IO.LoadFromFile( OpenImageEnDialog1.FileName );
if ImageEnView1.IO.Params.FileType = ioDICOM then
begin
  IEAnonymizeDicomTags( ImageEnView1.IO.Params.DICOM_Tags );
  destFN := ChangeFileExt( ImageEnView1.IO.Params.FileName, '-Anonymous.dicom' );
  ImageEnView1.IO.InjectDICOMTags( ImageEnView1.IO.Params.FileName, destFN );
end;

// Strip all tags from a dicom file
ImageEnView1.IO.LoadFromFile( OpenImageEnDialog1.FileName );
if ImageEnView1.IO.Params.FileType = ioDICOM then
begin
  ImageEnView1.IO.Params.ResetInfo([ierDicomTags]);
  destFN := ChangeFileExt( ImageEnView1.IO.Params.FileName, '-ExclTags.dicom' );
  ImageEnView1.IO.InjectDICOMTags( ImageEnView1.IO.Params.FileName, destFN );
end;

// Add a "Patient Name" tag to a Dicom file (or replace tag if it already exists)
ImageEnView1.IO.LoadFromFile( OpenImageEnDialog1.FileName );
if ImageEnView1.IO.Params.FileType = ioDICOM then
begin
  ImageEnView1.IO.Params.DICOM_Tags.SetTagString( $0010, $0010, 'Joe Bloggs' );
  destFN := ChangeFileExt( ImageEnView1.IO.Params.FileName, '-Edited.dicom' );
  ImageEnView1.IO.InjectDICOMTags( ImageEnView1.IO.Params.FileName, destFN );
end;


See Also

- LoadFromFileDICOM
- LoadFromStreamDICOM
- SaveToFileDICOM
- SaveToStreamDICOM