示例#1
0
 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);
     }
 }
示例#2
0
 /// <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 WriteItemLittleEndian(DICOMBinaryWriter dw, DICOMWriteSettings settings, DICOMObject d)
 {
     DICOMTagWriter.WriteLittleEndian(dw, TagHelper.Item);
     using (var stream = new MemoryStream())
     {
         using (var itemDw = new DICOMBinaryWriter(stream))
         {
             DICOMObjectWriter.Write(itemDw, settings, d, true);
             if (!settings.DoWriteIndefiniteSequences)
             {
                 LengthWriter.Write(dw, VR.Null, settings, (int)stream.Length);
                 dw.Write(stream.ToArray());
             }
             else
             {
                 WriteIndefiniteLittleEndian(dw, stream.ToArray());
             }
         }
     }
 }