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;