Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.3.25
|
Leadtools.Dicom Namespace > DicomDataSet Class > Load Method : Load(Stream,DicomDataSetLoadFlags) Method |
public virtual void Load( Stream stream, DicomDataSetLoadFlags flags )
'Declaration
Public Overloads Overridable Sub Load( _ ByVal stream As Stream, _ ByVal flags As DicomDataSetLoadFlags _ )
'Usage
Dim instance As DicomDataSet Dim stream As Stream Dim flags As DicomDataSetLoadFlags instance.Load(stream, flags)
public virtual void Load( Stream stream, DicomDataSetLoadFlags flags )
public void load(ILeadStream stream, /*DicomDataSetLoadFlags*/ int flags)
public: virtual void Load( Stream^ stream, DicomDataSetLoadFlags flags )
If you do not know any of the characteristics of the file, set flags to DicomDataSetLoadFlags.None and LEADTOOLS will automatically determine all the file characteristics and load the file accordingly.
In this overload, the DicomDataSetLoadFlags.LoadAndClose is always used internally, even if not included in the flags
To load a Data Set from memory, you can also use DicomDataSet.Load(IntPtr, long, DicomDataSetFlags). To load a Data Set from a file, you can use DicomDataSet.Load(string, DicomDataSetLoadFlags).
This example will load a DICOM Dataset from a file, save to a stream, load from a stream, and save to another file.
Imports Leadtools Imports Leadtools.Dicom <TestMethod()> _ Public Sub LoadFromStreamSample() Dim dicomFileNameInput As String = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm") Dim dicomFileNameOutput As String = Path.Combine(LEAD_VARS.ImagesDir, "Image3_copy.dcm") DicomEngine.Startup() Using ds As New DicomDataSet() Using streamInput As New FileStream(dicomFileNameInput, FileMode.Open) ' Load a DICOM data set from a stream ds.Load(streamInput, DicomDataSetLoadFlags.None) ' Save to another output stream Using streamOutput As New FileStream(dicomFileNameOutput, FileMode.Create) ds.Save(streamOutput, DicomDataSetSaveFlags.None) End Using End Using End Using DicomEngine.Shutdown() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Dicom; [TestMethod] public void LoadFromStreamSample() { string dicomFileNameInput = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"); string dicomFileNameOutput = Path.Combine(LEAD_VARS.ImagesDir, "Image3_copy.dcm"); DicomEngine.Startup(); using (DicomDataSet ds = new DicomDataSet()) { using (FileStream streamInput = new FileStream(dicomFileNameInput, FileMode.Open)) { // Load a DICOM data set from a stream ds.Load(streamInput, DicomDataSetLoadFlags.None); // Save to another output stream using (FileStream streamOutput = new FileStream(dicomFileNameOutput, FileMode.Create)) { ds.Save(streamOutput, DicomDataSetSaveFlags.None); } } } DicomEngine.Shutdown(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }