Leadtools.Dicom.Annotations Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
FromAnnObject Method
See Also  Example
Leadtools.Dicom.Annotations Namespace > DicomAnnotationsUtilities Class : FromAnnObject Method




annObject
The LEAD annotation object that is being converted
Converts an AnnObject to a DicomAnnotationObject.

Syntax

Visual Basic (Declaration) 
Public Function FromAnnObject( _
   ByVal annObject As AnnObject _
) As DicomAnnotationObject
Visual Basic (Usage)Copy Code
Dim instance As DicomAnnotationsUtilities
Dim annObject As AnnObject
Dim value As DicomAnnotationObject
 
value = instance.FromAnnObject(annObject)
C# 
public DicomAnnotationObject FromAnnObject( 
   AnnObject annObject
)
Managed Extensions for C++ 
public: DicomAnnotationObject FromAnnObject( 
   AnnObject annObject
) 
C++/CLI 
public:
DicomAnnotationObject FromAnnObject( 
   AnnObject annObject
) 

Parameters

annObject
The LEAD annotation object that is being converted

Return Value

A DICOM annotation DicomAnnotationObject if successful; null if the AnnObjectcannot be converted.

Example

This sample does the following: <list type="number"> <item><description>Creates a LEAD AnnRectangleObject annotation</description></item> <item><description>Creates a converter</description></item> <item><description>Converts to a DicomAnnotationObject annotation</description></item> <item><description>Converts back to a LEAD AnnObject></item> <item><description>Shows that the original AnnRectangleObject has been changed to a AnnPolygonObject</description></item> </list>

Visual BasicCopy Code
Public Sub DicomAnnotationsUtilities_FromAnnObject()
  ' Create an AnnRectangleObject
  Dim annObject As AnnRectangleObject = New AnnRectangleObject()
  annObject.Pen = New AnnPen(Color.Purple, New AnnLength(5, AnnUnit.Pixel))
  annObject.Brush = New AnnSolidBrush(Color.White)
  annObject.Bounds = New AnnRectangle(400, 100, 500, 200)
  ' Create an instance of the converter, and set some properties
  Dim du As DicomAnnotationsUtilities = New DicomAnnotationsUtilities()
  du.LayerName = "Test Layer Name"
  du.Pen = annObject.Pen
  du.Brush = annObject.Brush

  ' Convert to a DicomAnnotationObject
  ' Note that there is no DicomAnnotationObject rectangle type, so it is converted to a polyline
  Dim dicomAnnotationObject As DicomAnnotationObject = du.FromAnnObject(annObject)

  ' Convert back to a LEAD AnnObject
  ' Now the LEAD object will be a polyline, even though the original object was a rectangle
  Dim annObjectNew As AnnObject = du.ToAnnObject(dicomAnnotationObject)

  Dim msg As String = String.Format("Original type [{0}] New type [{1}]", annObject.GetType(), annObjectNew.GetType())
  MessageBox.Show(msg)
 End Sub
C#Copy Code
public void DicomAnnotationsUtilities_FromAnnObject() 

   // Create an AnnRectangleObject 
   AnnRectangleObject annObject = new AnnRectangleObject(); 
   annObject.Pen = new AnnPen(Color.Purple, new AnnLength(5, AnnUnit.Pixel)); 
   annObject.Brush = new AnnSolidBrush(Color.White); 
   annObject.Bounds = new AnnRectangle(400, 100, 500, 200); 
   // Create an instance of the converter, and set some properties 
   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities(); 
   du.LayerName = "Test Layer Name"; 
   du.Pen = annObject.Pen; 
   du.Brush = annObject.Brush; 
 
   // Convert to a DicomAnnotationObject 
   // Note that there is no DicomAnnotationObject rectangle type, so it is converted to a polyline 
   DicomAnnotationObject dicomAnnotationObject = du.FromAnnObject(annObject); 
 
   // Convert back to a LEAD AnnObject 
   // Now the LEAD object will be a polyline, even though the original object was a rectangle 
   AnnObject annObjectNew = du.ToAnnObject(dicomAnnotationObject); 
 
   string msg = string.Format("Original type [{0}]     New type [{1}]", annObject.GetType(), annObjectNew.GetType()); 
   MessageBox.Show(msg); 
}

Remarks

A DicomAnnotationObject has a layer name, but an AnnObject does not. Set the LayerName property prior to calling this method.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Dicom.Annotations requires a Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features