/// <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); } }
public static void WriteLittleEndian(string filePath, DICOMObject toWrite) { DICOMWriteSettings settings = DICOMWriteSettings.Default(); IDICOMElement currentUID = toWrite.FindFirst(TagHelper.TRANSFER_SYNTAX_UID); if (currentUID != null) { settings.TransferSyntax = TransferSyntaxHelper.GetSyntax(currentUID); } //TODO Currently don't support BigEndian writing : switch syntax to supported if (settings.TransferSyntax == TransferSyntax.EXPLICIT_VR_BIG_ENDIAN) { settings.TransferSyntax = TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN; } Write(filePath, settings, toWrite); }