public static void Write(string filePath, DICOMWriteSettings settings, DICOMObject toWrite) { using (DICOMBinaryWriter dw = new DICOMBinaryWriter(filePath)) { DICOMPreambleWriter.Write(dw); TransferSyntaxHelper.SetSyntax(toWrite, settings.TransferSyntax); DICOMObjectWriter.WriteObjectLittleEndian(dw, settings, toWrite); } }
/// <summary> /// Write DICOM file out (bytes) to a specified stream /// </summary> /// <param name="stream">the stream to which to write the file</param> /// <param name="settings">the write settings</param> /// <param name="toWrite">the object to write</param> public static void Write(Stream stream, DICOMWriteSettings settings, DICOMObject toWrite) { settings = settings ?? DICOMWriteSettings.Default(); using (var dw = new DICOMBinaryWriter(stream)) { DICOMPreambleWriter.Write(dw); TransferSyntaxHelper.SetSyntax(toWrite, settings.TransferSyntax); DICOMObjectWriter.Write(dw, settings, toWrite); } }