private DicomDataset DeepClone_(DicomDataset dataset)
    {
      var ms = new MemoryStream();
      var target = new StreamByteTarget(ms);
      var writer = new DicomWriter(DicomTransferSyntax.ImplicitVRLittleEndian, DicomWriteOptions.Default, target);
      var walker = new DicomDatasetWalker(dataset);
      walker.Walk(writer);

      var clone = new DicomDataset();
      var reader = new DicomReader { IsExplicitVR = false };
      var byteSource = new ByteBufferByteSource(
        new MemoryByteBuffer(ms.ToArray()));
      reader.Read(byteSource, new DicomDatasetReaderObserver(clone));
      return clone;
    }
예제 #2
0
		public void Save(Stream stream) {
			if (Format == DicomFileFormat.ACRNEMA1 || Format == DicomFileFormat.ACRNEMA2)
				throw new DicomFileException(this, "Unable to save ACR-NEMA file");

			if (Format == DicomFileFormat.DICOM3NoFileMetaInfo) {
				// create file meta information from dataset
				FileMetaInfo = new DicomFileMetaInformation(Dataset);
			}

			OnSave();

			using (var target = new StreamByteTarget(stream)) {
				DicomFileWriter writer = new DicomFileWriter(DicomWriteOptions.Default);
				writer.Write(target, FileMetaInfo, Dataset);
			}
		}
예제 #3
0
파일: DicomFile.cs 프로젝트: aerik/fo-dicom
        /// <summary>
        /// Asynchronously save DICOM file to stream.
        /// </summary>
        /// <param name="stream">Stream on which to save DICOM file.</param>
        /// <returns>Awaitable task.</returns>
        public async Task SaveAsync(Stream stream)
        {
            this.PreprocessFileMetaInformation();
            this.OnSave();

            var target = new StreamByteTarget(stream);
            var writer = new DicomFileWriter(DicomWriteOptions.Default);
            await writer.WriteAsync(target, this.FileMetaInfo, this.Dataset).ConfigureAwait(false);
        }
예제 #4
0
파일: DicomFile.cs 프로젝트: aerik/fo-dicom
        /// <summary>
        /// Save DICOM file to stream.
        /// </summary>
        /// <param name="stream">Stream on which to save DICOM file.</param>
        public void Save(Stream stream)
        {
            this.PreprocessFileMetaInformation();
            this.OnSave();

            var target = new StreamByteTarget(stream);
            var writer = new DicomFileWriter(DicomWriteOptions.Default);
            writer.Write(target, this.FileMetaInfo, this.Dataset);
        }
예제 #5
0
        /// <summary>
        /// Asynchronously save DICOM file to stream.
        /// </summary>
        /// <param name="stream">Stream on which to save DICOM file.</param>
        /// <returns>Awaitable task.</returns>
        public async Task SaveAsync(Stream stream)
        {
            if (this.Format == DicomFileFormat.ACRNEMA1 || this.Format == DicomFileFormat.ACRNEMA2)
            {
                throw new DicomFileException(this, "Unable to save ACR-NEMA file");
            }

            if (this.Format == DicomFileFormat.DICOM3NoFileMetaInfo)
            {
                // create file meta information from dataset
                this.FileMetaInfo = new DicomFileMetaInformation(this.Dataset);
            }

            this.OnSave();

            var target = new StreamByteTarget(stream);
            var writer = new DicomFileWriter(DicomWriteOptions.Default);
            await writer.WriteAsync(target, this.FileMetaInfo, this.Dataset).ConfigureAwait(false);
        }