Leadtools.Medical.Workstation.DataAccessLayer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
DicomInformation Constructor()
See Also  Example
Leadtools.Medical.Workstation.DataAccessLayer Namespace > DicomInformation Class > DicomInformation Constructor : DicomInformation Constructor()



Initializes a new instance of the DicomInformation class.

Syntax

Visual Basic (Declaration)  
<DebuggerNonUserCodeAttribute()>
Public Function New()
Visual Basic (Usage) Copy Code
Dim instance As DicomInformation()
C#  
[DebuggerNonUserCodeAttribute()]
public DicomInformation()
C++/CLI  
[DebuggerNonUserCodeAttribute()]
public:
DicomInformation();

Example

Visual Basic Copy Code
<Test> _
Public Sub StoreDICOMImages()
  Dim dataSet As DicomDataSet = New DicomDataSet()
  Dim dataSetPath As String = Path.Combine (ImagesPath.Path, "IMAGE1.DIC")

  dataSet.Load (dataSetPath, DicomDataSetLoadFlags.LoadAndClose)

  Dim thumbnailPath As String = GenerateThumbnail (dataSet)

  Dim dataAccessAgent As IWorkstationDataAccessAgent = Nothing
  Try
     'make sure you have configured the application configuration file with a valid
     'SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection'
     dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ("WorkstationSqlCeConnection")

     If Nothing Is dataAccessAgent Then
       Console.WriteLine ("You have not configured a valid database connection.")

       Return
     End If
  Catch exception As Exception
     Console.WriteLine(exception.Message," :You have not configured a valid database connection.")

     Return
  End Try

  dataAccessAgent.AddDicom (dataSet, "TEST", dataSetPath,thumbnailPath)

  'perform a wildcard query for all the database information.
  Dim queryResult As DicomInformation = dataAccessAgent.QueryDicomInformation (New FindQuery ())


  If queryResult.Images.Count > 0 Then
     Console.WriteLine (queryResult.Images (0).SOPInstanceUID)

     dataAccessAgent.RemoveDicom (queryResult.Images)
  Else
     Console.WriteLine ("No images found in the database.")
  End If
End Sub

Private Function GenerateThumbnail(ByVal dataset As DicomDataSet) As String
  Dim codec As RasterCodecs = New RasterCodecs()

  Dim imageElement As DicomElement = dataset.FindFirstElement(Nothing, DicomTag.PixelData, False)

  If Not Nothing Is imageElement Then
     Dim rasterImage As RasterImage
     Dim resizeCmd As SizeCommand
     Dim thumbImage As String

     rasterImage = dataset.GetImage(imageElement, 0, 0, RasterByteOrder.Rgb, DicomGetImageFlags.AutoApplyModalityLut Or DicomGetImageFlags.AutoApplyVoiLut)

     If rasterImage.Signed OrElse rasterImage.GrayscaleMode = RasterGrayscaleMode.OrderedInverse Then
       Dim cmgGray As GrayscaleCommand

       cmgGray = New GrayscaleCommand(8)

       cmgGray.Run(rasterImage)
     End If

     resizeCmd = New SizeCommand(64, 64, RasterSizeFlags.None)

     resizeCmd.Run(rasterImage)

     thumbImage = Path.Combine (ImagesPath.Path, "Test.jpg")

     codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24)

     Return thumbImage
  Else
     Return Nothing
  End If
End Function
C# Copy Code
public void StoreDICOMImages ( )  

   DicomDataSet dataSet = new DicomDataSet(); 
 
   string dataSetPath = Path.Combine ( ImagesPath.Path, "IMAGE1.DIC" ) ; 
 
   dataSet.Load ( dataSetPath, DicomDataSetLoadFlags.LoadAndClose ) ; 
 
   string thumbnailPath = GenerateThumbnail ( dataSet ) ; 
 
   IWorkstationDataAccessAgent dataAccessAgent = null ; 
   try 
   { 
      //make sure you have configured the application configuration file with a valid  
      //SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection' 
      dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ( "WorkstationSqlCeConnection" ) ; 
 
      if ( null == dataAccessAgent ) 
      { 
         Console.WriteLine ( "You have not configured a valid database connection." ) ; 
 
         return ; 
      } 
   } 
   catch ( Exception exception ) 
   { 
      Console.WriteLine( exception.Message," :You have not configured a valid database connection."); 
 
      return ; 
   } 
 
   dataAccessAgent.AddDicom ( dataSet, "TEST", dataSetPath,thumbnailPath ) ; 
 
   //perform a wildcard query for all the database information. 
   DicomInformation queryResult = dataAccessAgent.QueryDicomInformation ( new FindQuery ( ) ) ; 
 
 
   if ( queryResult.Images.Count > 0 )  
   { 
      Console.WriteLine ( queryResult.Images [ 0 ].SOPInstanceUID ) ; 
 
      dataAccessAgent.RemoveDicom ( queryResult.Images ) ; 
   } 
   else 
   { 
      Console.WriteLine ( "No images found in the database." ); 
   } 

 
private string GenerateThumbnail 

   DicomDataSet dataset 
 


   RasterCodecs codec = new RasterCodecs(); 
 
   DicomElement imageElement = dataset.FindFirstElement(null, DicomTag.PixelData, false); 
 
   if (null != imageElement) 
   { 
      RasterImage rasterImage; 
      SizeCommand resizeCmd; 
      string thumbImage; 
 
      rasterImage = dataset.GetImage(imageElement, 
                                       0, 
                                       0, 
                                       RasterByteOrder.Rgb, 
                                       DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut); 
 
      if (rasterImage.Signed || rasterImage.GrayscaleMode == RasterGrayscaleMode.OrderedInverse) 
      { 
         GrayscaleCommand cmgGray; 
 
         cmgGray = new GrayscaleCommand(8); 
 
         cmgGray.Run(rasterImage); 
      } 
 
      resizeCmd = new SizeCommand(64, 64, RasterSizeFlags.None); 
 
      resizeCmd.Run(rasterImage); 
 
      thumbImage = Path.Combine ( ImagesPath.Path, "Test.jpg" ) ; 
 
      codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24); 
 
      return thumbImage ; 
   } 
   else 
   { 
      return null ; 
   } 
}

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Medical.Workstation.DataAccessLayer requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features