Skip to content

Commit

Permalink
add save to stream method
Browse files Browse the repository at this point in the history
  • Loading branch information
rcd committed Jan 5, 2013
1 parent 7e1b2b6 commit dda31c3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions DICOM/DicomFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ public class DicomFile {
}
}

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);
}
}

public void BeginSave(string fileName, AsyncCallback callback, object state) {
if (Format == DicomFileFormat.ACRNEMA1 || Format == DicomFileFormat.ACRNEMA2)
throw new DicomFileException(this, "Unable to save ACR-NEMA file");
Expand Down

0 comments on commit dda31c3

Please sign in to comment.