ImageEn, unit ieMIO

TImageEnMIO.SaveToFileDICOM

TImageEnMIO.SaveToFileDICOM

Declaration

procedure SaveToFileDICOM(const FileName: string; SelectedOnly: Boolean = False);

Description

Save all images in the attached TImageEnMView or TIEMultiBitmap as a DICOM file.
If SelectedOnly = True and the component is attached to a TImageEnMView then only the selected images are output.

Note:
◼DICOM requires each image to have the same width, height and pixel format (BitsPerSample and SamplesPerPixel).
◼If an internal save error is encountered Aborting will return True. Saving issues due to insufficient write permissions and disk write failures will raise an exception.
◼To abort while saving set Aborting to True

Example

// Create a multi-frame DICOM image from a source file list
procedure TForm1.CreateMultiDicom(sl: TStrings; SaveFilename: string);
var
  mbmp: TIEMultiBitmap;
  mio: TImageEnMIO;
  bmp : TIEBitmap;
  i: Integer;
begin
  mbmp := TIEMultiBitmap.Create();
  mio := TImageEnMIO.CreateFromIEMBitmap(mbmp);

  for i := 0 to sl.Count - 1 do
  begin
    bmp := TIEBitmap.Create();
    bmp.ParamsEnabled := True;
    bmp.LoadFromFile(sl[i]);
    mbmp.AppendImage( bmp );
    bmp.Free();
  end;

  // Ensure all frames of DICOM are same size
  for i := 1 to mbmp.Count - 1 do
  begin
    bmp := mbmp.GetTIEBitmap( i );
    bmp.Resample( mbmp.ImageWidth[0], mbmp.ImageHeight[0], rfFastLinear );
    mbmp.ReleaseBitmap( i, True );
  end;

  // Ensure all frames of DICOM have same duplication and pixel format info
  mio.DuplicateCompressionInfo();

  mio.SaveToFileDICOM( SaveFilename );
  mio.Free();
  mbmp.Free();
end;