ImageGear for .NET User Guide > Getting Started > ImageGear for .NET Visual Studio 2008/2005 Tutorials > ImageGear for .NET VB.NET Tutorial > Adding DICOM Support |
Once the base of the tutorial application is completed, you can extend it with DICOM support using the following steps:
You should now have the ImageGear21.Formats.Dicom assembly listed under References in the Solution Explorer.
Next, add the DICOM using statement. Open the code for Form1.cs by right-clicking on the form and clicking View Code. At the top of the code add the following statement:
VB.NET |
Copy Code |
---|---|
Imports ImageGear.Formats.DICOM |
VB.NET |
Copy Code |
---|---|
' Support for DICOM format ImGearFileFormats.Filters.Insert(0, ImGearDICOM.CreateDICOMFormat()) ' Set DICOM DIMSE control value for wide range of DICOM file detection. ImGearFileFormats.Filters.Get(ImGearFormats.DICOM).Parameters.GetByName("LoadDetectSkipDIMSE").Value = True ' Set LoadConcatenateRepeatedDE flag to true by default. ImGearFileFormats.Filters.Get(ImGearFormats.DICOM).Parameters.GetByName("LoadConcatenateRepeatedDE").Value = True |
This will add the DICOM format to the ImageGear formats list. And now you are ready to compile and run the finished application supporting DICOM pages.
VB.NET |
Copy Code |
---|---|
Private igDocument As ImGearDocument |
VB.NET |
Copy Code |
---|---|
igPage = ImGearFileFormats.LoadPage(stream, 0) |
VB.NET |
Copy Code |
---|---|
igDocument = ImGearFileFormats.LoadDocument(stream, 0, 1) igPage = igDocument.Pages.Item(0) |
It does the same thing, but using the ImGearDocument API.
Now you are ready to compile and run the finished application working with DICOM documents.
VB.NET |
Copy Code |
---|---|
Imports ImageGear.ART |
VB.NET |
Copy Code |
---|---|
Private artPage As ImGearARTPage |
VB.NET |
Copy Code |
---|---|
If (artPage IsNot Nothing) Then artPage.RemoveMarks() End If ' DICOM overlays artPage = ImGearDICOM.LoadOverlay(igPage) If (artPage Is Nothing) Then artPage = New ImGearARTPage() End If ImGearPageView1.Display.ARTPage = artPage |
This will enable displaying overlays after loading the DICOM page.
VB.NET |
Copy Code |
---|---|
Dim rasterPage As ImGearRasterPage = ImGearPageView1.Display.Page ImGearDICOM.SaveOverlay(ImGearPageView1.Display.ARTPage, rasterPage) |
VB.NET |
Copy Code |
---|---|
artPage = ImGearDICOM.LoadOverlay(igPage) |
VB.NET |
Copy Code |
---|---|
Private presStateOrigMetadata As ImGearMetadataHead |
VB.NET |
Copy Code |
---|---|
If igPage Is Nothing Or Not (TypeOf igPage Is ImGearRasterPage) Then Return End If Dim dlg As OpenFileDialog = New OpenFileDialog() dlg.Filter = "Presentation State (*.pre)|*.pre|All files (*.*)|*.*" dlg.Title = "Select Presentation State File" If dlg.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then Using fileContent As New FileStream(dlg.FileName, FileMode.Open, FileAccess.Read) Dim opts As New ImGearPresStateOptions() presStateOrigMetadata = ImGearDICOM.LoadPresState(fileContent, CType(igPage, ImGearRasterPage), ImGearPageView1.Display, opts) artPage = ImGearPageView1.Display.ARTPage ImGearPageView1.Update() End Using End If |
VB.NET |
Copy Code |
---|---|
Dim dlg As SaveFileDialog = New SaveFileDialog() dlg.Filter = "Presentation State (*.pre)|*.pre|All files (*.*)|*.*" dlg.Title = "Save Presentation State File" If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Using fileContent As New FileStream(dlg.FileName, FileMode.Create) If TypeOf igPage Is ImGearRasterPage Then Dim opts As New ImGearPresStateOptions() Dim presStateMetadata As ImGearMetadataHead = ImGearDICOM.PreparePresStateMetadata(DirectCast(igPage, ImGearRasterPage), ImGearPageView1.Display, presStateOrigMetadata, opts) ' Note: The application can edit presStateMetadata here ImGearDICOM.SavePresState(fileContent, presStateMetadata) End If End Using End If |
VB.NET |
Copy Code |
---|---|
' Delete presStateOrigMetadata if any presStateOrigMetadata = Nothing |